Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lambda: trace-context trace continuation for SNS and SQS single event triggers #1831

Closed
astorm opened this issue Oct 15, 2020 · 1 comment · Fixed by #2606
Closed

lambda: trace-context trace continuation for SNS and SQS single event triggers #1831

astorm opened this issue Oct 15, 2020 · 1 comment · Fixed by #2606
Assignees
Labels
agent-nodejs Make available for APM Agents project planning.
Milestone

Comments

@astorm
Copy link
Contributor

astorm commented Oct 15, 2020

Once we take care of #1521, we'll want to make sure we add tracestate header parsing to the lambda transaction starting code.


Update (by trentm): I realize belatedly that this issue had been about extending the initial handling of the traceparent header in the Lambda instrumentation to also handle the tracestate header. That was done in #2185. I have morphed this issue to be about handling those trace-context headers for the SNS and SQS trigger cases.

Note (by trentm): The commit for elastic/apm-nodejs-http-client#180 reference this issue. It should have referenced #2598 instead.

@trentm trentm added the agent-nodejs Make available for APM Agents project planning. label Nov 16, 2020
@trentm
Copy link
Member

trentm commented Feb 19, 2022

Trace context is being picked up from event.headers to use as childOf for creating the lambda transaction. However there is some remaining work here:

  • The current event.headers checking is being done for all trigger events, and not scoped to API Gateway events.
  • Possible traceparent/tracestate from SNS and SQS single-event record.messageAttributes is not being picked up, but it is part of the spec.
  • We don't have test cases for any of the above yet.

@trentm trentm added this to the 8.2 milestone Feb 23, 2022
@trentm trentm changed the title TraceState Support for Amazon Lambda lambda: finish trace-context handling Mar 8, 2022
@trentm trentm self-assigned this Mar 8, 2022
@trentm trentm moved this from Planned to In Progress in APM-Agents (OLD) Mar 8, 2022
trentm added a commit to elastic/apm-nodejs-http-client that referenced this issue Mar 9, 2022
@trentm trentm changed the title lambda: finish trace-context handling lambda: trace-context trace continuation for SNS and SQS single event triggers Mar 10, 2022
trentm added a commit that referenced this issue Mar 10, 2022
… attributes for lambda transaction

- If a SNS or SQS single event trigger to an instrumented Lambda
  function includes message attributes with the name "traceparent" (and
  "tracestate"), case-insensitive, then those are used to continue the
  trace. This was already being done for API Gateway event headers.
- Also, fix a bug in the capturing of SNS and SQS message attributes as
  "transaction.context.message.headers". Note that only "String"-type
  message attributes are captured. Binary-type attributes are base64
  encoded. I'm not sure of the value in capturing them.

Closes: #1831
Fixes: #2605
Refs: elastic/apm#614
trentm added a commit to elastic/apm-nodejs-http-client that referenced this issue Mar 10, 2022
This ensures that the APM agent instrumentation in a Lambda
function will not cause a `null` response from the user's handler
if the agent cannot talk to the extension.

Note that the spec at elastic/apm#613 related to this might
yet change.

Refs: elastic/apm-agent-nodejs#1831
Refs: elastic/apm#613
APM-Agents (OLD) automation moved this from In Progress to Done Mar 15, 2022
trentm added a commit that referenced this issue Mar 15, 2022
… attributes for lambda transaction (#2606)

- If a SNS or SQS single event trigger to an instrumented Lambda
  function includes message attributes with the name "traceparent" (and
  "tracestate"), case-insensitive, then those are used to continue the
  trace. This was already being done for API Gateway event headers.
- Also, fix a bug in the capturing of SNS and SQS message attributes as
  "transaction.context.message.headers". Note that only "String"-type
  message attributes are captured. Binary-type attributes are base64
  encoded. I'm not sure of the value in capturing them.

Closes: #1831
Fixes: #2605
Refs: elastic/apm#614
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-nodejs Make available for APM Agents project planning.
Projects
2 participants