feat: Auto-create traces for MAUI navigation events #5111
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
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
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.