open-telemetry / opentelemetry-js

OpenTelemetry JavaScript Client
https://opentelemetry.io
Apache License 2.0
2.65k stars 765 forks source link

Lamda Auto Instrumentation Causes -> Internal Server Error Due To Span not Ending #4863

Closed mglaserna closed 1 week ago

mglaserna commented 2 months ago

What happened?

Steps to Reproduce

  1. Deploy a Lambda Node JS that is backed by API Gateway and Cloudflare

  2. Set the Auto Instrumentation config for the lambda with the following Layer: arn:aws:lambda:ap-southeast-1:184161586896:layer:opentelemetry-nodejs-0_7_0:1 OTEL_TRACES_SAMPLER: ALWAYS_ON - > need this since the lambda is behind API Gateway

  3. Call the lambda via APIGateway

Expected Result

Lambda will be able to send span and complete its transaction without errors

Actual Result

Lambda gives out "You can only call end() on a span once." Which causes internal server error but collector still receives the spans

Additional Details

OpenTelemetry Setup Code

No response

package.json

No response

Relevant log output

WARN: Can not execute the operation on ended Span {traceId: XXXXX, spanId: xxxxxxx}

2024-07-12T05:37:20.920Z    XXXXX   ERROR   ${LAMBDA SERVICE} XXXXXX - You can only call end() on a span once.
1:38
2024-07-12T05:37:20.920Z    XXXXX   ERROR   c${LAMBDA SERVICE}  XXXXXX-691cb454cc0c71ed - You can only call end() on a span once.
mglaserna commented 2 months ago

Just checked out, i think this is happening with opentelemetry/instrumentation-hapi enabled, still checking it throughly

dyladan commented 1 month ago

Can you provide a reproducer? This is not really actionable for us in its current state