From 94263749539f2724cc553df5c4040a227db31948 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 8 Oct 2024 09:05:08 +0000 Subject: [PATCH] ref(nextjs): Ignore sentry spans based on query params --- packages/nextjs/src/server/index.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/nextjs/src/server/index.ts b/packages/nextjs/src/server/index.ts index e787f978cf22..ca9e3beba61e 100644 --- a/packages/nextjs/src/server/index.ts +++ b/packages/nextjs/src/server/index.ts @@ -14,6 +14,7 @@ import { GLOBAL_OBJ, logger } from '@sentry/utils'; import { ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_ROUTE, + ATTR_URL_QUERY, SEMATTRS_HTTP_METHOD, SEMATTRS_HTTP_TARGET, } from '@opentelemetry/semantic-conventions'; @@ -157,11 +158,14 @@ export function init(options: NodeOptions): NodeClient | undefined { // We need to drop these spans. if ( // eslint-disable-next-line deprecation/deprecation - typeof spanAttributes[SEMATTRS_HTTP_TARGET] === 'string' && - // eslint-disable-next-line deprecation/deprecation - spanAttributes[SEMATTRS_HTTP_TARGET].includes('sentry_key') && - // eslint-disable-next-line deprecation/deprecation - spanAttributes[SEMATTRS_HTTP_TARGET].includes('sentry_client') + (typeof spanAttributes[SEMATTRS_HTTP_TARGET] === 'string' && + // eslint-disable-next-line deprecation/deprecation + spanAttributes[SEMATTRS_HTTP_TARGET].includes('sentry_key') && + // eslint-disable-next-line deprecation/deprecation + spanAttributes[SEMATTRS_HTTP_TARGET].includes('sentry_client')) || + (typeof spanAttributes[ATTR_URL_QUERY] === 'string' && + spanAttributes[ATTR_URL_QUERY].includes('sentry_key') && + spanAttributes[ATTR_URL_QUERY].includes('sentry_client')) ) { samplingDecision.decision = false; }