Skip to content

ref: Rename baggage env header to trace #5128

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 6 commits into from
May 23, 2022
Merged

ref: Rename baggage env header to trace #5128

merged 6 commits into from
May 23, 2022

Conversation

AbhiPrasad
Copy link
Member

@AbhiPrasad AbhiPrasad commented May 18, 2022

Matches how this information will be captured and processed in Relay.

See #5104 for init work.

Resolves https://getsentry.atlassian.net/browse/WEB-926

@AbhiPrasad AbhiPrasad requested review from jan-auer and Lms24 May 18, 2022 15:42
@github-actions
Copy link
Contributor

github-actions bot commented May 18, 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.38 KB (-9.74% 🔽)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 24.98 KB (-4.19% 🔽)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 23.54 KB (-3.85% 🔽)

expect(envHeader.baggage).toBeDefined();
expect(envHeader.baggage).toEqual(
expect(envHeader.trace).toBeDefined();
expect(envHeader.trace).toEqual(
Copy link
Member

Choose a reason for hiding this comment

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

The envelope header is independent of baggage or tracestate encoding. It is directly a JSON object with all the keys relevant to Sentry. See: https://develop.sentry.dev/sdk/performance/trace-context/#envelope-headers

Instead of serializing baggage, please filter for sentry-* keys and directly add them as object to the header.

@jan-auer
Copy link
Member

@AbhiPrasad after applying the above suggestion and before merging, I'd like to take this example payload and also check it into Relay's unit test suite for verification, just to make sure we're not missing anything.

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

We need to adjust unit tests for the baggage env header entry creation, too: https://github.com/getsentry/sentry-javascript/blob/250ec10d2577bc98bf2688627873e7e1077e781a/packages/core/test/lib/envelope.test.ts

After reading the Slack thread about the changes, I think we want to send the BaggageObj (i.e. our entries) instead of the serialized baggage string, right? Do we want to make the change in this PR or a follow-up one?

@AbhiPrasad
Copy link
Member Author

We can make these changes in this PR! I'll amend the PR title, description, and JIRA ticket.

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

LGTM. Left a question about types but nothing that should be blocking this.

@@ -56,7 +56,7 @@ export type SessionItem =
| BaseEnvelopeItem<SessionAggregatesItemHeaders, SessionAggregates>;
export type ClientReportItem = BaseEnvelopeItem<ClientReportItemHeaders, ClientReport>;

export type EventEnvelopeHeaders = { event_id: string; sent_at: string; baggage?: string };
export type EventEnvelopeHeaders = { event_id: string; sent_at: string; trace?: Record<string, unknown> };
Copy link
Member

@Lms24 Lms24 May 19, 2022

Choose a reason for hiding this comment

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

I first thought, "why not use the BaggageObj type here" but then I realized that we can't because we declared the baggage types in @sentry/utils. For my PR I decided to move them (i.e. Baggage and BaggageObj) to @sentry/types and export them from there because I needed them in the types package. WDYT is this a good idea? If yes, we can either move them already in this PR or make the change afterwards. If not, I'll have to make some adjustments in my PR 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we can move the types, good idea.

Comment on lines +44 to +47
release: '1.0.0',
environment: 'prod',
user: { id: 'bob', segment: 'segmentA' },
transaction: 'TX',
Copy link
Member

Choose a reason for hiding this comment

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

Thanks, this schema looks correct now based on the reference struct. However, we currently also expect the trace_id and the public_key of the DSN where the trace originated. Is this just missing in this test?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's missing in the test, can add!

Matches how this information will be captured and processed in Relay.
@AbhiPrasad AbhiPrasad force-pushed the v7-abhi-baggage-to-trace branch from 739eb07 to 5b88771 Compare May 19, 2022 20:07
Copy link
Member

@jan-auer jan-auer left a comment

Choose a reason for hiding this comment

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

Compatible with Relay and G2G.

Once the test contains public_key and trace_id, I'll create a PR in Relay to add the same payload to its tests and link it back here.

@Lms24 Lms24 merged commit 9759e27 into 7.x May 23, 2022
@Lms24 Lms24 deleted the v7-abhi-baggage-to-trace branch May 23, 2022 10:15
AbhiPrasad added a commit that referenced this pull request May 30, 2022
This patch renames the tracing data envelope header from `baggage` to `trace`. Additionally, it now includes the `trace_id` and `public_key` fields as required by Relay

Co-authored-by: Abhijeet Prasad <[email protected]>
Co-authored-by: Lukas Stracke <[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