Skip to content

Commit 1a3f402

Browse files
committed
remove headers logic from wrappers
1 parent 1ec0da1 commit 1a3f402

File tree

6 files changed

+2
-28
lines changed

6 files changed

+2
-28
lines changed

packages/nextjs/src/common/pages-router-instrumentation/wrapApiHandlerWithSentry.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
} from '@sentry/core';
1616
import type { NextApiRequest } from 'next';
1717
import type { AugmentedNextApiResponse, NextApiHandler } from '../types';
18-
import { addHeadersAsAttributes } from '../utils/addHeadersAsAttributes';
1918
import { flushSafelyWithTimeout } from '../utils/responseEnd';
2019
import { dropNextjsRootContext, escapeNextjsTracing } from '../utils/tracingUtils';
2120

@@ -88,7 +87,6 @@ export function wrapApiHandlerWithSentry(apiHandler: NextApiHandler, parameteriz
8887
attributes: {
8988
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',
9089
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.nextjs',
91-
...addHeadersAsAttributes(normalizedRequest.headers || {}),
9290
},
9391
},
9492
async span => {

packages/nextjs/src/common/wrapGenerationFunctionWithSentry.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
import type { GenerationFunctionContext } from '../common/types';
2323
import { isNotFoundNavigationError, isRedirectNavigationError } from './nextNavigationErrorUtils';
2424
import { TRANSACTION_ATTR_SENTRY_TRACE_BACKFILL } from './span-attributes-with-logic-attached';
25-
import { addHeadersAsAttributes } from './utils/addHeadersAsAttributes';
2625
import { commonObjectToIsolationScope, commonObjectToPropagationContext } from './utils/tracingUtils';
2726
import { getSanitizedRequestUrl } from './utils/urls';
2827
import { maybeExtractSynchronousParamsAndSearchParams } from './utils/wrapperUtils';
@@ -64,11 +63,6 @@ export function wrapGenerationFunctionWithSentry<F extends (...args: any[]) => a
6463

6564
const headersDict = headers ? winterCGHeadersToDict(headers) : undefined;
6665

67-
if (activeSpan) {
68-
const rootSpan = getRootSpan(activeSpan);
69-
addHeadersAsAttributes(headers, rootSpan);
70-
}
71-
7266
let data: Record<string, unknown> | undefined = undefined;
7367
if (getClient()?.getOptions().sendDefaultPii) {
7468
const props: unknown = args[0];

packages/nextjs/src/common/wrapMiddlewareWithSentry.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
winterCGRequestToRequestData,
1414
withIsolationScope,
1515
} from '@sentry/core';
16-
import { addHeadersAsAttributes } from '../common/utils/addHeadersAsAttributes';
1716
import { flushSafelyWithTimeout } from '../common/utils/responseEnd';
1817
import type { EdgeRouteHandler } from '../edge/types';
1918

@@ -60,16 +59,14 @@ export function wrapMiddlewareWithSentry<H extends EdgeRouteHandler>(
6059

6160
let spanName: string;
6261
let spanSource: TransactionSource;
63-
let headerAttributes: Record<string, string> = {};
62+
const headerAttributes: Record<string, string> = {};
6463

6564
if (req instanceof Request) {
6665
isolationScope.setSDKProcessingMetadata({
6766
normalizedRequest: winterCGRequestToRequestData(req),
6867
});
6968
spanName = `middleware ${req.method} ${new URL(req.url).pathname}`;
7069
spanSource = 'url';
71-
72-
headerAttributes = addHeadersAsAttributes(req.headers);
7370
} else {
7471
spanName = 'middleware';
7572
spanSource = 'component';

packages/nextjs/src/common/wrapRouteHandlerWithSentry.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
} from '@sentry/core';
2020
import { isNotFoundNavigationError, isRedirectNavigationError } from './nextNavigationErrorUtils';
2121
import type { RouteHandlerContext } from './types';
22-
import { addHeadersAsAttributes } from './utils/addHeadersAsAttributes';
2322
import { flushSafelyWithTimeout } from './utils/responseEnd';
2423
import { commonObjectToIsolationScope } from './utils/tracingUtils';
2524

@@ -40,10 +39,6 @@ export function wrapRouteHandlerWithSentry<F extends (...args: any[]) => any>(
4039
const activeSpan = getActiveSpan();
4140
const rootSpan = activeSpan ? getRootSpan(activeSpan) : undefined;
4241

43-
if (rootSpan && process.env.NEXT_RUNTIME !== 'edge') {
44-
addHeadersAsAttributes(headers, rootSpan);
45-
}
46-
4742
let edgeRuntimeIsolationScopeOverride: Scope | undefined;
4843
if (rootSpan && process.env.NEXT_RUNTIME === 'edge') {
4944
const isolationScope = commonObjectToIsolationScope(headers);
@@ -55,7 +50,6 @@ export function wrapRouteHandlerWithSentry<F extends (...args: any[]) => any>(
5550
rootSpan.updateName(`${method} ${parameterizedRoute}`);
5651
rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');
5752
rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'http.server');
58-
addHeadersAsAttributes(headers, rootSpan);
5953
}
6054

6155
return withIsolationScope(

packages/nextjs/src/common/wrapServerComponentWithSentry.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import { isNotFoundNavigationError, isRedirectNavigationError } from '../common/
2424
import type { ServerComponentContext } from '../common/types';
2525
import { flushSafelyWithTimeout } from '../common/utils/responseEnd';
2626
import { TRANSACTION_ATTR_SENTRY_TRACE_BACKFILL } from './span-attributes-with-logic-attached';
27-
import { addHeadersAsAttributes } from './utils/addHeadersAsAttributes';
2827
import { commonObjectToIsolationScope, commonObjectToPropagationContext } from './utils/tracingUtils';
2928
import { getSanitizedRequestUrl } from './utils/urls';
3029
import { maybeExtractSynchronousParamsAndSearchParams } from './utils/wrapperUtils';
@@ -62,11 +61,6 @@ export function wrapServerComponentWithSentry<F extends (...args: any[]) => any>
6261

6362
const headersDict = context.headers ? winterCGHeadersToDict(context.headers) : undefined;
6463

65-
if (activeSpan) {
66-
const rootSpan = getRootSpan(activeSpan);
67-
addHeadersAsAttributes(context.headers, rootSpan);
68-
}
69-
7064
let params: Record<string, string> | undefined = undefined;
7165

7266
if (getClient()?.getOptions().sendDefaultPii) {

packages/nextjs/src/edge/wrapApiHandlerWithSentry.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
winterCGRequestToRequestData,
1414
withIsolationScope,
1515
} from '@sentry/core';
16-
import { addHeadersAsAttributes } from '../common/utils/addHeadersAsAttributes';
1716
import { flushSafelyWithTimeout } from '../common/utils/responseEnd';
1817
import type { EdgeRouteHandler } from './types';
1918

@@ -32,15 +31,13 @@ export function wrapApiHandlerWithSentry<H extends EdgeRouteHandler>(
3231
const req: unknown = args[0];
3332
const currentScope = getCurrentScope();
3433

35-
let headerAttributes: Record<string, string> = {};
34+
const headerAttributes: Record<string, string> = {};
3635

3736
if (req instanceof Request) {
3837
isolationScope.setSDKProcessingMetadata({
3938
normalizedRequest: winterCGRequestToRequestData(req),
4039
});
4140
currentScope.setTransactionName(`${req.method} ${parameterizedRoute}`);
42-
43-
headerAttributes = addHeadersAsAttributes(req.headers);
4441
} else {
4542
currentScope.setTransactionName(`handler (${parameterizedRoute})`);
4643
}

0 commit comments

Comments
 (0)