-
Notifications
You must be signed in to change notification settings - Fork 587
Open
Labels
bugSomething isn't workingSomething isn't workingpkg:instrumentation-aws-lambdapriority:p1Bugs which cause problems in end-user applications such as crashes, data inconsistenciesBugs which cause problems in end-user applications such as crashes, data inconsistencies
Description
What version of OpenTelemetry are you using?
What version of Node are you using?
Node.js 22.x
What did you do?
- Create new Lambda function using Node.js 22.x with function body:
export const handler = awslambda.streamifyResponse(
async (event, responseStream, _context) => {
console.log(event)
console.log(responseStream)
console.log(_context)
responseStream.write('test payload');
responseStream.end();
}
)
- Test above with helloworld - Success (see success.log)
- Checkout https://github.com/open-telemetry/opentelemetry-lambda
- from
nodejs
foldernpm install
&npm run build
- Create lambda layer from resultant zip.
- Add lambda layer to function, set env var:
AWS_LAMBDA_EXEC_WRAPPER /opt/otel-handler
- Test again with helloworld - Failure (see failure.log):
TypeError: responseStream.write is not a function
What did you expect to see?
Expected instrumentation to work.
What did you see instead?
Instrumentation caused my lambda to fail.
Additional context
The problem appears to be opentelemetry-instrumentation-aws-lambda
. The instrumentation basically looks for any handler
and replaces it with a patched handler
that has 3 args: event, context, and callback. However, with streaming response lambdas the handler is streamifyReponse
which needs 4 args: event, context, responseStream, and callback. So, responseStream
is overwritten with callback and becomes unusable.
Two solutions:
- [Short term] Do not instrument if
handler
is astreamifyReponse
- Callout, this means streaming response lambdas will not be supported - [Long term] Properly instrument
streamifyResponse
, fully supporting both "normal" and streaming response lambdas.
Let me know if I should cut a separate issue for 2, above.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpkg:instrumentation-aws-lambdapriority:p1Bugs which cause problems in end-user applications such as crashes, data inconsistenciesBugs which cause problems in end-user applications such as crashes, data inconsistencies