You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
APM AWS Lambda extension version (apm-aws-lambda version): latest main (commit 02f4ef1) plus a patch for some debug logging
Describe the bug
I believe the extension is reporting a transaction twice in a certain case -- at least it appears that CreateProxyTxn is called twice. My case is when (a) using the extension and Node.js APM agent layers that support the recent partial transactions work and (b) a lambda function executes that results in terminating the function process (via process.exit(42) in my case). This results in the extension receiving the platform.runtimeDone event from the Logs API, and then the SHUTDOWN event. The handlers for both of those events result in calling b.finalizeInvocation(...).
Function URL: https://[REDACTED].lambda-url.us-west-2.on.aws/
You don't have to enable a function URL, but it is a convenient way to invoke the function.
Handler code. WARNING: The AWS Lambda console defaults to creating an index.mjs handler
file. This uses ES modules that the Node.js APM agent doesn't currently support. You must (a) delete index.mjs and (b) create a index.js file with:
module.exports.handler=async(event)=>{console.log('[handler] going to process.exit now');process.exit(42);};
at least it appears that CreateProxyTxn is called twice.
This is expected. CreateProxyTxn can be called multiple times. Once an invocation is finalized, we mark it as such (ref). In CreateProxyTxn we check if it really needs to create a proxy transaction - here we check if the finalized flag is set (ref).
I have created a PR to rename CreateProxyTxn to MaybeCreateProxyTxn to better indicate what the method does.
My guess at the issue: should this code be deleting reqID from b.invocations?
runtimeDone is not the last event for the invocation. After runtimeDone we receive the platformReport log, this is the event which triggers cleanup from the invocations datastructure. We use some of the invocation data to enrich the platformReport and that is why we don't cleanup invocations when we receive runtimeDone. Note that platfromReport will not be reported for the last invocation in case of failures, this is known (ref) but there is no known solution for this.
Are you observing duplicate transactions being reported by the extension?
/cc @lahsivjar
APM AWS Lambda extension version (
apm-aws-lambda version
): latest main (commit 02f4ef1) plus a patch for some debug loggingDescribe the bug
I believe the extension is reporting a transaction twice in a certain case -- at least it appears that
CreateProxyTxn
is called twice. My case is when (a) using the extension and Node.js APM agent layers that support the recent partial transactions work and (b) a lambda function executes that results in terminating the function process (viaprocess.exit(42)
in my case). This results in the extension receiving theplatform.runtimeDone
event from the Logs API, and then theSHUTDOWN
event. The handlers for both of those events result in callingb.finalizeInvocation(...)
.I'll show full repro steps below, but the annotated log is here: https://gist.github.com/trentm/66ebb5eb18c43eea0a8c013e193a41e6
My guess at the issue: should this code be deleting reqID from
b.invocations
?To Reproduce
create a new Lambda function, mine is named
trentm-play-fn3
Function URL: https://[REDACTED].lambda-url.us-west-2.on.aws/
You don't have to enable a function URL, but it is a convenient way to invoke the function.
Handler code.
WARNING: The AWS Lambda console defaults to creating an
index.mjs
handlerfile. This uses ES modules that the Node.js APM agent doesn't currently support.
You must (a) delete
index.mjs
and (b) create aindex.js
file with:Add layers to get the latest (unreleased) ext change, and the draft Node.js APM
changes (feat: pre-register partial transactions in AWS Lambda apm-agent-nodejs#3285) to make the
POST /register/transaction
calls to the extension. You can use the following, or build your own:See note below for the patch to the extension in my build (for debug logging).
Configure envvars for the Lambda:
Call the Lambda function once. We expect a 502 because it will crash.
Look at the logs via
aws logs tail --since 10s --follow /aws/lambda/trentm-play-fn3
Gist of the annotated log output: https://gist.github.com/trentm/66ebb5eb18c43eea0a8c013e193a41e6
Patch to apm-aws-lambda.git for debug logging
the diff
The text was updated successfully, but these errors were encountered: