Skip to content

fix(tracing): Remove undefined tracestate data rather than setting it to null #3373

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

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Apr 7, 2021

The only two values guaranteed to be included in a transaction's tracestate are trace_id and public_key. The rest - release, environment, user.id, and user.segment - may or may not have values. Previously, any of these lacking a value were being set to null in the tracestate object. This changes it so the keys are removed instead.

The only snag I could foresee here is that if no user data is available, I've chosen to not send a user key at all, rather than sending user: { }. That means that on the relay end, asking for user.id will have to first include a check for user. If this is a problem, I can switch to sending an empty object.

NB: Currently this is a PR against another PR's branch, just so that only this PR's changes show up. Once that PR is merged, I'll rebase onto the main feature branch.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 7, 2021

size-limit report

Path Size
@sentry/browser - CDN Bundle (gzipped) 20.8 KB (-0.01% 🔽)
@sentry/browser - Webpack 21.63 KB (0%)
@sentry/react - Webpack 21.67 KB (0%)
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 28.75 KB (-0.05% 🔽)

@kamilogorek
Copy link
Contributor

That means that on the relay end, asking for user.id will have to first include a check for user. If this is a problem, I can switch to sending an empty object.

Relay should perform all the validations anyway, so it should be fine imo.

@@ -227,7 +225,7 @@ describe('tracestate', () => {
});

it("won't include data set after first call to `getTraceHeaders`", () => {
expect.assertions(2);
expect.assertions(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

There are no need to explicitly state number of assertions in sync tests, but it's fine to leave it. Personal preference.

Copy link
Member Author

@lobsterkatie lobsterkatie Apr 12, 2021

Choose a reason for hiding this comment

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

^^^ Not from this PR (I hadn't rebased yet) but I did the expect.assertions() because the expects are in a callback. Less of an issue in this test than some of the others, because the callback is explicitly called and included in the test itself, unlike, for instance, this one:

        it('uses existing sentry tracestate in envelope headers rather than creating a new one', () => {
          // one here, and two inside the `captureEvent` implementation above
          expect.assertions(3);

@lobsterkatie lobsterkatie force-pushed the kmclb-stop-bundling-buffer-module branch 2 times, most recently from 00cfee2 to 9228f1e Compare April 8, 2021 19:07
Copy link

@RaduW RaduW left a comment

Choose a reason for hiding this comment

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

Exactly what we need.

Base automatically changed from kmclb-stop-bundling-buffer-module to kmclb-dynamic-sampling-data-in-envelopes April 12, 2021 18:56
@lobsterkatie lobsterkatie force-pushed the kmclb-stop-sending-nulls-when-data-unavailable branch from 2a1806e to 44a6857 Compare April 12, 2021 19:23
@lobsterkatie lobsterkatie merged commit 03d37ba into kmclb-dynamic-sampling-data-in-envelopes Apr 12, 2021
@lobsterkatie lobsterkatie deleted the kmclb-stop-sending-nulls-when-data-unavailable branch April 12, 2021 19:58
lobsterkatie added a commit that referenced this pull request Apr 12, 2021
lobsterkatie added a commit that referenced this pull request Aug 24, 2021
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.
lobsterkatie added a commit that referenced this pull request Aug 30, 2021
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.
lobsterkatie added a commit that referenced this pull request Aug 31, 2021
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.
lobsterkatie added a commit that referenced this pull request Sep 15, 2021
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.
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