Skip to content

fix(tracing): Stop idle spans from keeping idle transactions alive until their deadline (JAVA-795) - #6396

Open
0xadam-brown wants to merge 1 commit into
mainfrom
fix/sentry-nav-traced-idling
Open

0xadam-brown wants to merge 1 commit into
mainfrom
fix/sentry-nav-traced-idling

Conversation

@0xadam-brown

@0xadam-brown 0xadam-brown commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

📜 Description

An idle span (SpanOptions.isIdle()) is meant to be finished by its parent transaction when the transaction finishes. Before this PR, SentryTracer treated an unfinished idle span as blocking. Creating one canceled the idle timer; SentryTracer.hasAllChildrenFinished() counted it as unfinished; and the timer never restarted.

As a consequence, any idle transaction that i) waited for its children (i.e., all Android idle transactions, including ui.load and nav transactions) and ii) had an unfinished idle span, was kept alive until its deadline (30 s by default). That in turn caused the transaction to be reported as DEADLINE_EXCEEDED even though in most cases no actual work was keeping the transaction alive.

💡 Motivation and Context

I discovered this issue while implementing multi-Activity support for Nav3 (see #6301).

Current producers of idle spans

SentryTraced is the SDK's sole producer of idle spans in sentry-java (link), so the effects mentioned above are limited to idle transactions that, prior to this commit, contained a span from SentryTraced.

(The issue has been with SentryTraced from the beginning.)

💚 How did you test it?

Unit tests + had my clanker verify pre- and post-fix behavior via the Android sample app.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

@linear-code

linear-code Bot commented Oct 27, 2026

Copy link
Copy Markdown

JAVA-795

@0xadam-brown 0xadam-brown added the sanity-check PR needs a lightweight review for obvious issues label Oct 27, 2026
@sentry

sentry Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.62.0 (1) release

⚙️ sentry-android Build Distribution Settings

@0xadam-brown
0xadam-brown force-pushed the fix/sentry-nav-traced-idling branch from 7c18f01 to b2fddd4 Compare October 27, 2026 16:19
…til their deadline (JAVA-795)

An idle span (SpanOptions.isIdle) is meant to be finished by its parent transaction when the transaction finishes. Before this commit, SentryTracer treated an unfinished idle span as blocking. Creating one canceled the idle timer; SentryTracer.hasAllChildrenFinished() counted it as unfinished; and the timer never restarted. As a consequence, any idle transaction that i) waited for its children (i.e., all Android idle transactions, including ui.load and nav transactions) and ii) had an unfinished idle span was kept alive until its deadline (30 s by default), causing it to be reported as DEADLINE_EXCEEDED even though in most cases no actual work was keeping the transaction alive.

**Current producers of idle spans**

SentryTraced is the SDK's only producer of idle spans, so the effects mentioned above are limited to idle transactions that, prior to this commit, contained a span from SentryTraced. (The issue has been with SentryTraced from the beginning – see #2507).
@0xadam-brown
0xadam-brown force-pushed the fix/sentry-nav-traced-idling branch from b2fddd4 to b1bdbbb Compare October 27, 2026 16:27
@0xadam-brown
0xadam-brown marked this pull request as ready for review October 27, 2026 16:28
@0xadam-brown
0xadam-brown requested review from a team and adinauer as code owners October 27, 2026 16:28

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sanity-check PR needs a lightweight review for obvious issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant