Skip to content

feat(tracing): Add empty baggage header propagation to outgoing requests #5133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
May 23, 2022

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented May 19, 2022

This PR adds the propagation of an "empty" baggage header. The word "empty" is however kind of misleading as the header is not necessarily empty. In order to comply with the baggage spec, as of this PR, we propagate incoming (3rd party) baggage to outgoing requests. The important part of this PR is that we actually add the baggage HTTP header to outgoing requests which is a breaking change in terms of CORS rules having to be adjusted.

We don't yet add sentry- baggage entries to the propagated baggage. This will come in a follow up PR which does not necessarily have to be part of the initial v7 release as it is no longer a breaking change.

Overall, the PR is heavily inspired from #3945 (thanks @lobsterkatie for doing the hard work)

More specifically, this PR does the following things:

  1. Extract incoming baggage headers and store them in the created transaction's metadata. Incoming baggage data is intercepted at:
  • Node SDK: TracingHandler
  • Serverless SDK: AWS wrapHandler
  • Serverless SDK: GCP wrapHttpFunction
  • Next.js: SDK makeWrappedReqHandler
  • Next.js: SDK withSentry
  • BrowserTracing Integration: by parsing the <meta> tags (analogously to the sentry-trace header)
  1. Add the extracted baggage data to outgoing requests we instrument at:
  • Node SDK: HTTP integration
  • Tracing: instrumented Fetch and XHR callbacks

Note that there is still a lot to be done until we have a properly working baggage propagation. This PR should add much of the necessary groundwork but it is far from complete. I'm very open for improvement suggestions (also I might have missed something) and already added a few TODOs to follow up on in future PRs. We will iterate on baggage in upcoming PRs (potentially post-v7.0.0).

Also commented out lambda stuff because it's broken with the changed GH action.

ref: https://getsentry.atlassian.net/browse/WEB-925

@Lms24 Lms24 changed the title feat(tracing): Add baggage header propagation to outgoing requests feat(tracing): Add empty baggage header propagation to outgoing requests May 19, 2022
@github-actions
Copy link
Contributor

github-actions bot commented May 19, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.33 KB (-4.03% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 59.9 KB (-7.29% 🔽)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.18 KB (-3.6% 🔽)
@sentry/browser - ES6 CDN Bundle (minified) 53.59 KB (-7.56% 🔽)
@sentry/browser - Webpack (gzipped + minified) 19.88 KB (-14.47% 🔽)
@sentry/browser - Webpack (minified) 63.04 KB (-22.86% 🔽)
@sentry/react - Webpack (gzipped + minified) 19.9 KB (-14.51% 🔽)
@sentry/nextjs Client - Webpack (gzipped + minified) 43.82 KB (-8.82% 🔽)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 25.44 KB (-2.46% 🔽)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 23.93 KB (-2.24% 🔽)

@Lms24 Lms24 force-pushed the lms-empty-baggage-header branch 3 times, most recently from 28f161e to 4149c9d Compare May 20, 2022 12:57
@Lms24 Lms24 marked this pull request as ready for review May 20, 2022 15:01
Copy link
Contributor

@lforst lforst left a comment

Choose a reason for hiding this comment

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

Great work! Good tests! Review is only nits.

@Lms24 Lms24 force-pushed the lms-empty-baggage-header branch from f8eff24 to c95af98 Compare May 23, 2022 10:21
@Lms24 Lms24 merged commit d48711f into 7.x May 23, 2022
@Lms24 Lms24 deleted the lms-empty-baggage-header branch May 23, 2022 12:18
AbhiPrasad pushed a commit that referenced this pull request May 30, 2022
…sts (#5133)

Adds the propagation of an "empty" baggage header. The word "empty" is however kind of misleading as the header is not necessarily empty. In order to comply with the baggage spec, as of this patch, we propagate incoming (3rd party) baggage to outgoing requests. The important part is that we actually add the `baggage` HTTP header to outgoing requests which is a breaking change in terms of CORS rules having to be adjusted.

We don't yet add `sentry-` baggage entries to the propagated baggage. This will come in a follow up PR which does not necessarily have to be part of the initial v7 release as it is no longer a breaking change. 

Overall, this is heavily inspired from #3945 (thanks @lobsterkatie for doing the hard work)

More specifically, this PR does the following things:

1. Extract incoming baggage headers and store them in the created transaction's metadata. Incoming baggage data is intercepted at:
* Node SDK: TracingHandler
* Serverless SDK: AWS wrapHandler
* Serverless SDK: GCP wrapHttpFunction
* Next.js: SDK makeWrappedReqHandler
* Next.js: SDK withSentry
* BrowserTracing Integration: by parsing the `<meta>` tags (analogously to the `sentry-trace` header)

2. Add the extracted baggage data to outgoing requests we instrument at:
* Node SDK: HTTP integration
* Tracing: instrumented Fetch and XHR callbacks

Co-authored-by: Luca Forstner <[email protected]>
@AbhiPrasad AbhiPrasad added this to the 7.0.0 milestone May 30, 2022
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.

3 participants