Skip to content

fix(compose): Honor ignored origins for SentryTraced spans - #6058

Open
0xadam-brown wants to merge 1 commit into
fix/sentry-traced-stale-parentfrom
fix/sentry-traced-origin-filtering-bug
Open

fix(compose): Honor ignored origins for SentryTraced spans#6058
0xadam-brown wants to merge 1 commit into
fix/sentry-traced-stale-parentfrom
fix/sentry-traced-origin-filtering-bug

Conversation

@0xadam-brown

Copy link
Copy Markdown
Member

📜 Description

Fixes a bug where we set span origins for SentryTraced after their creation via the span context, resulting in our ignore-span-origins logic not being able to see them and spans being produced when they should have been ignored / suppressed.

💡 Motivation and Context

This issue has been with us for a while, but was discovered (along with a number of others) in connection with my Nav3 work.

The general rule is that we need to set span origins during creation and not afterwards via span context or else checks list ignoreSpanOrigins will be ignored.

What went wrong?

SentryTracer checks ignoredSpanOrigins during span creation, before the returned span can be mutated:

if (SpanUtils.isIgnored(scopes.getOptions().getIgnoredSpanOrigins(), spanOptions.getOrigin())) {
  return NoOpSpan.getInstance();
}

That check reads SpanOptions.origin, not the SpanContext.origin we were setting after creation.

So if a host app did this...

options.setIgnoredSpanOrigins(listOf("auto.ui.jetpack_compose"))

...it would no-op and the Compose spans were created nonetheless.

The issue affected both levels of the SentryTraced span hierarchy (ie, both parent spans and child spans).

💚 How did you test it?

Unit regression test + I had my clanker verify the fix works and is correct via our Android sample apps.

📝 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

@0xadam-brown
0xadam-brown force-pushed the fix/sentry-traced-origin-filtering-bug branch from 3db1e97 to a8aeb7e Compare September 5, 2026 13:35
Fix a bug where we set span origins for SentryTraced after their creation via the span context, resulting in our ignore-span-origins logic not being able to see them and spans being produced when they should have been ignored / suppressed.

What was happening?

SentryTracer checks `ignoredSpanOrigins` during span creation, before the returned span can be mutated:

```java
if (SpanUtils.isIgnored(scopes.getOptions().getIgnoredSpanOrigins(), spanOptions.getOrigin())) {
  return NoOpSpan.getInstance();
}
```

That check reads SpanOptions.origin, not the SpanContext.origin we were setting after creation.

So if a host app did this...

```kotlin
options.setIgnoredSpanOrigins(listOf("auto.ui.jetpack_compose"))
```

...it would no-op and the Compose spans were created nonetheless.

The issue affected both levels of the SentryTraced span hierarchy (ie, both parent spans and child spans).
@0xadam-brown
0xadam-brown force-pushed the fix/sentry-traced-origin-filtering-bug branch from a8aeb7e to 7b13e55 Compare September 5, 2026 13:36
OP_COMPOSITION_CHILD,
tag,
startTimestamp,
Instrumenter.SENTRY,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: We have to specify the instrumenter explicitly b/c the only startChild() method that permits setting both the start timestamp and SentryOptions requires it. (This doesn't change behavior, as SentryTraced has always started children via Instrumenter.SENTRY under the hood.)

@0xadam-brown
0xadam-brown marked this pull request as ready for review September 5, 2026 13:39
@sentry

sentry Bot commented Sep 5, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

@0xadam-brown 0xadam-brown changed the title fix(compose): Honor ignored origins in SentryTraced spans fix(compose): Honor ignored origins for SentryTraced spans Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant