Skip to content

Discard UI event transactions without child spans

09760b3
Select commit
Loading
Failed to load commit list.
Draft

feat: Auto-create traces for MAUI navigation events #5111

Discard UI event transactions without child spans
09760b3
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: code-review completed Apr 7, 2026 in 13m 31s

2 issues

code-review: Found 2 issues (2 medium)

Medium

_manualTransactionOnScope is never reset, permanently disabling navigation transactions after first manual transaction - `src/Sentry.Maui/Internal/MauiEventsBinder.cs:338-341`

The comment on line 368-369 states that _manualTransactionOnScope should be 'cleared on the next navigation so we re-evaluate', but the code never sets this flag back to false. Once a user's manual transaction is detected, _manualTransactionOnScope remains true permanently for the singleton MauiEventsBinder, causing all subsequent navigation events to skip creating auto-transactions even after the user's transaction has finished. This contradicts the stated design intent.

Race condition: non-atomic reset of _activeSpanCount can corrupt counter - `src/Sentry/TransactionTracer.cs:343`

The line _activeSpanCount = 0 (guard against underflow) is a non-atomic assignment that can race with Interlocked.Increment in AddChildSpan. If a new span starts between the Interlocked.Decrement and this reset, its increment will be clobbered, causing the idle timer to restart prematurely or the counter to become inconsistent. This can lead to the idle timer firing while spans are still in flight, resulting in premature transaction completion.


Duration: 13m 26s · Tokens: 4.6M in / 54.0k out · Cost: $7.28 (+extraction: $0.00, +merge: $0.00, +fix_gate: $0.00)

Annotations

Check warning on line 341 in src/Sentry.Maui/Internal/MauiEventsBinder.cs

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

_manualTransactionOnScope is never reset, permanently disabling navigation transactions after first manual transaction

The comment on line 368-369 states that `_manualTransactionOnScope` should be 'cleared on the next navigation so we re-evaluate', but the code never sets this flag back to `false`. Once a user's manual transaction is detected, `_manualTransactionOnScope` remains `true` permanently for the singleton `MauiEventsBinder`, causing all subsequent navigation events to skip creating auto-transactions even after the user's transaction has finished. This contradicts the stated design intent.

Check warning on line 343 in src/Sentry/TransactionTracer.cs

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

Race condition: non-atomic reset of _activeSpanCount can corrupt counter

The line `_activeSpanCount = 0` (guard against underflow) is a non-atomic assignment that can race with `Interlocked.Increment` in `AddChildSpan`. If a new span starts between the `Interlocked.Decrement` and this reset, its increment will be clobbered, causing the idle timer to restart prematurely or the counter to become inconsistent. This can lead to the idle timer firing while spans are still in flight, resulting in premature transaction completion.