newrelic / newrelic-ruby-agent

New Relic RPM Ruby Agent
https://docs.newrelic.com/docs/apm/agents/ruby-agent/getting-started/introduction-new-relic-ruby/
Apache License 2.0
1.19k stars 600 forks source link

Test / Fix distributed trace across multiple AWS lambdas #2664

Open kford-newrelic opened 4 weeks ago

kford-newrelic commented 4 weeks ago

Description

As a reference, the Python Agent team has a write up on what they needed to do to address this problem within the Python agent.

This topic came up as part of customer escalation, who was having some challenges with New Relic when using AWS API Gateway configured in HTTP mode which executes a lambda. For this customer, there are actually a chain of API Gateway (HTTP) → Lambda → API Gateway (HTTP) → Lambda calls. When manually testing this use case to understand the behavior within New Relic, it was found that each lambda had their own trace_id’s even though the expected HTTP headers were being forwarded to the second lambda.

Acceptance Criteria

If both entities have the same trace_id and the service map for the distributed trace shows both lambdas, you are done and no changes are needed.

If both entities have different trace_id’s and the service map for the distributed trace only shows the lambda that you are viewing from, then there is an issue with propagating the trace_id between the lambdas that needs to be debugged and fixed.

Design Consideration/Limitations

N/A

Dependencies

In order to run the test, it does take a bit of setup within AWS.

With the above defined and working, run curl commands to generate several test distributed traces. For the same external request, are both entities using the same trace_id or are they generating different trace_ids?

Additional context

See NR-265378 for Python example code and output

workato-integration[bot] commented 4 weeks ago

https://new-relic.atlassian.net/browse/NR-274393