File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 99 withScope ,
1010} from '@sentry/node' ;
1111import * as Sentry from '@sentry/node' ;
12- import { extractTraceparentData } from '@sentry/tracing' ;
12+ import { extractSentrytraceData , extractTracestateData } from '@sentry/tracing' ;
1313import { Integration } from '@sentry/types' ;
1414import { isString , logger } from '@sentry/utils' ;
1515// NOTE: I have no idea how to fix this right now, and don't want to waste more time, as it builds just fine — Kamil
@@ -245,14 +245,20 @@ export function wrapHandler<TEvent, TResult>(
245245
246246 // Applying `sentry-trace` to context
247247 let traceparentData ;
248+ let tracestateData ;
248249 const eventWithHeaders = event as { headers ?: { [ key : string ] : string } } ;
249250 if ( eventWithHeaders . headers && isString ( eventWithHeaders . headers [ 'sentry-trace' ] ) ) {
250- traceparentData = extractTraceparentData ( eventWithHeaders . headers [ 'sentry-trace' ] as string ) ;
251+ traceparentData = extractSentrytraceData ( eventWithHeaders . headers [ 'sentry-trace' ] as string ) ;
251252 }
253+ if ( eventWithHeaders . headers ?. tracestate ) {
254+ tracestateData = extractTracestateData ( eventWithHeaders . headers . tracestate as string ) ;
255+ }
256+
252257 const transaction = startTransaction ( {
253258 name : context . functionName ,
254259 op : 'awslambda.handler' ,
255260 ...traceparentData ,
261+ metadata : { tracestate : tracestateData } ,
256262 } ) ;
257263
258264 const hub = getCurrentHub ( ) ;
Original file line number Diff line number Diff line change @@ -231,7 +231,10 @@ describe('AWSLambda', () => {
231231 const wrappedHandler = wrapHandler ( handler ) ;
232232
233233 try {
234- fakeEvent . headers = { 'sentry-trace' : '12312012123120121231201212312012-1121201211212012-0' } ;
234+ fakeEvent . headers = {
235+ 'sentry-trace' : '12312012123120121231201212312012-1121201211212012-0' ,
236+ tracestate : 'sentry=doGsaREgReaT,maisey=silly,charlie=goofy' ,
237+ } ;
235238 await wrappedHandler ( fakeEvent , fakeContext , fakeCallback ) ;
236239 } catch ( e ) {
237240 expect ( Sentry . startTransaction ) . toBeCalledWith ( {
@@ -240,6 +243,12 @@ describe('AWSLambda', () => {
240243 traceId : '12312012123120121231201212312012' ,
241244 parentSpanId : '1121201211212012' ,
242245 parentSampled : false ,
246+ metadata : {
247+ tracestate : {
248+ sentry : 'sentry=doGsaREgReaT' ,
249+ thirdparty : 'maisey=silly,charlie=goofy' ,
250+ } ,
251+ } ,
243252 } ) ;
244253 expectScopeSettings ( ) ;
245254 expect ( Sentry . captureException ) . toBeCalledWith ( e ) ;
You can’t perform that action at this time.
0 commit comments