diff --git a/apps/web/.env.test b/apps/web/.env.test index 9a0355845..291b0d6ac 100644 --- a/apps/web/.env.test +++ b/apps/web/.env.test @@ -53,4 +53,8 @@ NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY= NEXT_PUBLIC_ENABLE_ACCOUNT_DELETION=true NEXT_PUBLIC_ENABLE_PERSONAL_ACCOUNT_BILLING=true NEXT_PUBLIC_ENABLE_ORGANIZATION_DELETION=true -NEXT_PUBLIC_ENABLE_ORGANIZATION_BILLING=true \ No newline at end of file +NEXT_PUBLIC_ENABLE_ORGANIZATION_BILLING=true + +# MONITORING +MONITORING_PROVIDER= +MONITORING_INSTRUMENTATION_ENABLED=false \ No newline at end of file diff --git a/apps/web/instrumentation.ts b/apps/web/instrumentation.ts index 954d16634..f15910dc6 100644 --- a/apps/web/instrumentation.ts +++ b/apps/web/instrumentation.ts @@ -3,14 +3,12 @@ * for your Next.js application. */ -const RUNTIME = process.env.NEXT_RUNTIME; - -const ENABLE_INSTRUMENTATION = - process.env.MONITORING_INSTRUMENTATION_ENABLED === 'true'; - export async function register() { // only run in nodejs runtime - if (RUNTIME === 'nodejs' && ENABLE_INSTRUMENTATION) { + if ( + process.env.NEXT_RUNTIME === 'nodejs' && + process.env.MONITORING_INSTRUMENTATION_ENABLED + ) { const { registerMonitoringInstrumentation } = await import( '@kit/monitoring/instrumentation' ); diff --git a/packages/monitoring/sentry/src/instrumentation.ts b/packages/monitoring/sentry/src/instrumentation.ts index 141a1ecf2..3a15c301c 100644 --- a/packages/monitoring/sentry/src/instrumentation.ts +++ b/packages/monitoring/sentry/src/instrumentation.ts @@ -28,7 +28,7 @@ export async function registerInstrumentation() { resource: new Resource({ [SEMRESATTRS_SERVICE_NAME]: serviceName, }), - spanProcessor: new SentrySpanProcessor(), + spanProcessors: [new SentrySpanProcessor()], textMapPropagator: new SentryPropagator(), }); diff --git a/packages/monitoring/src/instrumentation.ts b/packages/monitoring/src/instrumentation.ts index 3cfe70c3b..355058a75 100644 --- a/packages/monitoring/src/instrumentation.ts +++ b/packages/monitoring/src/instrumentation.ts @@ -1,13 +1,5 @@ import { InstrumentationProvider } from './monitoring-providers.enum'; -/** - * @name MONITORING_PROVIDER - * @description Register monitoring instrumentation based on the MONITORING_PROVIDER environment variable. - */ -const MONITORING_PROVIDER = process.env.MONITORING_PROVIDER as - | InstrumentationProvider - | undefined; - /** * @name registerMonitoringInstrumentation * @description Register monitoring instrumentation based on the MONITORING_PROVIDER environment variable. @@ -15,13 +7,13 @@ const MONITORING_PROVIDER = process.env.MONITORING_PROVIDER as * Please set the MONITORING_PROVIDER environment variable to register the monitoring instrumentation provider. */ export async function registerMonitoringInstrumentation() { - if (!MONITORING_PROVIDER) { + if (!process.env.MONITORING_PROVIDER) { console.info(`No instrumentation provider specified. Skipping...`); return; } - switch (MONITORING_PROVIDER) { + switch (process.env.MONITORING_PROVIDER as InstrumentationProvider) { case InstrumentationProvider.Baselime: { const { registerInstrumentation } = await import( '@kit/baselime/instrumentation' @@ -40,7 +32,7 @@ export async function registerMonitoringInstrumentation() { default: throw new Error( - `Unknown instrumentation provider: ${MONITORING_PROVIDER as string}`, + `Unknown instrumentation provider: ${process.env.MONITORING_PROVIDER}`, ); } }