Skip to content

fix(core): [Session based Traces for Mobile 4] No longer unfreeze Baggage#5429

Draft
adinauer wants to merge 1 commit into
fix/session-trace-lifecycle-active-sessionfrom
fix/session-trace-lifecycle-baggage-freeze
Draft

fix(core): [Session based Traces for Mobile 4] No longer unfreeze Baggage#5429
adinauer wants to merge 1 commit into
fix/session-trace-lifecycle-active-sessionfrom
fix/session-trace-lifecycle-baggage-freeze

Conversation

@adinauer
Copy link
Copy Markdown
Member

@adinauer adinauer commented May 13, 2026

PR Stack (Session based Traces for Mobile)


📜 Description

Avoids reusing the session propagation context's frozen baggage when remapping root transactions onto the session trace. The remapped transaction now keeps its own transaction baggage as the source and only overrides the session traceId and sampleRand.

This preserves the session trace linkage without creating a mutable copy from already-frozen propagation baggage.

💡 Motivation and Context

Session trace lifecycle needs root transactions to share the session trace ID and sampling random value. The previous approach did that by copying the scope propagation baggage as mutable transaction baggage, effectively unfreezing baggage that had already been frozen during header propagation.

Keeping the transaction baggage as the source avoids that unfreeze behavior while still reusing the session trace identifiers required for session-based traces.

💚 How did you test it?

  • ./gradlew spotlessApply apiDump
  • ./gradlew :sentry:test --tests='io.sentry.BaggageTest' --tests='io.sentry.TransactionContextTest'

📝 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.

🔮 Next steps

Continue the Session based Traces for Mobile stack.

#skip-changelog

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

@sentry
Copy link
Copy Markdown

sentry Bot commented May 13, 2026

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

@github-actions
Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 316.65 ms 362.65 ms 46.00 ms
Size 0 B 0 B 0 B

Baseline results on branch: fix/session-trace-lifecycle-active-session

Startup times

Revision Plain With Sentry Diff
076885a 317.45 ms 372.94 ms 55.49 ms
4147c75 300.84 ms 377.67 ms 76.83 ms

App size

Revision Plain With Sentry Diff
076885a 0 B 0 B 0 B
4147c75 0 B 0 B 0 B

false,
baggage.logger);
source.thirdPartyHeader,
source.mutable,
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.

No longer unfreezing here since we can rely on Baggage still being mutable when creating a new transaction in head of trace scenario.

final @NotNull Baggage baggage =
Baggage.copyWithOverrides(
propagationContext.getBaggage(),
transactionContext.getBaggage(),
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.

Better to use the transactions own Baggage and copy over desired values from Scope instead of the other way around.

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