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 9
9
withScope ,
10
10
} from '@sentry/node' ;
11
11
import * as Sentry from '@sentry/node' ;
12
- import { extractTraceparentData } from '@sentry/tracing' ;
12
+ import { extractSentrytraceData , extractTracestateData } from '@sentry/tracing' ;
13
13
import { Integration } from '@sentry/types' ;
14
14
import { isString , logger } from '@sentry/utils' ;
15
15
// 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>(
245
245
246
246
// Applying `sentry-trace` to context
247
247
let traceparentData ;
248
+ let tracestateData ;
248
249
const eventWithHeaders = event as { headers ?: { [ key : string ] : string } } ;
249
250
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 ) ;
251
252
}
253
+ if ( eventWithHeaders . headers ?. tracestate ) {
254
+ tracestateData = extractTracestateData ( eventWithHeaders . headers . tracestate as string ) ;
255
+ }
256
+
252
257
const transaction = startTransaction ( {
253
258
name : context . functionName ,
254
259
op : 'awslambda.handler' ,
255
260
...traceparentData ,
261
+ metadata : { tracestate : tracestateData } ,
256
262
} ) ;
257
263
258
264
const hub = getCurrentHub ( ) ;
Original file line number Diff line number Diff line change @@ -231,7 +231,10 @@ describe('AWSLambda', () => {
231
231
const wrappedHandler = wrapHandler ( handler ) ;
232
232
233
233
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
+ } ;
235
238
await wrappedHandler ( fakeEvent , fakeContext , fakeCallback ) ;
236
239
} catch ( e ) {
237
240
expect ( Sentry . startTransaction ) . toBeCalledWith ( {
@@ -240,6 +243,12 @@ describe('AWSLambda', () => {
240
243
traceId : '12312012123120121231201212312012' ,
241
244
parentSpanId : '1121201211212012' ,
242
245
parentSampled : false ,
246
+ metadata : {
247
+ tracestate : {
248
+ sentry : 'sentry=doGsaREgReaT' ,
249
+ thirdparty : 'maisey=silly,charlie=goofy' ,
250
+ } ,
251
+ } ,
243
252
} ) ;
244
253
expectScopeSettings ( ) ;
245
254
expect ( Sentry . captureException ) . toBeCalledWith ( e ) ;
You can’t perform that action at this time.
0 commit comments