Skip to content

fix(core): [Tracing API Cleanup 2] Snapshot tracing options - #6417

Merged
adinauer merged 3 commits into
9.x.xfrom
fix/immutable-tracing-options
Nov 12, 2026
Merged

adinauer merged 3 commits into
9.x.xfrom
fix/immutable-tracing-options

Conversation

@adinauer

@adinauer adinauer commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

PR Stack (Tracing API Cleanup)


📜 Description

Snapshots SpanOptions and TransactionOptions when spans and transactions are created. Deferred tracing behavior now uses the values captured at creation time instead of retaining caller-owned mutable option objects.

Timestamp-based child creation also applies timestamps to copied options in both native and OpenTelemetry paths, including null timestamps, while leaving caller-owned options unchanged.

💡 Motivation and Context

Mutating tracing options after creating a span or transaction could change its trimming, idle handling, timer, child-waiting, or callback behavior. Timestamp-based child creation could also mutate the caller's SpanOptions instance.

Fixes #6416.

💚 How did you test it?

  • ./gradlew :sentry:test
  • ./gradlew :sentry-opentelemetry:sentry-opentelemetry-core:test
  • ./gradlew :sentry:apiCheck spotlessCheck
  • ./gradlew spotlessApply updateKotlinAbi

📝 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

None.

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

Prevent caller mutations to SpanOptions and TransactionOptions from
changing spans and transactions after they have been created. Copy span
options before applying explicit timestamps in native and OpenTelemetry
paths.

Fixes #6416
Co-Authored-By: Claude <noreply@anthropic.com>
@sentry

sentry Bot commented Oct 29, 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

Base automatically changed from ref/remove-instrumenter-v9 to 9.x.x October 29, 2026 15:11
Apply the explicit timestamp argument to copied span options even when
it is null. This matches native tracing while preserving caller-owned
options.

Refs #6416
Co-Authored-By: Claude <noreply@anthropic.com>

@markushi markushi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice one, thanks for taking care of that!

@adinauer
adinauer marked this pull request as ready for review November 12, 2026 10:03
@adinauer
adinauer requested a review from a team as a code owner November 12, 2026 10:03
@adinauer
adinauer requested review from 0xadam-brown and runningcode and removed request for a team November 12, 2026 10:03
@adinauer
adinauer merged commit fe83822 into 9.x.x Nov 12, 2026
40 of 42 checks passed
@adinauer
adinauer deleted the fix/immutable-tracing-options branch November 12, 2026 10:03
@github-actions

Copy link
Copy Markdown
Contributor
Fails
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Fixes

- [Tracing API Cleanup 2] Snapshot tracing options ([#6417](https://github.com/getsentry/sentry-java/pull/6417))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against 4395ef6

adinauer added a commit that referenced this pull request Nov 12, 2026
…shed (#6595)

#6417 replaced Span.getOptions() with Span.isIdle(), but #6415 merged
right after and brought back the old span.getOptions().isIdle() call,
so 9.x.x no longer compiles.

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Alexander Dinauer <alexander.dinauer@sentry.io>
@sentry-junior sentry-junior Bot mentioned this pull request Nov 17, 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.

2 participants