DataDog / datadog-lambda-js

The Datadog AWS Lambda Library for Node
Apache License 2.0
113 stars 35 forks source link

Extract Lambda Trace Context from the Event's Step Functions Context #331

Closed kimi-p closed 1 year ago

kimi-p commented 1 year ago

What does this PR do?

Set Lambda span's trace_id and parent's span_id when Step Functions Context is detected in the event. The corresponding Lambda subtask span is set in the backend https://github.com/DataDog/logs-backend/pull/43234.

The MD5 logic on the backend is here: https://github.com/DataDog/logs-backend/blob/329f0ce114138067af8cdaef82bdbe15a06ffc58/domains/serverless/apps/logs-to-traces-reducer/src/main/java/com/dd/logs/serverless/logs_to_traces/common/HashHelper.java#L12-L32

Node: md5 is used to generate a string to be converted to trace_id in a deterministic way, so md5 is not used for any encryption purposes.

Motivation

To link Step Functions log generated span (parent) with Lambda span (child).

Testing Guidelines

Tested in staging with custom made dd-lambda-js layer. The trace is here.

image

Additional Notes

Types of Changes

Check all that apply

codecov-commenter commented 1 year ago

Codecov Report

Merging #331 (53f0b26) into main (fcf19da) will increase coverage by 0.31%. The diff coverage is 90.90%.

:exclamation: Current head 53f0b26 differs from pull request most recent head 44e3da1. Consider uploading reports for the commit 44e3da1 to get more accurate results

@@            Coverage Diff             @@
##             main     #331      +/-   ##
==========================================
+ Coverage   78.71%   79.02%   +0.31%     
==========================================
  Files          36       36              
  Lines        1785     1807      +22     
  Branches      415      418       +3     
==========================================
+ Hits         1405     1428      +23     
+ Misses        327      326       -1     
  Partials       53       53              
Impacted Files Coverage Δ
src/trace/context.ts 80.00% <90.90%> (+1.69%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more