Skip to content

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

Draft
adinauer wants to merge 3 commits into
9.x.xfrom
fix/immutable-tracing-options
Draft

adinauer wants to merge 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>

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant