Skip to content

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

@trentm

Description

@trentm

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions