Skip to content

Injected aws.lambda_request_id is wrong #303

Open
@alexandruluca

Description

Description

I am using the newrelic layer on a nodejs lambda function.
The lambda runtime is Node.js 20.x and the layer arn is arn:aws:lambda:eu-west-1:451483290750:layer:NewRelicNodeJS20XARM64:51

(I have also tried using Node.js 22.x and latest layer version and still got the same issue)

When inspecting logs using the newrelic UI and when I tried correlating them using aws.lambda_request_id, I have noticed I get strange
data and something was not adding up.

The aws.lambda_request_id which is automatically injected via the layer, had the wrong aws request id in some cases.
In some cases, it seems it always has the previous request id.

This behaviour can be seen more clear in following screenshot. I have explicitly injected the awsRequestId using pino-lambda to try and compare and to troubleshoot the issue(the request id is ready from context each time the handler is called), and logger
As

Steps to Reproduce

This does not appear to happen at small scale, but only whenever we have concurrent invocations.

Here is a screenshot to illustrate behaviour.

Image

I have managed to work around this by explicitly injecting aws.lambda_request_id as part of the logger context which I get from the lambda context. It seems the newrelic lambda layer does not ovewrite aws.lambda_request_id if explicitly provided.
This works for me now, but it would be great if this can be fixed from the newrelic layer.

Expected Behaviour

aws.lambda_request_id to always have the correct aws request id from context.

Relevant Logs / Console output

Your Environment

  • ex: Browser name and version:
  • ex: Operating System and version:

Additional context

Metadata

Assignees

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