Skip to content
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): Add PropagationContext to scope #8421

Merged
merged 10 commits into from
Jun 29, 2023

Conversation

AbhiPrasad
Copy link
Member

@AbhiPrasad AbhiPrasad commented Jun 28, 2023

ref #8352

For more details about PropagationContext, see https://www.notion.so/sentry/Tracing-without-performance-efab307eb7f64e71a04f09dc72722530

Building off of work in both #8403 and #8418, this PR adds PropagationContext and uses that to always set a trace context on outgoing error events.

Currently if there is an active span on the scope, we automatically attach that span's trace context to all outgoing events. Now, we want to rely on either the active span or fallback to the propagation context to ensure that there is always a trace being generated and propagated.

Next up we'll work on updating the node/browser SDKs to update the propagation context. For example, we should update the propagation context for node based on the incoming sentry-trace/baggage headers.

@AbhiPrasad AbhiPrasad requested a review from a team June 28, 2023 18:23
@AbhiPrasad AbhiPrasad self-assigned this Jun 28, 2023
@AbhiPrasad AbhiPrasad requested review from Lms24, ale-cota, mydea and lforst and removed request for a team and ale-cota June 28, 2023 18:23
@AbhiPrasad
Copy link
Member Author

I know this needs more tests, I'm planning to add some integration tests after some more twp tasks are merged in.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 28, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 21.76 KB (+1.26% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 68.42 KB (+1.22% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 20.07 KB (+1.27% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 59.69 KB (+1.34% 🔺)
@sentry/browser - Webpack (gzipped + minified) 21.69 KB (+1.2% 🔺)
@sentry/browser - Webpack (minified) 70.83 KB (+1.38% 🔺)
@sentry/react - Webpack (gzipped + minified) 21.72 KB (+1.21% 🔺)
@sentry/nextjs Client - Webpack (gzipped + minified) 50.09 KB (+0.58% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 29.63 KB (+0.82% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 27.71 KB (+0.82% 🔺)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 49.43 KB (+0.2% 🔺)
@sentry/replay - Webpack (gzipped + minified) 43.12 KB (+0.04% 🔺)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 69.06 KB (+0.35% 🔺)
@sentry/browser + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 61.64 KB (+0.43% 🔺)

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! Good point about tests and I agree that it's better to wait until all important parts are implemented and then add integration tests.

@@ -365,6 +375,9 @@ export class Scope implements ScopeInterface {
if (captureContext.requestSession) {
this._requestSession = captureContext.requestSession;
}
if (captureContext.propagationContext) {
this._propagationContext = captureContext.propagationContext;
}
Copy link
Member

Choose a reason for hiding this comment

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

Hmm seems like we have quite some duplicated logic here when distinguishing between captureContext being a class instance or a plain object. No action required in this PR but we should probable deduplicate this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah something we can keep in mind, I'll leave a note.

@@ -492,6 +492,28 @@ describe('BaseClient', () => {
);
});

test('it adds a trace context all events', () => {
Copy link
Member

Choose a reason for hiding this comment

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

super-l:

Suggested change
test('it adds a trace context all events', () => {
test('it adds a trace context to all events', () => {

Copy link
Member Author

Choose a reason for hiding this comment

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

Will update in the next PR!

@AbhiPrasad AbhiPrasad merged commit f1ede57 into develop Jun 29, 2023
67 checks passed
@AbhiPrasad AbhiPrasad deleted the abhi-prop-context-twp branch June 29, 2023 15:08
AbhiPrasad added a commit that referenced this pull request Jun 29, 2023
Requires #8421 to be
merged

ref #8352

This PR adds support for
https://github.com/getsentry/rfcs/blob/main/text/0071-continue-trace-over-process-boundaries.md
via propagation context. When the Node SDK initializes, it grabs
`process.env.SENTRY_TRACE` and `process.env.SENTRY_BAGGAGE` and uses
them to populate the existing propagation context.

In future PRs (tracked by #8352), we will be adding support for
transactions/outgoing requests to use propagation context, but for now
we are only storing in propagation context, not doing anything with it.
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.

None yet

2 participants