Skip to content

feat: Add support for SENTRY_SPOTLIGHT env var in Node #13325

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

Merged
merged 10 commits into from
Aug 13, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/node/src/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ export function validateOpenTelemetrySetup(): void {
}
}

const FALSY_ENV_VALUES = new Set(['0', 'false', 'no']);
const TRUTHY_ENV_VALUES = new Set(['1', 'true', 'yes']);

function getClientOptions(
options: NodeOptions,
getDefaultIntegrationsImpl: (options: Options) => Integration[],
Expand All @@ -221,6 +224,17 @@ function getClientOptions(
? true
: options.autoSessionTracking;

if (options.spotlight == null && process.env.SENTRY_SPOTLIGHT) {
const spotlightEnv = process.env.SENTRY_SPOTLIGHT.toLowerCase();
if (FALSY_ENV_VALUES.has(spotlightEnv)) {
options.spotlight = false;
} else if (TRUTHY_ENV_VALUES.has(spotlightEnv)) {
options.spotlight = true;
} else {
options.spotlight = spotlightEnv;
}
}

const tracesSampleRate = getTracesSampleRate(options.tracesSampleRate);

const baseOptions = dropUndefinedKeys({
Expand Down
Loading