Skip to content

@opentelemetry/instrumentation-aws-lambda not working for Node 24 (when not using Layers) #3314

@mduesterhoeft

Description

@mduesterhoeft

What version of OpenTelemetry are you using?

"@opentelemetry/api": "^1.9.0",
"@opentelemetry/core": "^2.2.0",
"@opentelemetry/instrumentation": "^0.208.0",
"@opentelemetry/instrumentation-aws-lambda": "^0.61.1",
"@opentelemetry/instrumentation-aws-sdk": "^0.64.1",
"@opentelemetry/resources": "^2.2.0",
"@opentelemetry/sdk-trace-base": "^2.2.0",
"@opentelemetry/sdk-trace-node": "^2.2.0",

What version of Node are you using?

Node 24

What did you do?

I am trying to use @opentelemetry/instrumentation-aws-lambda without the lambda layer (as described in the usage section of the package https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation-aws-lambda#usage)

See my reproduction scenario for details open-telemetry/opentelemetry-lambda#2081

This works fine with the Node22 Lambda Runtime. But does not with Node24.

With Node24 I still get a single log output from the lambda instrumentation (Instrumenting lambda handler). But nothing more.
With Node 22 I also saw the following log lines, which I am missing on Node 24

DEBUG @opentelemetry/instrumentation-aws-lambda Applying instrumentation patch for nodejs module file on require hook {   module: '/var/task/index.js',   version: undefined,   fileName: 'index',   baseDir: '/var/task' }                                                                                                                                                                                                                                                                                                DEBUG patch handler function      

So I think that the actual wrapping of the lambda function is not applied.

Full output of the handler on Node24

| 1766062029721 | INIT_START Runtime Version: nodejs:24.v27 Runtime Version ARN: arn:aws:lambda:eu-central-1::runtime:0bc82ce04038968a71a6237f018cf92c34977461e956ba25e0127f3d6cf4c36a                                                                                                                   
| 1766062029881 | @opentelemetry/api: Registered a global for diag v1.9.0.                                                                                                                                                                                                                               
| 1766062029883 | @opentelemetry/api: Registered a global for trace v1.9.0.                                                                                                                                                                                                                              
| 1766062029883 | @opentelemetry/api: Registered a global for context v1.9.0.                                                                                                                                                                                                                            
| 1766062029884 | @opentelemetry/api: Registered a global for propagation v1.9.0.                                                                                                                                                                                                                        
| 1766062029889 | Instrumenting lambda handler {                                                                                                                                                                                                                                                         
| 1766062029889 | taskRoot: '/var/task',                                                                                                                                                                                                                                                                 
| 1766062029889 | handlerDef: 'index.handler',                                                                                                                                                                                                                                                           
| 1766062029889 | handler: 'index.handler',                                                                                                                                                                                                                                                              
| 1766062029889 | moduleRoot: '',                                                                                                                                                                                                                                                                        
| 1766062029889 | module: 'index',                                                                                                                                                                                                                                                                       
| 1766062029889 | filename: '/var/task/index.js',                                                                                                                                                                                                                                                        
| 1766062029889 | functionName: 'handler'                                                                                                                                                                                                                                                                
| 1766062029889 | }                                                                                                                                                                                                                                                                                      
| 1766062030068 | 2025-12-18T12:47:10.068Z - DEBUG @opentelemetry/instrumentation-aws-sdk Applying instrumentation patch for module on require hook {   module: '@smithy/middleware-stack',   version: '4.1.1',   baseDir: '/var/runtime/node_modules/@aws-sdk/node_modules/@smithy/middleware-stack' }  |
| 1766062030071 | 2025-12-18T12:47:10.071Z - DEBUG @opentelemetry/instrumentation-aws-sdk propwrapping aws-sdk v3 constructStack                                                                                                                                                                         
| 1766062030074 | 2025-12-18T12:47:10.074Z - DEBUG @opentelemetry/instrumentation-aws-sdk Applying instrumentation patch for module on require hook {   module: '@smithy/smithy-client',   version: '4.6.4',   baseDir: '/var/runtime/node_modules/@aws-sdk/node_modules/@smithy/smithy-client' }    

I am using esbuild and the NodeJsFunction CDK construct to bundle the lambda function.

Additional context

I adapted the sample application in opentelemetry-lambda to reproduce the issue open-telemetry/opentelemetry-lambda#2081

Similar: open-telemetry/opentelemetry-lambda#2034

The full output of the working version on Node22

INIT_START Runtime Version: nodejs:22.v70 Runtime Version ARN: arn:aws:lambda:eu-central-1::runtime:dd849bc5eb759042eb9a87d38a406e763aeb7832756f411e38151c6c27e4afa2                                                                                                                                                                                                                                                                                                                                                                                        
@opentelemetry/api: Registered a global for diag v1.9.0.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
@opentelemetry/api: Registered a global for trace v1.9.0.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
@opentelemetry/api: Registered a global for context v1.9.0.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
@opentelemetry/api: Registered a global for propagation v1.9.0.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
Instrumenting lambda handler {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
taskRoot: '/var/task',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
handlerDef: 'index.handler',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
handler: 'index.handler',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
moduleRoot: '',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
module: 'index',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
filename: '/var/task/index.js',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
functionName: 'handler'                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
2025-12-18T12:40:58.424Z undefined DEBUG @opentelemetry/instrumentation-aws-sdk Applying instrumentation patch for module on require hook {   module: '@smithy/middleware-stack',   version: '4.1.1',   baseDir: '/var/runtime/node_modules/@aws-sdk/node_modules/@smithy/middleware-stack' }                                                                                                                                                                                                                                                               
2025-12-18T12:40:58.427Z undefined DEBUG @opentelemetry/instrumentation-aws-sdk propwrapping aws-sdk v3 constructStack                                                                                                                                                                                                                                                                                                                                                                                                                                      
2025-12-18T12:40:58.430Z undefined DEBUG @opentelemetry/instrumentation-aws-sdk Applying instrumentation patch for module on require hook {   module: '@smithy/smithy-client',   version: '4.6.4',   baseDir: '/var/runtime/node_modules/@aws-sdk/node_modules/@smithy/smithy-client' }                                                                                                                                                                                                                                                                     
2025-12-18T12:40:58.495Z undefined WARN Failed extracting version /var/task                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
2025-12-18T12:40:58.495Z undefined DEBUG @opentelemetry/instrumentation-aws-lambda Applying instrumentation patch for nodejs module file on require hook {   module: '/var/task/index.js',   version: undefined,   fileName: 'index',   baseDir: '/var/task' }                                                                                                                                                                                                                                                                                              
2025-12-18T12:40:58.496Z undefined DEBUG patch handler function                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
2025-12-18T12:40:58.498Z undefined WARN WARN: AWS Lambda has removed support for callback-based function handlers starting with Node.js 24. You will need to modify this function to use a supported handler signature when upgrading to Node.js 24 or later. To disable this warning, set the AWS_LAMBDA_NODEJS_DISABLE_CALLBACK_WARNING environment variable. For more information see https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html.                                                                                                  
START RequestId: 1a84eef8-6465-4377-a79d-2c9e3b9663d0 Version: $LATEST                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
2025-12-18T12:40:58.609Z 1a84eef8-6465-4377-a79d-2c9e3b9663d0 INFO Received event: {   "key1": "value1",   "key2": "value2",   "key3": "value3" }                                                                                                                                                                                                                                                                                                                                                                                                           
2025-12-18T12:40:58.609Z 1a84eef8-6465-4377-a79d-2c9e3b9663d0 INFO Received context: {   "callbackWaitsForEmptyEventLoop": true,   "functionVersion": "$LATEST",   "functionName": "instrumentation-test-handler",   "memoryLimitInMB": "256",   "logGroupName": "/aws/lambda/instrumentation-test-handler",   "logStreamName": "2025/12/18/[$LATEST]16fd510cacf3470484226bbf2f544a9f",   "invokedFunctionArn": "arn:aws:lambda:eu-central-1:199626657728:function:instrumentation-test-handler",   "awsRequestId": "1a84eef8-6465-4377-a79d-2c9e3b9663d0" }
{                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
resource: { attributes: { 'service.name': 'instrumentation-test-handler' } },                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
instrumentationScope: {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
name: '@opentelemetry/instrumentation-aws-sdk',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
version: '0.64.1',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
schemaUrl: undefined                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
},                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
traceId: '5793fb1f4d10f2af77b228dac2d8c1f0',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
parentSpanContext: {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
traceId: '5793fb1f4d10f2af77b228dac2d8c1f0',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
spanId: '952199344d62a57c',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
traceFlags: 1,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
traceState: undefined                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
},                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
traceState: undefined,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
name: 'STS.GetCallerIdentity',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
id: 'ea616abeefdec78e',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
kind: 2,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
timestamp: 1766061658613000,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
duration: 483582.225,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
attributes: {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
'rpc.system': 'aws-api',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
'rpc.method': 'GetCallerIdentity',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
'rpc.service': 'STS',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
'cloud.region': 'eu-central-1',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
'aws.request.id': '48cfa3a5-1fae-4e96-a1b9-cd0495b067b3',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
'http.status_code': 200                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
},                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
status: { code: 0 },                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
events: [],                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
links: []                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
2025-12-18T12:40:59.170Z 1a84eef8-6465-4377-a79d-2c9e3b9663d0 DEBUG Metrics may not be exported for the lambda function because we are not force flushing before handler completion.                                                                                                                                                                                                                                                                                                                                                                        
{                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
resource: { attributes: { 'service.name': 'instrumentation-test-handler' } },                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
instrumentationScope: {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
name: '@opentelemetry/instrumentation-aws-lambda',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
version: '0.61.1',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
schemaUrl: undefined                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
},                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
traceId: '5793fb1f4d10f2af77b228dac2d8c1f0',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
parentSpanContext: undefined,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
traceState: undefined,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
name: 'instrumentation-test-handler',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
id: '952199344d62a57c',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
kind: 1,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
timestamp: 1766061658591000,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
duration: 505776.919,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
attributes: {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
'faas.execution': '1a84eef8-6465-4377-a79d-2c9e3b9663d0',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
'faas.id': 'arn:aws:lambda:eu-central-1:199626657728:function:instrumentation-test-handler',                                                                                                                                                                                                                                                                                                                                                                                                                                                                
'cloud.account.id': '199626657728',                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
'faas.coldstart': true                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
},                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
status: { code: 0 },                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
events: [],                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
links: []                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
END RequestId: 1a84eef8-6465-4377-a79d-2c9e3b9663d0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
REPORT RequestId: 1a84eef8-6465-4377-a79d-2c9e3b9663d0 Duration: 686.92 ms Billed Duration: 1085 ms Memory Size: 256 MB Max Memory Used: 105 MB Init Duration: 398.07 ms                                                                                                                                                                                                                                                                                                                                                                                    

I am trying to avoid the Layers, because I would like to use a custom span exporter which uses SQS to publish spans.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions