Skip to content

Commit

Permalink
Make sure trace_id is set from propagation context if existing.
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpirker committed Jun 27, 2023
1 parent 9b8a3cf commit 375d077
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,15 @@ def __init__(
start_timestamp=None, # type: Optional[datetime]
):
# type: (...) -> None
self.trace_id = trace_id or uuid.uuid4().hex
if trace_id:
self.trace_id = trace_id
elif hub:
traceparent = hub.get_traceparent()
if traceparent:
self.trace_id = traceparent.split("-")[0]
if not self.trace_id:
self.trace_id = uuid.uuid4().hex

Check warning on line 140 in sentry_sdk/tracing.py

View check run for this annotation

Codecov / codecov/patch

sentry_sdk/tracing.py#L140

Added line #L140 was not covered by tests

self.span_id = span_id or uuid.uuid4().hex[16:]
self.parent_span_id = parent_span_id
self.same_process_as_parent = same_process_as_parent
Expand Down

0 comments on commit 375d077

Please sign in to comment.