DataDog/datadog-lambda-js

Make `TraceExtractor` async

midu-git opened this issue · 5 comments

We would like to trace out serverless application, which include the following scenario

  1. A lambda function performs a POST operation to API Gateway.
  2. On receive, a lambda is triggered taking the payload and persisting it to an S3 bucket, saving the trace context as metadata.
  3. On this S3 bucket, an Object Created event is delivered to EventBridge.
  4. A lambda is triggered on this event.

Our intention is to have a full trace of this flow showing up in the UI. Unfortunately, there is no possibility to pass metadata from the S3 object to EventBridge. AWS simply does not support it. Out idea was to utilize DD_TRACE_EXTRACTOR to perform a headObject operation and extracting the trace context, however, neither the function extractTraceContext nor TraceExtractor
in this library is async and therefore we can't use promises inside the extractor.

Looking at the code shows that, e.g., MetricsListener i already implemented to use async functions, which is not the case for TraceListener. Is there any specific reason for this?

Can I have a sign of life?

Hi @midu-git - thanks for reaching out! Sorry for the delay.

I think this is a clever idea, and at the least I think we could allow Trace Extractors to be asynchronous.

We'll close this issue when we make the change and support this.

Thanks!
AJ

Hi @astuyve. Thanks for the response.
Do you have a rough idea about some timeline?

BR,
Michael

Hi Michael,

I'm looking at it now but I can't commit to when we could release this, as the team is presently focused on some high priority fixes in other libraries we maintain.

I will update this ticket when I know more.

Thanks!

Update - we've merged a PR which supports this and will update this ticket when the release lands in Lambda Layers/NPM.

Thanks!