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

hasTracingEnabled doesn't handle undefined values correctly #12034

Open
3 tasks done
nwalters512 opened this issue May 14, 2024 · 2 comments
Open
3 tasks done

hasTracingEnabled doesn't handle undefined values correctly #12034

nwalters512 opened this issue May 14, 2024 · 2 comments

Comments

@nwalters512
Copy link

nwalters512 commented May 14, 2024

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

8.0.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup

const config = await dynamicallyLoadConfigSomehow();

Sentry.init({
  tracesSampleRate: config.sentryTracesSampleRate ?? undefined
});

Steps to Reproduce

  • Add logs to import-in-the-middle so that you can tell when it's being imported.
  • Initialize Sentry with tracesSampleRate: undefined.
  • Observe that even though I don't want Sentry to enable any tracing instrumentation, import-in-the-middle is still loaded by Sentry and instrumentation is still added.

Expected Result

I would expect that an undefined value for tracesSampleRate would be interpreted as "don't enable tracing".

Actual Result

The mere existence of a tracesSampleRate value in the Sentry init options, regardless of what the value is, is interpreted as "enable tracing instrumentation":

return !!options && (options.enableTracing || 'tracesSampleRate' in options || 'tracesSampler' in options);

I think that check should probably look more like this:

return !!options && (options.enableTracing || options.tracesSampleRate != undefined || options.tracesSampler != undefined);

I'd be happy to open a PR with this if a maintainer can give the go-ahead!

@mydea
Copy link
Member

mydea commented May 15, 2024

Hey,

the background for this is based on browser-land, where we want to do certain things only if performance is set in any way.
We may revisit this, but for now I will fix this specifically in the node init check for performance integrations, and only load those if this is not undefined!

mydea added a commit that referenced this issue May 16, 2024
ref #12034

cc @AbhiPrasad when you're back, let's look again at
`hasTracingEnabled()` and see if we want to adjust this maybe.
@AbhiPrasad AbhiPrasad added this to the v8 Instrumentation Bugs milestone May 27, 2024
@mydea
Copy link
Member

mydea commented May 28, 2024

Hey,

we have updated this in the SDK, so that even if this is set to undefined, performance instrumentation will not be added by default.

(FWIW, we have not updated the hasTracingEnabled() check yet, because we need to double check to make sure there are no other effects there, but we changed this for the perf instrumentation check itself).

I will leave the issue open still because I think the fundamental problem it poses remains valid!

@mydea mydea removed this from the v8 Instrumentation Issues milestone May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

3 participants