-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(tracing): Handle incoming tracestate data, allow for third-party data #3275
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
feat(tracing): Handle incoming tracestate data, allow for third-party data #3275
Conversation
size-limit report
|
01f2b1c
to
b808fcc
Compare
4a57c05
to
fbd3c0f
Compare
fbd3c0f
to
06e8d3b
Compare
The linting error is solved in a follow-up cleanup PR to come once this is merged into the feature branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, skimmed over it at it makes sense
const sentrytraceData = sentrytraceValue ? extractSentrytraceData(sentrytraceValue) : undefined; | ||
const tracestateData = tracestateValue ? extractTracestateData(tracestateValue) : undefined; | ||
|
||
if (sentrytraceData || tracestateData?.sentry || tracestateData?.thirdparty) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tracestateData?.thirdparty
is useless here, as it will never be reached due to the first sentrytraceData
check already shorting it with its truthiness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But sentrytraceData
isn't guaranteed to be truthy - if the sentry-trace
<meta>
tag isn't there, or if the value is somehow malformed, you could have tracestate
data without having sentry-trace
data. Similarly, if we have a tracesatate
value in which there's no sentry portion (or the sentry portion is malformed), then we could have third-party tracestate
data without having sentry tracestate
data. So I think we need all three checks, since the existence of each value is independent of the existence of the others.
packages/tracing/src/utils.ts
Outdated
|
||
// remove the commas after the split so we don't end up with `xxx=yyy,,zzz=qqq` (double commas) when we put them | ||
// back together | ||
[before, after] = header.split(sentryEntry).map(s => s.replace(/^,*|,*$/g, '')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[before, after] = header.split(sentryEntry).map(s => s.replace(/^,*|,*$/g, '')); | |
[before, after] = header.split(sentryEntry).map(s => s.replace(/,/g, '')); |
This should be good enough I guess. We don't allow for commas anywhere in the middle of a value anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, no. That's what I had originally, but if the header comes in with a value like
x=y,sentry=blah,a=b,c=d
then getting rid of all commas gets rid of the comma between a=b
and c=d
, which isn't what we want.
This is the result of rebasing the feature branch for the initial implementation of `tracestate` header handling (which had grown very stale) on top of current `master`. That branch is going to get deleted, so for posterity, it included the following PRs (oldest -> newest): feat(tracing): Add dynamic sampling correlation context data to envelope header (#3062) chore(utils): Split browser/node compatibility utils into separate module (#3123) ref(tracing): Prework for initial `tracestate` implementation (#3242) feat(tracing): Add `tracestate` header to outgoing requests (#3092) ref(tracing): Rework tracestate internals to allow for third-party data (#3266) feat(tracing): Handle incoming tracestate data, allow for third-party data (#3275) chore(tracing): Various small fixes to first `tracestate` implementation (#3291) fix(tracing): Use `Request.headers.append` correctly (#3311) feat(tracing): Add user data to tracestate header (#3343) chore(various): Small fixes (#3368) fix(build): Prevent Node's `Buffer` module from being included in browser bundles (#3372) fix(tracing): Remove undefined tracestate data rather than setting it to `null` (#3373) More detail in the PR description.
This is the result of rebasing the feature branch for the initial implementation of `tracestate` header handling (which had grown very stale) on top of current `master`. That branch is going to get deleted, so for posterity, it included the following PRs (oldest -> newest): feat(tracing): Add dynamic sampling correlation context data to envelope header (#3062) chore(utils): Split browser/node compatibility utils into separate module (#3123) ref(tracing): Prework for initial `tracestate` implementation (#3242) feat(tracing): Add `tracestate` header to outgoing requests (#3092) ref(tracing): Rework tracestate internals to allow for third-party data (#3266) feat(tracing): Handle incoming tracestate data, allow for third-party data (#3275) chore(tracing): Various small fixes to first `tracestate` implementation (#3291) fix(tracing): Use `Request.headers.append` correctly (#3311) feat(tracing): Add user data to tracestate header (#3343) chore(various): Small fixes (#3368) fix(build): Prevent Node's `Buffer` module from being included in browser bundles (#3372) fix(tracing): Remove undefined tracestate data rather than setting it to `null` (#3373) More detail in the PR description.
This is the result of rebasing the feature branch for the initial implementation of `tracestate` header handling (which had grown very stale) on top of current `master`. That branch is going to get deleted, so for posterity, it included the following PRs (oldest -> newest): feat(tracing): Add dynamic sampling correlation context data to envelope header (#3062) chore(utils): Split browser/node compatibility utils into separate module (#3123) ref(tracing): Prework for initial `tracestate` implementation (#3242) feat(tracing): Add `tracestate` header to outgoing requests (#3092) ref(tracing): Rework tracestate internals to allow for third-party data (#3266) feat(tracing): Handle incoming tracestate data, allow for third-party data (#3275) chore(tracing): Various small fixes to first `tracestate` implementation (#3291) fix(tracing): Use `Request.headers.append` correctly (#3311) feat(tracing): Add user data to tracestate header (#3343) chore(various): Small fixes (#3368) fix(build): Prevent Node's `Buffer` module from being included in browser bundles (#3372) fix(tracing): Remove undefined tracestate data rather than setting it to `null` (#3373) More detail in the PR description.
This is the result of rebasing the feature branch for the initial implementation of `tracestate` header handling (which had grown very stale) on top of current `master`. That branch is going to get deleted, so for posterity, it included the following PRs (oldest -> newest): feat(tracing): Add dynamic sampling correlation context data to envelope header (#3062) chore(utils): Split browser/node compatibility utils into separate module (#3123) ref(tracing): Prework for initial `tracestate` implementation (#3242) feat(tracing): Add `tracestate` header to outgoing requests (#3092) ref(tracing): Rework tracestate internals to allow for third-party data (#3266) feat(tracing): Handle incoming tracestate data, allow for third-party data (#3275) chore(tracing): Various small fixes to first `tracestate` implementation (#3291) fix(tracing): Use `Request.headers.append` correctly (#3311) feat(tracing): Add user data to tracestate header (#3343) chore(various): Small fixes (#3368) fix(build): Prevent Node's `Buffer` module from being included in browser bundles (#3372) fix(tracing): Remove undefined tracestate data rather than setting it to `null` (#3373) More detail in the PR description.
This builds on previous dynamic sampling/tracestate PRs by (as the title says), consuming incoming
tracestate
headers and allowing for non-sentry data in both those and outgoingtracestate
headers.This should complete the initial implementation of
tracestate
on the JavaScript side.Lingering issues to be dealt with in future:
Because
Buffer
is mentioned inutils/string.ts
, webpack will include the entire contents of node'sBuffer
module in your bundle when you include@sentry/browser
or any of its derivatives in said bundle. (Rollup is smart enough to exclude it from our CDN bundles.) Before we GA this, we need to figure out a way around that. Holding off for now since all of the build tooling is changing in v7, and this likely won't GA until after v7 is released. (As to our dogfooding, @HazAT suggested seeing how much of an impact it actually has there before spending time dealing with it.)This initial proof of concept doesn't include any user data, which the final version will need to.
This also doesn't handle weird edge cases in terms of third-party data in the headers (blank values, for instance), as detailed in the official spec.