elastic / elastic/apm-agent-nodejs

Use `traceparent` from SQS MessageAttribute so that the transaction in Lambda to be a child of SQS Message Sender

Open
#4,242 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

**Is your feature request related to a problem? Please describe.**
I have an API Server(`nestjs`) that sends messages to AWS SQS.
A Lambda retrieves messages from the SQS queue and processes them.

I would like these two transactions to be appear as `related` in the `Service Map`
Currently, I can see that the SQS Sender and SQS Receiver are linked via `Span links`

But I would prefer the Lambda function to be shown as a the child of API Server.

**Describe the solution you'd like**
I have reviewed the source code of `lib/lambda.js`

https://github.com/elastic/apm-agent-nodejs/blob/2d084c54790f2c46253f6e1f3a0c10c9c0c4fd62/lib/lambda.js#L708-L741

I noticed that only API Gateway and ELB trigger types are register as `childOf` the `traceparent`.

It would be ideal to use the `traceparent` injected into SQS Message Attribute to achieve this behavior.

**Describe alternatives you've considered**
I tried using `agent.startTransaction` API, but this left the `messaging` `RECEIVED blabla` transaction dangling.

**Additional context**
Is there any specific reason why SQS Message exchanges are linked only via `span links` rather than using parent-child transaction relationships?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.