elastic / elastic/apm-agent-nodejs

AWS Lambda and ELB integration not including request metadata or tracing when using multi_value_headers

Open
#5,189 0 comments 0 reactions 0 assignees View on GitHub
community triage
Dominant language
JavaScript
Stars
594
Forks
244
Avg merge
1d 8h
Merged PRs (30d)
16

Description

**Describe the bug**

Using lambda behind an ALB that supports requests with multiple headers or query strings named the same requires `multi_value_headers` which moves the header access from `event.headers` to `event.multiValueHeaders` and QS access from `event.queryStringParameters` to `event.multiValueQueryStringParameters` in an all-or-nothing manner. The APM Lambda integration only ever looks at the former values so traceparent/tracestate tracking and relevant metadata (url.query, http.(request|response).headers) are missing in the transaction.

**To Reproduce**

Standard lambda instrumentation using an ALB with the target group attribute `lambda.multi_value_headers.enabled` set to true.

**Expected behavior**

Full tracing and metadata.

**Environment (please complete the following information)**

- OS: Lambda
- Node.js version: 22.x
- APM Server version:
- Agent version: 4.18.0

**How are you starting the agent? (please tick one of the boxes)**

- [ ] Calling `agent.start()` directly (e.g. `require('elastic-apm-node').start(...)`)
- [ ] Requiring `elastic-apm-node/start` from within the source code
- [ X] Starting node with `-r elastic-apm-node/start`

**Additional context**

AWS Documentation: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html#multi-value-headers

Likely the cause of #3286.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing standard Lambda instrumentation with an ALB target group using lambda.multi_value_headers.enabled, then follow the startup path through -r elastic-apm-node/start or agent.start(). Compare handling of event.headers and event.queryStringParameters with their multiValue counterparts; done means traceparent/tracestate and url.query plus request and response headers appear in the transaction.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, node.js
Domain
backend, observability-sre
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.