Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sentry_sdk/tracing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ def extract_sentrytrace_data(header):
trace_id, parent_span_id, sampled_str = match.groups()
parent_sampled = None

if trace_id:
if trace_id and len(trace_id) != 32:
trace_id = "{:032x}".format(int(trace_id, 16))
Comment on lines +370 to 371
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the string formatting is really redundant after the regex match, the string formatting logic can be removed.

There's no point checking len(trace_id) != 32, because to reach this point the regex has matched, so the string must be 32 characters long.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, can just remove it

if parent_span_id:
if parent_span_id and len(parent_span_id) != 16:
parent_span_id = "{:016x}".format(int(parent_span_id, 16))
if sampled_str:
parent_sampled = sampled_str != "0"
Expand Down
Loading