Skip to content

Commit 0177165

Browse files
committed
fix
1 parent fee89f1 commit 0177165

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

sentry_sdk/tracing_utils.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,12 @@ def add_query_source(
399399
if not should_add_query_source:
400400
return
401401

402-
end_timestamp = (
403-
datetime.now(timezone.utc) if span.end_timestamp is None else span.end_timestamp
404-
)
402+
if isinstance(span, StreamedSpan):
403+
end_timestamp = span.end_timestamp
404+
else:
405+
end_timestamp = span.timestamp
406+
407+
end_timestamp = end_timestamp or datetime.now(timezone.utc)
405408

406409
duration = end_timestamp - span.start_timestamp
407410
threshold = client.options.get("db_query_source_threshold_ms", 0)
@@ -442,9 +445,12 @@ def add_http_request_source(
442445
if not should_add_request_source:
443446
return
444447

445-
end_timestamp = (
446-
datetime.now(timezone.utc) if span.end_timestamp is None else span.end_timestamp
447-
)
448+
if isinstance(span, StreamedSpan):
449+
end_timestamp = span.end_timestamp
450+
else:
451+
end_timestamp = span.timestamp
452+
453+
end_timestamp = end_timestamp or datetime.now(timezone.utc)
448454

449455
duration = end_timestamp - span.start_timestamp
450456
threshold = client.options.get("http_request_source_threshold_ms", 0)

0 commit comments

Comments
 (0)