Skip to content
Merged
Changes from all 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
7 changes: 5 additions & 2 deletions packages/node/src/integrations/tracing/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { ExpressRequestInfo } from '@opentelemetry/instrumentation-express'
import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
import type { IntegrationFn } from '@sentry/core';
import {
httpRequestToRequestData,
SEMANTIC_ATTRIBUTE_SENTRY_OP,
captureException,
defineIntegration,
Expand Down Expand Up @@ -135,9 +136,10 @@ export function expressErrorHandler(options?: ExpressHandlerOptions): ExpressErr
res: http.ServerResponse,
next: (error: MiddlewareError) => void,
): void {
const normalizedRequest = httpRequestToRequestData(request);
// Ensure we use the express-enhanced request here, instead of the plain HTTP one
// When an error happens, the `expressRequestHandler` middleware does not run, so we set it here too
getIsolationScope().setSDKProcessingMetadata({ request });
getIsolationScope().setSDKProcessingMetadata({ normalizedRequest });

const shouldHandleError = options?.shouldHandleError || defaultShouldHandleError;

Expand All @@ -156,8 +158,9 @@ function expressRequestHandler(): ExpressMiddleware {
_res: http.ServerResponse,
next: () => void,
): void {
const normalizedRequest = httpRequestToRequestData(request);
// Ensure we use the express-enhanced request here, instead of the plain HTTP one
getIsolationScope().setSDKProcessingMetadata({ request });
getIsolationScope().setSDKProcessingMetadata({ normalizedRequest });

next();
};
Expand Down
Loading