Skip to content

Commit 2529a75

Browse files
committed
rebase main
2 parents 49addb8 + 090afda commit 2529a75

8 files changed

Lines changed: 507 additions & 8 deletions

File tree

CHANGLOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
## [0.1.22] - 2026-01-05
1+
## [0.1.23] - 2026-01-07
22
### Added
33
- lcc support child_of and state_span_ctx_key
44
- lcc support multi clients
55
- llc support get trace_id and root_span_id
66

7+
## [0.1.22] - 2026-01-06
8+
### Added
9+
- support span discard
10+
711
## [0.1.21] - 2025-12-23
812
### Added
913
- runtime scene support get from env

cozeloop/decorator/decorator.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def sync_wrapper(*args: Any, **kwargs: Any):
101101
span.set_tags(tags)
102102
span.finish()
103103

104-
if res:
104+
if res is not None:
105105
return res
106106

107107
@wraps(func)
@@ -140,7 +140,7 @@ async def async_wrapper(*args: Any, **kwargs: Any):
140140
span.set_tags(tags)
141141
span.finish()
142142

143-
if res:
143+
if res is not None:
144144
return res
145145

146146
@wraps(func)
@@ -249,7 +249,7 @@ def sync_stream_wrapper(*args: Any, **kwargs: Any):
249249
span.set_input(input)
250250
span.set_tags(tags)
251251

252-
if not hasattr(res, "__iter__") and res:
252+
if not hasattr(res, "__iter__") and res is not None:
253253
return res
254254

255255
@wraps(func)
@@ -288,7 +288,7 @@ async def async_stream_wrapper(*args: Any, **kwargs: Any):
288288
span.set_input(input)
289289
span.set_tags(tags)
290290

291-
if not hasattr(res, "__aiter__") and res:
291+
if not hasattr(res, "__aiter__") and res is not None:
292292
return res
293293

294294
if is_async_gen_func(func):
@@ -423,7 +423,7 @@ async def __aiter__(self) -> AsyncIterator[S]:
423423
await self._aend()
424424
raise
425425
except Exception as e:
426-
await self._aend()
426+
await self._aend(e)
427427
raise e
428428
else:
429429
await self._aend()
@@ -449,7 +449,7 @@ async def __async_streamer__(
449449
self.__span.set_start_time_first_resp(time.time_ns() // 1_000)
450450
self.__is_set_start_time_first_token = True
451451
yield s
452-
except StopIteration:
452+
except (StopIteration, StopAsyncIteration):
453453
pass
454454

455455

cozeloop/internal/trace/noop_span.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def set_tags(self, tag_kvs: Dict[str, Any]) -> None:
3434
def set_baggage(self, baggage_items: Dict[str, str]) -> None:
3535
pass
3636

37+
def discard(self) -> None:
38+
pass
39+
3740
def finish(self) -> None:
3841
pass
3942

cozeloop/internal/trace/span.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,9 @@ def set_baggage_item(self, restricted_key: str, value: str):
490490
with self.lock:
491491
super().set_baggage_item(restricted_key, value)
492492

493+
def discard(self) -> None:
494+
delete_span_in_context(self.span_id)
495+
493496
def finish(self):
494497
try:
495498
if not self.is_do_finish():

cozeloop/internal/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
22
# SPDX-License-Identifier: MIT
33

4-
VERSION = 'v0.1.21'
4+
VERSION = 'v0.1.23'

cozeloop/span.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ def finish(self) -> None:
218218
Under the hood, it is actually placed in an asynchronous queue waiting to be reported.
219219
"""
220220

221+
@abstractmethod
222+
def discard(self) -> None:
223+
"""
224+
The span will be discarded, not be reported.
225+
"""
226+
221227
@property
222228
@abstractmethod
223229
def start_time(self) -> datetime:

tests/decorator/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)