ref: Support outgoing trace propagation in span first (18)#5638
2 issues
code-review: Found 2 issues (1 high, 1 medium)
High
Calling _iter_headers on NoOpStreamedSpan raises AttributeError due to missing _segment - `sentry_sdk/traces.py:504-512`
The _iter_headers method (lines 504-512) accesses self._segment, but NoOpStreamedSpan never initializes this attribute. When iter_trace_propagation_headers in scope.py calls span._iter_headers() without checking for NoOpStreamedSpan, it will raise AttributeError: 'NoOpStreamedSpan' object has no attribute '_segment'. The guard if not self._segment doesn't help because it requires _segment to exist. Similarly, _dynamic_sampling_context, _to_baggage, and _get_baggage will fail for the same reason.
Also found at:
sentry_sdk/tracing_utils.py:1117-1118
Medium
Early return in set_transaction_name skips transaction_info source storage - `sentry_sdk/scope.py:843`
When self._span is a NoOpStreamedSpan, the method returns early on line 843, which skips the self._transaction_info["source"] = source assignment on line 858. In the old code, the source was always stored in _transaction_info regardless of the span type. This behavioral change could affect event processing that relies on _transaction_info["source"] being set.
Duration: 11m 5s · Tokens: 3.5M in / 44.9k out · Cost: $4.41 (+extraction: $0.01, +merge: $0.00, +fix_gate: $0.00)
Annotations
Check failure on line 512 in sentry_sdk/traces.py
github-actions / warden: code-review
Calling _iter_headers on NoOpStreamedSpan raises AttributeError due to missing _segment
The `_iter_headers` method (lines 504-512) accesses `self._segment`, but `NoOpStreamedSpan` never initializes this attribute. When `iter_trace_propagation_headers` in `scope.py` calls `span._iter_headers()` without checking for `NoOpStreamedSpan`, it will raise `AttributeError: 'NoOpStreamedSpan' object has no attribute '_segment'`. The guard `if not self._segment` doesn't help because it requires `_segment` to exist. Similarly, `_dynamic_sampling_context`, `_to_baggage`, and `_get_baggage` will fail for the same reason.
Check failure on line 1118 in sentry_sdk/tracing_utils.py
github-actions / warden: code-review
[BFZ-FAG] Calling _iter_headers on NoOpStreamedSpan raises AttributeError due to missing _segment (additional location)
The `_iter_headers` method (lines 504-512) accesses `self._segment`, but `NoOpStreamedSpan` never initializes this attribute. When `iter_trace_propagation_headers` in `scope.py` calls `span._iter_headers()` without checking for `NoOpStreamedSpan`, it will raise `AttributeError: 'NoOpStreamedSpan' object has no attribute '_segment'`. The guard `if not self._segment` doesn't help because it requires `_segment` to exist. Similarly, `_dynamic_sampling_context`, `_to_baggage`, and `_get_baggage` will fail for the same reason.
Check warning on line 843 in sentry_sdk/scope.py
github-actions / warden: code-review
Early return in set_transaction_name skips transaction_info source storage
When `self._span` is a `NoOpStreamedSpan`, the method returns early on line 843, which skips the `self._transaction_info["source"] = source` assignment on line 858. In the old code, the source was always stored in `_transaction_info` regardless of the span type. This behavioral change could affect event processing that relies on `_transaction_info["source"]` being set.