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(node): Add tracePropagationTargets option #5521

Merged
merged 6 commits into from Aug 4, 2022

Conversation

lforst
Copy link
Member

@lforst lforst commented Aug 4, 2022

This PR adds the tracePropagationTargets option as outlined in #5403, getsentry/develop#636, and DACI (internal) to the node SDK init options.

The tracePropagationTargets option can be used to control to which request the SDK should attach trace data (at the time of writing via sentry-trace and baggage headers).

Its behavior (at least for node) is as follows: If not provided, the SDK will attach tracing data to all outgoing requests. If provided, the SDK will only attach trace data when the request's URL matches one of the items in the tracePropagationTargets array.

Resolves #5403


Notes:

  • Since the option has a different meaning in the node SDK vs the browser SDK, I suggest we have the option types separated so we can have different JSDoc for each of them.

@lforst lforst added this to the Dynamic Sampling milestone Aug 4, 2022
@lforst lforst self-assigned this Aug 4, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.36 KB (0%)
@sentry/browser - ES5 CDN Bundle (minified) 59.96 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 17.94 KB (-0.02% 🔽)
@sentry/browser - ES6 CDN Bundle (minified) 52.83 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 19.7 KB (0%)
@sentry/browser - Webpack (minified) 64.17 KB (0%)
@sentry/react - Webpack (gzipped + minified) 19.72 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 44.14 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 25.77 KB (-0.01% 🔽)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.02 KB (-0.01% 🔽)

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.

This looks great. And I agree, having a browser/node-specific JSDoc justifies defining the option twice.

Just had some minor questions and remarks but nothing blocking.

Also, thanks for taking the time and adding all these tests despite this change being tough to test properly!

packages/node/src/integrations/http.ts Outdated Show resolved Hide resolved
@@ -90,7 +103,26 @@ type WrappedRequestMethodFactory = (original: OriginalRequestMethod) => WrappedR
function _createWrappedRequestMethodFactory(
breadcrumbsEnabled: boolean,
tracingEnabled: boolean,
tracePropagationTargets: (string | RegExp)[] | undefined,
Copy link
Member

Choose a reason for hiding this comment

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

optional/question: Does it make sense to extract (string | RegExp)[] | undefined to a type?

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 that makes a lot of sense! Can you check whether the location where I extracted it makes sense?: 0aa153f

Also I extracted it without | undefined because that works better with the optional operator in the init options.

Copy link
Member

Choose a reason for hiding this comment

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

I think it sort of makes sense but I can see why this might look a little off. Seems like we don't really have a tracing-related file in the types package. Adding it to the transaction, span or baggage files also doesn't make more sense...

So wdyt about adding a new tracing.ts file? Or we add it to the misc.ts file ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Created a tracing.ts file. Thanks for the input!

packages/node/src/integrations/http.ts Show resolved Hide resolved
packages/node/src/types.ts Outdated Show resolved Hide resolved
lforst and others added 3 commits August 4, 2022 13:06
Co-authored-by: Lukas Stracke <lukas@stracke.co.at>
Co-authored-by: Lukas Stracke <lukas@stracke.co.at>
@lforst lforst enabled auto-merge (squash) August 4, 2022 13:15
@lforst lforst merged commit f240077 into master Aug 4, 2022
@lforst lforst deleted the lforst-trace-propagation-targets-node branch August 4, 2022 13:25
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.

Add tracePropagationTargets to Node
2 participants