Skip to content

add finished to noop span

bd9e0a3
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
Merged

ref: Add sampling to span first (11) #5617

add finished to noop span
bd9e0a3
Select commit
Loading
Failed to load commit list.
GitHub Actions / warden: code-review completed Mar 10, 2026 in 1m 42s

2 issues

code-review: Found 2 issues (1 high, 1 medium)

High

Uninitialized `_finished` attribute causes AttributeError on first call to `_end()` - `sentry_sdk/traces.py:485`

The _finished attribute is declared in __slots__ but never initialized in __init__. When _end() is called, the check if self._finished: on line 485 will raise an AttributeError because the attribute doesn't exist yet. This affects every NoOpStreamedSpan when it finishes, breaking span cleanup.

Medium

Baggage mutability check missing before modification - `sentry_sdk/scope.py:1254-1255`

The _update_sample_rate method modifies baggage.sentry_items["sample_rate"] without checking if the baggage is mutable. According to the Baggage class documentation, callers must check baggage.mutable is True before mutation. When a trace is continued from an incoming header containing sentry items, the baggage is immutable (mutable=False), so this modification violates the baggage contract and could lead to unexpected behavior in trace propagation.


Duration: 1m 37s · Tokens: 1.1M in / 10.4k out · Cost: $1.43 (+extraction: $0.00, +merge: $0.00, +fix_gate: $0.00)

Annotations

Check failure on line 485 in sentry_sdk/traces.py

See this annotation in the file changed.

@github-actions github-actions / warden: code-review

Uninitialized `_finished` attribute causes AttributeError on first call to `_end()`

The `_finished` attribute is declared in `__slots__` but never initialized in `__init__`. When `_end()` is called, the check `if self._finished:` on line 485 will raise an `AttributeError` because the attribute doesn't exist yet. This affects every `NoOpStreamedSpan` when it finishes, breaking span cleanup.

Check warning on line 1255 in sentry_sdk/scope.py

See this annotation in the file changed.

@github-actions github-actions / warden: code-review

Baggage mutability check missing before modification

The `_update_sample_rate` method modifies `baggage.sentry_items["sample_rate"]` without checking if the baggage is mutable. According to the Baggage class documentation, callers must check `baggage.mutable` is `True` before mutation. When a trace is continued from an incoming header containing sentry items, the baggage is immutable (`mutable=False`), so this modification violates the baggage contract and could lead to unexpected behavior in trace propagation.