File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
packages/middleware-recursion-detection/src Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 1+ import { InvokeStore } from "@aws/lambda-invoke-store" ;
12import { HttpRequest } from "@smithy/protocol-http" ;
23import {
34 BuildHandler ,
@@ -31,7 +32,11 @@ export const recursionDetectionMiddleware =
3132 return next ( args ) ;
3233 }
3334 const functionName = process . env [ ENV_LAMBDA_FUNCTION_NAME ] ;
34- const traceId = process . env [ ENV_TRACE_ID ] ;
35+
36+ const traceIdFromEnv = process . env [ ENV_TRACE_ID ] ;
37+ const traceIdFromInvokeStore = InvokeStore . getXRayTraceId ( ) ;
38+ const traceId = traceIdFromInvokeStore ?? traceIdFromEnv ;
39+
3540 const nonEmptyString = ( str : unknown ) : str is string => typeof str === "string" && str . length > 0 ;
3641 if ( nonEmptyString ( functionName ) && nonEmptyString ( traceId ) ) {
3742 request . headers [ TRACE_ID_HEADER_NAME ] = traceId ;
You can’t perform that action at this time.
0 commit comments