@@ -5,7 +5,7 @@ import { VERSION } from '@opentelemetry/core';
55import type { InstrumentationConfig } from '@opentelemetry/instrumentation' ;
66import { InstrumentationBase , InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation' ;
77import { getRequestInfo } from '@opentelemetry/instrumentation-http' ;
8- import { addBreadcrumb , getClient , getIsolationScope , withIsolationScope } from '@sentry/core' ;
8+ import { addBreadcrumb , dropUndefinedKeys , getClient , getIsolationScope , withIsolationScope } from '@sentry/core' ;
99import {
1010 extractQueryParamsFromUrl ,
1111 getBreadcrumbLogLevelFromHttpStatusCode ,
@@ -439,16 +439,21 @@ export function httpRequestToRequestEventData(request: IncomingMessage): Request
439439 const originalUrl = request . url || '' ;
440440 const absoluteUrl = originalUrl . startsWith ( protocol ) ? originalUrl : `${ protocol } ://${ host } ${ originalUrl } ` ;
441441
442+ // This is non-standard, but may be sometimes set
443+ // It may be overwritten later by our own body handling
444+ const data = ( request as PolymorphicRequest ) . body ;
445+
442446 // This is non-standard, but may be set on e.g. Next.js or Express requests
443447 const cookies = ( request as PolymorphicRequest ) . cookies ;
444448
445- const normalizedRequest : RequestEventData = {
449+ const normalizedRequest : RequestEventData = dropUndefinedKeys ( {
446450 url : absoluteUrl ,
447451 method : request . method ,
448452 query_string : extractQueryParamsFromUrl ( originalUrl ) ,
449453 headers : headersToDict ( headers ) ,
450454 cookies,
451- } ;
455+ data,
456+ } ) ;
452457
453458 return normalizedRequest ;
454459}
0 commit comments