Skip to content

Commit 0011e22

Browse files
authored
Fix remote case for only_if_parent (#3777)
1 parent 6c6ac09 commit 0011e22

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

sentry_sdk/tracing.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,9 +1228,11 @@ def __init__(
12281228
if otel_span is not None:
12291229
self._otel_span = otel_span
12301230
else:
1231-
skip_span = (
1232-
only_if_parent and not get_current_span().get_span_context().is_valid
1233-
)
1231+
skip_span = False
1232+
if only_if_parent:
1233+
parent_span_context = get_current_span().get_span_context()
1234+
skip_span = not parent_span_context.is_valid or parent_span_context.is_remote
1235+
12341236
if skip_span:
12351237
self._otel_span = INVALID_SPAN
12361238
else:

0 commit comments

Comments
 (0)