Skip to content

feat(apollo): Add a flag to stop attaching tracing headers in SentryApolloInterceptor - #6414

Merged
adinauer merged 3 commits into
getsentry:mainfrom
lazerg:fix/apollo-tracing-headers-opt-out
Oct 29, 2026
Merged

adinauer merged 3 commits into
getsentry:mainfrom
lazerg:fix/apollo-tracing-headers-opt-out

Conversation

@lazerg

@lazerg lazerg commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

SentryApolloInterceptor has a new attachTracingHeaders constructor parameter. It defaults to true, so nothing changes unless you pass false. With false, the interceptor still creates spans, but it doesn't add the sentry-trace and baggage headers to the request.

The existing two-parameter primary constructor remains unchanged, preserving its Java and Kotlin binary API. A secondary constructor exposes attachTracingHeaders while retaining Kotlin usage such as SentryApolloInterceptor(attachTracingHeaders = false).

💡 Motivation and Context

In Apollo v2 the interceptor can't see the request URL, so it attaches tracing headers to every request without checking tracePropagationTargets. Before this change there was no way to turn that off. On the issue, @adinauer picked the opt-out flag.

💚 How did you test it?

I added a test that builds the interceptor with attachTracingHeaders = false and checks that the request has no sentry-trace or baggage header. It fails without the change. ./gradlew :sentry-apollo:check passes locally.

📝 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

The docs page for the Apollo integration could mention the new flag.

@lazerg

lazerg commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

I manually reviewed and verified each code in local before pushing

@adinauer

Copy link
Copy Markdown
Member

Thanks for the PR @lazerg . Will take a look and maybe shuffle some things.

Keep the existing Kotlin default-argument constructor ABI while exposing the tracing-header opt-out through a secondary constructor. This prevents runtime linkage failures for precompiled consumers upgrading the SDK.

Co-Authored-By: Claude <noreply@anthropic.com>
@adinauer
adinauer marked this pull request as ready for review October 29, 2026 10:33
@adinauer
adinauer requested review from a team and adinauer as code owners October 29, 2026 10:33
@adinauer
adinauer requested review from 0xadam-brown and runningcode and removed request for a team October 29, 2026 10:33

@adinauer adinauer 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.

LGTM, thank you for the contribution!

@adinauer
adinauer merged commit bdfdc76 into getsentry:main Oct 29, 2026
39 checks passed
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.

Add a flag to SentryApolloInterceptor to stop attaching tracing headers for Apollo v2

2 participants