Skip to content

fix(core): [Session based Traces for Mobile 2] Keep transaction baggage mutable#5402

Draft
adinauer wants to merge 1 commit into
ref/remove-propagation-context-modefrom
fix/session-based-traces-mobile-transaction-baggage
Draft

fix(core): [Session based Traces for Mobile 2] Keep transaction baggage mutable#5402
adinauer wants to merge 1 commit into
ref/remove-propagation-context-modefrom
fix/session-based-traces-mobile-transaction-baggage

Conversation

@adinauer
Copy link
Copy Markdown
Member

@adinauer adinauer commented May 11, 2026

PR Stack (Session based Traces for Mobile)


📜 Description

Keeps transaction baggage mutable when remapping a root transaction onto the current session trace. This lets each transaction populate its own DSC fields even if the ambient session propagation baggage was already frozen by an earlier outgoing request without an active transaction.

Adds regression coverage for:

  • starting a new session
  • producing outgoing headers without an active transaction, freezing the session baggage
  • starting a transaction in the session trace and verifying outgoing transaction baggage
  • finishing that transaction, then starting a second transaction and verifying its baggage too

💡 Motivation and Context

Session trace lifecycle can freeze ambient scope baggage before any transaction starts. If a later transaction reuses that frozen baggage directly, outgoing transaction propagation can miss transaction-specific DSC such as sentry-transaction, sentry-sampled, sentry-sample_rate, and sentry-sample_rand.

This keeps the session trace id and sample rand while allowing each remapped transaction to complete its own outgoing baggage.

💚 How did you test it?

  • ./gradlew spotlessApply apiDump
  • ./gradlew :sentry:test --tests 'io.sentry.BaggageTest' --tests 'io.sentry.ScopesTest.session trace transaction baggage is populated after scope baggage is frozen'

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

Copying session trace baggage for a transaction now creates mutable baggage so the transaction can populate DSC fields even if the ambient session baggage was already frozen by an earlier outgoing request.

Co-Authored-By: Claude <noreply@anthropic.com>
@sentry
Copy link
Copy Markdown

sentry Bot commented May 11, 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 317.06 ms 375.78 ms 58.72 ms
Size 0 B 0 B 0 B

Baseline results on branch: ref/remove-propagation-context-mode

Startup times

Revision Plain With Sentry Diff
f15a0c5 321.71 ms 365.46 ms 43.75 ms
c183fb7 368.02 ms 436.96 ms 68.94 ms

App size

Revision Plain With Sentry Diff
f15a0c5 0 B 0 B 0 B
c183fb7 0 B 0 B 0 B

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