Skip to content

Commit 3f7e132

Browse files
committed
fixes
1 parent af57386 commit 3f7e132

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

packages/node-core/src/integrations/http/SentryHttpInstrumentation.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,6 @@ export type SentryHttpInstrumentationOptions = InstrumentationConfig & {
8181
*/
8282
ignoreIncomingRequestBody?: (url: string, request: http.RequestOptions) => boolean;
8383

84-
/**
85-
* A hook that can be used to mutate the span for incoming requests.
86-
* This is triggered after the span is created, but before it is recorded.
87-
*/
88-
incomingRequestSpanHook?: (span: Span, request: http.IncomingMessage, response: http.ServerResponse) => void;
89-
9084
/**
9185
* @deprecated This no longer does anything.
9286
*/

packages/node-core/src/integrations/http/httpServerIntegration.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ function instrumentServer(
149149
const originalEmit: ServerEmit = server.emit;
150150

151151
if (wrappedEmitFns.has(originalEmit)) {
152-
DEBUG_BUILD &&
153-
debug.log(INSTRUMENTATION_NAME, 'Incoming requests already instrumented, not instrumenting again...');
154152
return;
155153
}
156154

@@ -223,7 +221,7 @@ function instrumentServer(
223221
return wrapInCallbacks(
224222
() => target.apply(thisArg, args),
225223
{ request, response, normalizedRequest },
226-
callbacks,
224+
callbacks.slice(),
227225
);
228226
} else {
229227
return target.apply(thisArg, args);

packages/node-core/src/integrations/http/httpServerSpansIntegration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ const _httpServerSpansIntegration = ((options: HttpServerSpansIntegrationOptions
166166
},
167167
});
168168

169-
// TODO v11: Remove the following three hooks, only incomingRequestSpanHook should remain
169+
// TODO v11: Remove the following three hooks, only onSpanCreated should remain
170170
requestHook?.(span, request);
171171
responseHook?.(span, response);
172172
applyCustomAttributesOnSpan?.(span, request, response);

packages/node/src/integrations/http.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ interface HttpOptions {
7676
*/
7777
ignoreIncomingRequests?: (urlPath: string, request: IncomingMessage) => boolean;
7878

79+
/**
80+
* A hook that can be used to mutate the span for incoming requests.
81+
* This is triggered after the span is created, but before it is recorded.
82+
*/
83+
incomingRequestSpanHook?: (span: Span, request: IncomingMessage, response: ServerResponse) => void;
84+
7985
/**
8086
* Whether to automatically ignore common static asset requests like favicon.ico, robots.txt, etc.
8187
* This helps reduce noise in your transactions.
@@ -210,6 +216,7 @@ export const httpIntegration = defineIntegration((options: HttpOptions = {}) =>
210216
ignoreStaticAssets: options.ignoreStaticAssets,
211217
ignoreStatusCodes: options.dropSpansForIncomingRequestStatusCodes,
212218
instrumentation: options.instrumentation,
219+
onSpanCreated: options.incomingRequestSpanHook,
213220
} satisfies Parameters<typeof httpServerSpansIntegration>[0];
214221

215222
const server = httpServerIntegration(serverOptions);

0 commit comments

Comments
 (0)