Skip to content

Commit 090afda

Browse files
authored
aupport span discard (#44)
1 parent 6005cb9 commit 090afda

File tree

5 files changed

+17
-1
lines changed

5 files changed

+17
-1
lines changed

CHANGLOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.1.22] - 2026-01-06
2+
### Added
3+
- support span discard
4+
15
## [0.1.21] - 2025-12-23
26
### Added
37
- runtime scene support get from env

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/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:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "cozeloop"
3-
version = "0.1.21"
3+
version = "0.1.22"
44
description = "coze loop sdk"
55
authors = ["JiangQi715 <jiangqi.rrt@bytedance.com>"]
66
license = "MIT"

0 commit comments

Comments
 (0)