Skip to content

Commit e323b61

Browse files
fix(boto3): handle NoOpStreamedSpan in span finishing and request creation
1 parent 985a99b commit e323b61

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎sentry_sdk/integrations/boto3/_instrumentation.py‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import sentry_sdk
88
from sentry_sdk.consts import OP, SPANDATA, SPANSTATUS
99
from sentry_sdk.integrations.boto3 import Boto3Integration
10-
from sentry_sdk.traces import StreamedSpan
10+
from sentry_sdk.traces import NoOpStreamedSpan, StreamedSpan
1111
from sentry_sdk.tracing import BAGGAGE_HEADER_NAME, Span
1212
from sentry_sdk.tracing_utils import (
1313
add_http_breadcrumb,
@@ -133,6 +133,9 @@ def _finish_client_span(
133133
) -> None:
134134
span.__exit__(None, None, None)
135135

136+
if isinstance(span, NoOpStreamedSpan):
137+
return
138+
136139
body = parsed.get("Body")
137140
if not isinstance(body, StreamingBody):
138141
return
@@ -271,6 +274,14 @@ def _sentry_request_created(
271274

272275
if has_span_streaming_enabled(client.options):
273276
span = sentry_sdk.traces.get_current_span()
277+
# an ignored `NoOpStreamedSpan` is not activated, so
278+
# `get_current_span()` may return the parent; do not enrich it.
279+
if (
280+
span is None
281+
or span.get_attributes().get(SPANDATA.SENTRY_ORIGIN)
282+
!= Boto3Integration.origin
283+
):
284+
return
274285
else:
275286
span = sentry_sdk.get_current_span()
276287
if span is None:

0 commit comments

Comments
 (0)