-
I am trying to instrument my typescript lambda functions with powertools, however, I don't get any sort of traces in the x-ray console, nor any errors in the logs that could help me diagnose why there are no traces. Is there any way to make the tool(s) print more information on why this might be happening? StackconstmyFN=newNodejsFunction(this,"myFn",{entry: join(__dirname,"..","functions/payment","my-fn","src","index.ts"),tracing: Tracing.ACTIVE,runtime: Runtime.NODEJS_18_X,architecture: Architecture.ARM_64,timeout: Duration.seconds(30),bundling: {minify: true,sourceMap: true,},environment: {NODE_OPTIONS: '--enable-source-maps',// see https://docs.aws.amazon.com/lambda/latest/dg/typescript-exceptions.htmlPOWERTOOLS_LOG_LEVEL: 'DEBUG',POWERTOOLS_TRACE_ENABLED: "true"},}); Lambdaimport{APIGatewayProxyResult,APIGatewayProxyWithLambdaAuthorizerEvent,Context}from"aws-lambda";import{Tracer,captureLambdaHandler}from'@aws-lambda-powertools/tracer';importmiddyfrom'@middy/core';consttracer=newTracer({serviceName: 'serverlessAirline'});interfaceUserContext{accountNumber: string;sessionId: string;}constlambdaHandler=async(event: APIGatewayProxyWithLambdaAuthorizerEvent<UserContext>,context: Context): Promise<APIGatewayProxyResult>=>{consthandlerSegment=tracer.getSegment()?.addNewSubsegment('### handler');handlerSegment&&tracer.setSegment(handlerSegment);tracer.putAnnotation('successfulBooking',true);console.log("hello","world");handlerSegment?.close();handlerSegment&&tracer.setSegment(handlerSegment?.parent);return{hello: "world"};}exportconsthandler=middy(lambdaHandler).use(captureLambdaHandler(tracer)); |
BetaWas this translation helpful?Give feedback.
Answered by am29d Feb 14, 2024
Replies: 1 comment
-
Hey @juaoose , you can attach the logger to the tracer and see debug statements. import{Tracer}from'@aws-lambda-powertools/tracer';import{Logger}from'@aws-lambda-powertools/logger';consttracer=newTracer();constlogger=newLogger();tracer.provider.setLogger(logger); if you set { "cold_start": true, "function_arn": "arn:aws:lambda:eu-west-1:xxxx:function:CdkStack-MyFunction3BAA72D1-Dt80v4r2LZZq", "function_memory_size": 1024, "function_name": "CdkStack-MyFunction3BAA72D1-Dt80v4r2LZZq", "function_request_id": "e822c766-ad93-45b0-af22-b6037e145111", "level": "DEBUG", "message": "UDP message sent: {\"id\":\"67081736cfdf9bd8\",\"name\":\"SSM\",\"start_time\":1707906769.144,\"namespace\":\"aws\",\"aws\":{\"operation\":\"GetParameter\",\"region\":\"eu-west-1\",\"request_id\":\"bd458e30-c09a-407b-a07a-06757d0c8b66\",\"retries\":1},\"http\":{\"response\":{\"status\":200,\"content_length\":199}},\"end_time\":1707906769.283,\"type\":\"subsegment\",\"parent_id\":\"babe751234a5964f\",\"trace_id\":\"1-65cc96d0-50be1d8458043e0405255b12\"}", "service": "service_undefined", "timestamp": "2024-02-14T10:32:49.289Z", "xray_trace_id": "1-65cc96d0-50be1d8458043e0405255b12" } However, we have also received a similar request in our discord channel where customer is not seeing traces and our e2e tests can't find traces either. We are looking into it. |
BetaWas this translation helpful?Give feedback.
0 replies
Answer selected bydreamorosi
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
Hey @juaoose ,
you can attach the logger to the tracer and see debug statements.
if you set
POWERTOOLS_LOG_LEVEL
toDEBUG
you will see something like this