Skip to content

hasTracingEnabled doesn't handle undefined values correctly #12034

Closed
@nwalters512

Description

@nwalters512

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nodeIssues related to the Sentry Node SDK

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions