Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lambda instrumentation does not take if _HANDLER has a period other in the module path #4293

Open
trentm opened this issue Nov 1, 2024 · 0 comments · May be fixed by #4294
Open

Lambda instrumentation does not take if _HANDLER has a period other in the module path #4293

trentm opened this issue Nov 1, 2024 · 0 comments · May be fixed by #4294
Assignees

Comments

@trentm
Copy link
Member

trentm commented Nov 1, 2024

A Lambda function has a "Handler" string (set on the _HANDLER envvar in the Lambda invocation process) that indicates the location of the handler function (both its module file location, and the export lookup path inside that module).
E.g. some/subdir/filename.handlerFunctionName points to a JS module at $LAMBDA_TASK_ROOT/some/subdir/filename.{js,cjs,mjs} and the handlerFunctionName export from that module.

The APM agent's processing of that handler string breaks if there is a period (.) in the module path. For example, this works:

_HANDLER="src/functions/myfunc/handler.main"

but this does not:

_HANDLER="./src/functions/myfunc/handler.main"

I suspect also that this would fail, but I have not tested.

_HANDLER="src/functions/my.other.func/handler.main"

The symptom is that a Lambda function setup to be instrumented by the Node.js APM agent does not show this log.debug:

{"log.level":"debug",...,"log.logger":"elastic-apm-node","message":"instrumenting /var/task/...@$LATEST module (enabled=true, ...)"}

Then no Lambda transaction is created, and then (typically) any additional spans from other instrumentation will not get created for lack of a current transaction.

@trentm trentm self-assigned this Nov 1, 2024
trentm added a commit that referenced this issue Nov 1, 2024
…e path

Before this if the _HANDLER string had a '.' in the module path (the
part before the 'moduleName.functionExport'), then the parsing of
that handler string would silently produce bogus 'lambdaHandlerInfo'
that would result in a RITM path that would never actually get loaded,
hence no Lambda instrumentation.

Fixes: #4293
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant