Skip to content

Commit

Permalink
fix(core): Avoid looking up client for hasTracingEnabled() if possi…
Browse files Browse the repository at this point in the history
…ble (#12066)

This is a bit weird in that we access the current scope & client etc.,
even if options are passed. Since we also use this method in `init()`
before we have setup stuff, it seems safer to avoid calling this at all
if possible.

This is related to
#12054, but not
really the cause of it.
  • Loading branch information
mydea committed May 16, 2024
1 parent 677602f commit 07c6838
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core/src/utils/hasTracingEnabled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ export function hasTracingEnabled(
return false;
}

const client = getClient();
const options = maybeOptions || (client && client.getOptions());
const options = maybeOptions || getClientOptions();
return !!options && (options.enableTracing || 'tracesSampleRate' in options || 'tracesSampler' in options);
}

function getClientOptions(): Options | undefined {
const client = getClient();
return client && client.getOptions();
}

0 comments on commit 07c6838

Please sign in to comment.