Skip to content

Commit ad47675

Browse files
committed
add trace_id
1 parent 65e667c commit ad47675

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

sentry_sdk/traces.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
sentry_sdk.init(_experiments={"trace_lifecycle": "stream"}).
66
"""
77

8+
import uuid
9+
from typing import TYPE_CHECKING
10+
11+
if TYPE_CHECKING:
12+
from typing import Optional
13+
814

915
class StreamedSpan:
1016
"""
@@ -16,4 +22,18 @@ class StreamedSpan:
1622
span implementation lives in tracing.Span.
1723
"""
1824

19-
pass
25+
__slots__ = ("_trace_id",)
26+
27+
def __init__(
28+
self,
29+
*,
30+
trace_id: "Optional[str]" = None,
31+
):
32+
self._trace_id = trace_id
33+
34+
@property
35+
def trace_id(self) -> str:
36+
if not self._trace_id:
37+
self._trace_id = uuid.uuid4().hex
38+
39+
return self._trace_id

0 commit comments

Comments
 (0)