Description
Describe the Bug
OpenTelemetry auto-instrumentation for AWS Lambda is not correctly propagating parent span IDs when using the AWS Lambda Layer (otel-nodejs) in a TypeScript-based Lambda.
- JavaScript Lambdas work correctly.
- TypeScript Lambdas drop parent spans, causing traces to appear disconnected in the tracing backend.
What did you expect to see?
- The parent span ID should be propagated correctly.
- Traces should be connected to the parent spans.
What did you see instead?
- No parent span ID is retained.
- The trace appears disconnected in the tracing backend.
This is a single lambda invocation with no parent ID and every span is seperated.
Timestamp (Local) | Level | Service | span_id | trace_id | Message |
---|---|---|---|---|---|
Mar 12 4:37:55.769 PM | ok | hasEligibleMacAddressHandler | 36b4fac9cbc266b5 | 67531b345b422befaa60232c084627f2 | dns.lookup |
Mar 12 4:37:55.750 PM | ok | hasEligibleMacAddressHandler | 3885f329e9bebb07 | 2c3d9bfa77566d65f5c38f5da7d93a4a | 200 GET http://localhost:2773/secretsmanager/get?secretId=qa/account-vehicle-service |
Mar 12 4:37:54.410 PM | ok | hasEligibleMacAddressHandler | 52b262ff58a7ea20 | cf72478ab8a4685ee978993d68836472 | tcp.connect |
Mar 12 4:37:54.410 PM | ok | hasEligibleMacAddressHandler | 65e34bc896c4cf37 | a07d26a6688312bcfeba166c529a1789 | dns.lookup |
Mar 12 4:37:54.170 PM | ok | hasEligibleMacAddressHandler | 31c1c10fdb703664 | b1c852b61f035eebdfd3a0e270344b61 | tcp.connect |
Mar 12 4:37:54.170 PM | ok | hasEligibleMacAddressHandler | dff7c0e0a8f2980e | e7a3992157fa443137799f0e1a6e3cf5 | dns.lookup |
What version of collector/language SDK version did you use?
- Lambda Layer (OTel Node.js):
- arn:aws:lambda:us-east-2:184161586896:layer:opentelemetry-nodejs-0_12_0:1
- Lambda Layer (OTel Collector):
- arn:aws:lambda:us-east-2:184161586896:layer:opentelemetry-collector-amd64-0_13_0:1
What language layer did you use?
nodejs
Additional context
If I manually propagate a parent trace through the lambda we'll be able to preserve the parent ID and trace continuity, I expect the lambda layer to autoinstrument the parent ID.
` // Extract traceparent from headers
const headers = event.headers || {};
const traceparentHeader = headers['traceparent'];
// Propagate traceparent if available
let ctx = context.active();
if (traceparentHeader) {
ctx = propagation.extract(ctx, { traceparent: traceparentHeader });
}
`
This forces a parent span and connects the traces, but shouldn't be necessary if the OpenTelemetry AWS Lambda layer is functioning correctly.
We've ruled out
- lambda layer configuration
- node versioning
- layer version
- secretsmanager lambda layer
- custom logging packages
- potential async issues
Questions for Maintainers
- Is this a known issue with OpenTelemetry auto-instrumentation in TypeScript-based AWS Lambdas?
- Is there a recommended workaround to ensure traces remain linked without requiring manual propagation?
- Could ESBuild bundling or Lambda execution order interfere with OpenTelemetry’s automatic instrumentation?