Skip to content

[Serverless] Send the lambda invocation context to our extension#2656

Merged
thedavlee merged 15 commits into
masterfrom
david.lee/serverless-send-lambda-context-headers-to-lambda-extension
Apr 18, 2022
Merged

[Serverless] Send the lambda invocation context to our extension#2656
thedavlee merged 15 commits into
masterfrom
david.lee/serverless-send-lambda-context-headers-to-lambda-extension

Conversation

@thedavlee

@thedavlee thedavlee commented Apr 8, 2022

Copy link
Copy Markdown

Summary of changes

Send the lambda invocation context to the datadog extension on StartInvocation

Reason for change

The lambda invocation context contains trace metadata (trace-id, parent-id) that needs to be passed to the lambda extension for successful trace propagation

Implementation details

Test coverage

Manually tested in conjunction with lambda extension changes on a variety of dotnet lambda functions (no parameters, one parameter (context and custom input), two parameters)

Other details

@andrewlock

This comment has been minimized.

@andrewlock

This comment has been minimized.

@andrewlock

This comment has been minimized.

@thedavlee
thedavlee marked this pull request as ready for review April 12, 2022 15:14
@thedavlee
thedavlee requested a review from a team as a code owner April 12, 2022 15:14
@thedavlee thedavlee changed the title [Serverless] WIP Send the lambda invocation context to our extension [Serverless] Send the lambda invocation context to our extension Apr 12, 2022
@thedavlee thedavlee changed the title [Serverless] Send the lambda invocation context to our extension [Serverless] WIP Send the lambda invocation context to our extension Apr 12, 2022
@thedavlee
thedavlee marked this pull request as draft April 12, 2022 15:39
@andrewlock

This comment has been minimized.

@thedavlee
thedavlee marked this pull request as ready for review April 13, 2022 22:12
@thedavlee thedavlee changed the title [Serverless] WIP Send the lambda invocation context to our extension [Serverless] Send the lambda invocation context to our extension Apr 13, 2022
@andrewlock

This comment has been minimized.

@thedavlee
thedavlee requested a review from lucaspimentel April 14, 2022 18:27
Co-authored-by: Lucas Pimentel-Ordyna <[email protected]>

@zacharycmontoya zacharycmontoya left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I can think of a couple small improvements that could be added later because I don't want to block this work:

  • Enabling C# nullable reference types in this file
  • Caching a default JSON object so we don't make unnecessary calls to serialize "{}" which will create a new object each time

@andrewlock

This comment has been minimized.

@zacharycmontoya

Copy link
Copy Markdown
Contributor

Since Lucas commented on the PR some requesting changes, please wait until he approves before merging. Thanks!

@thedavlee
thedavlee requested a review from lucaspimentel April 15, 2022 14:24
@andrewlock

Copy link
Copy Markdown
Member

Code Coverage Report 📊

✔️ Merging #2656 into master will not change line coverage
✔️ Merging #2656 into master will not change branch coverage
⛔ Merging #2656 into master will will increase complexity by 11

master #2656 Change
Lines 13537 / 18627 13549 / 18640
Lines % 73% 73% 0% ✔️
Branches 7815 / 11125 7843 / 11135
Branches % 70% 70% 0% ✔️
Complexity 12431 12442 11

View the full report for further details:

Datadog.Trace Breakdown ✔️

master #2656 Change
Lines % 73% 73% 0% ✔️
Branches % 70% 70% 0% ✔️
Complexity 12431 12442 11

The following classes have significant coverage changes.

File Line coverage change Branch coverage change Complexity change
Datadog.Trace.ClrProfiler.ServerlessInstrumentation.AWS.LambdaCommon -1% ⚠️ 15% ✔️ 11
Datadog.Trace.Ci.GitInfo 5% ✔️ 8% ✔️ 0 ✔️
Datadog.Trace.Ci.CIVisibility 7% ✔️ 7% ✔️ 0 ✔️
Datadog.Trace.Telemetry.JsonWebRequestTelemetryTransport 27% ✔️ 57% ✔️ 0 ✔️

View the full reports for further details:

@andrewlock

Copy link
Copy Markdown
Member

Benchmarks Report 🐌

Benchmarks for #2656 compared to master:

  • All benchmarks have the same speed
  • All benchmarks have the same allocations

The following thresholds were used for comparing the benchmark speeds:

  • Mann–Whitney U test with statistical test for significance of 5%
  • Only results indicating a difference greater than 10% and 0.3 ns are considered.

Allocation changes below 0.5% are ignored.

Benchmark details

Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net472 923μs 4.08μs 16.8μs 0 0 0 3.16 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 692μs 2.79μs 10.4μs 0 0 0 2.57 KB
#2656 WriteAndFlushEnrichedTraces net472 985μs 5μs 21.8μs 0 0 0 3.16 KB
#2656 WriteAndFlushEnrichedTraces netcoreapp3.1 778μs 3.72μs 14.9μs 0 0 0 2.57 KB
Benchmarks.Trace.AppSecBodyBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master AllCycleSimpleBody net472 288ns 1.35ns 5.21ns 0.0519 0 0 329 B
master AllCycleSimpleBody netcoreapp3.1 375ns 1.37ns 4.95ns 0.00462 0 0 328 B
master AllCycleMoreComplexBody net472 299ns 1.73ns 13.9ns 0.0482 0 0 305 B
master AllCycleMoreComplexBody netcoreapp3.1 371ns 1.83ns 7.78ns 0.00422 0 0 304 B
master BodyExtractorSimpleBody net472 423ns 2.37ns 15.9ns 0.0569 0 0 361 B
master BodyExtractorSimpleBody netcoreapp3.1 452ns 2.31ns 10.3ns 0.00376 0 0 272 B
master BodyExtractorMoreComplexBody net472 24μs 89.3ns 346ns 1.19 0.0125 0 7.62 KB
master BodyExtractorMoreComplexBody netcoreapp3.1 21.6μs 105ns 444ns 0.0931 0 0 6.75 KB
#2656 AllCycleSimpleBody net472 293ns 1.49ns 6.81ns 0.0519 0 0 329 B
#2656 AllCycleSimpleBody netcoreapp3.1 379ns 1.55ns 5.57ns 0.00464 0 0 328 B
#2656 AllCycleMoreComplexBody net472 291ns 1.43ns 7.01ns 0.0481 0 0 305 B
#2656 AllCycleMoreComplexBody netcoreapp3.1 387ns 1.83ns 11.4ns 0.0041 0 0 304 B
#2656 BodyExtractorSimpleBody net472 416ns 2.13ns 9.29ns 0.0569 0 0 361 B
#2656 BodyExtractorSimpleBody netcoreapp3.1 471ns 2.54ns 14.6ns 0.0037 0 0 272 B
#2656 BodyExtractorMoreComplexBody net472 24.1μs 134ns 868ns 1.19 0.0119 0 7.62 KB
#2656 BodyExtractorMoreComplexBody netcoreapp3.1 21.2μs 113ns 567ns 0.089 0 0 6.75 KB
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendRequest net472 0ns 0ns 0ns 0 0 0 0 b
master SendRequest netcoreapp3.1 293μs 1.51μs 7.07μs 0.143 0 0 19.74 KB
#2656 SendRequest net472 0ns 0ns 0ns 0 0 0 0 b
#2656 SendRequest netcoreapp3.1 286μs 1.53μs 7.64μs 0.151 0 0 19.74 KB
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteNonQuery net472 1.67μs 8.7ns 42.6ns 0.0943 0.000827 0 594 B
master ExecuteNonQuery netcoreapp3.1 1.51μs 7.56ns 49ns 0.00838 0 0 632 B
#2656 ExecuteNonQuery net472 1.73μs 10.1ns 94.4ns 0.0938 0.000885 0 594 B
#2656 ExecuteNonQuery netcoreapp3.1 1.46μs 7.32ns 32.7ns 0.00872 0 0 632 B
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master CallElasticsearch net472 2.67μs 13.3ns 70.1ns 0.126 0 0 802 B
master CallElasticsearch netcoreapp3.1 1.72μs 7.84ns 30.4ns 0.0109 0 0 792 B
master CallElasticsearchAsync net472 3μs 15.8ns 83.8ns 0.148 0 0 939 B
master CallElasticsearchAsync netcoreapp3.1 1.79μs 4.06ns 14.6ns 0.0126 0 0 912 B
#2656 CallElasticsearch net472 2.55μs 12.5ns 49.8ns 0.127 0 0 803 B
#2656 CallElasticsearch netcoreapp3.1 1.76μs 9.67ns 60.4ns 0.0104 0 0 792 B
#2656 CallElasticsearchAsync net472 2.82μs 14.6ns 70.2ns 0.149 0.00143 0 939 B
#2656 CallElasticsearchAsync netcoreapp3.1 1.82μs 9.59ns 46ns 0.0125 0 0 912 B
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteAsync net472 2.9μs 11.2ns 43.5ns 0.167 0 0 1.06 KB
master ExecuteAsync netcoreapp3.1 2.06μs 8.7ns 36.9ns 0.0142 0 0 1.03 KB
#2656 ExecuteAsync net472 3.11μs 17.7ns 133ns 0.165 0 0 1.06 KB
#2656 ExecuteAsync netcoreapp3.1 1.98μs 10.1ns 49.4ns 0.0148 0 0 1.03 KB
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendAsync net472 6.57μs 25.4ns 95ns 0.36 0 0 2.28 KB
master SendAsync netcoreapp3.1 5.01μs 28.4ns 199ns 0.0311 0 0 2.21 KB
#2656 SendAsync net472 7.18μs 39.4ns 243ns 0.361 0 0 2.28 KB
#2656 SendAsync netcoreapp3.1 4.95μs 27.6ns 189ns 0.0316 0 0 2.21 KB
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net472 3.54μs 10.7ns 42.7ns 0.228 0 0 1.45 KB
master EnrichedLog netcoreapp3.1 3.25μs 15.3ns 61.1ns 0.0217 0 0 1.53 KB
#2656 EnrichedLog net472 3.65μs 18.6ns 91.3ns 0.226 0 0 1.45 KB
#2656 EnrichedLog netcoreapp3.1 3.13μs 16.8ns 89ns 0.0215 0 0 1.53 KB
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net472 291μs 1.25μs 4.85μs 0.426 0.142 0 4.33 KB
master EnrichedLog netcoreapp3.1 225μs 646ns 2.42μs 0 0 0 4.21 KB
#2656 EnrichedLog net472 294μs 1.35μs 5.56μs 0.33 0.165 0 4.33 KB
#2656 EnrichedLog netcoreapp3.1 232μs 953ns 3.57μs 0 0 0 4.21 KB
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net472 8.05μs 44.6ns 296ns 0.503 0 0 3.23 KB
master EnrichedLog netcoreapp3.1 6.69μs 31.6ns 126ns 0.0489 0 0 3.6 KB
#2656 EnrichedLog net472 7.41μs 40.3ns 238ns 0.506 0 0 3.23 KB
#2656 EnrichedLog netcoreapp3.1 6.63μs 34.4ns 161ns 0.0489 0 0 3.6 KB
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendReceive net472 2.63μs 13ns 55ns 0.16 0.00127 0 1.01 KB
master SendReceive netcoreapp3.1 2.12μs 9.86ns 39.4ns 0.014 0 0 1.01 KB
#2656 SendReceive net472 2.43μs 13.7ns 101ns 0.159 0 0 1.01 KB
#2656 SendReceive netcoreapp3.1 1.99μs 10.2ns 47.8ns 0.0138 0 0 1.01 KB
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net472 6.87μs 32.1ns 124ns 0.289 0 0 1.87 KB
master EnrichedLog netcoreapp3.1 5.72μs 31ns 167ns 0.0194 0 0 1.49 KB
#2656 EnrichedLog net472 7.12μs 37.6ns 196ns 0.29 0 0 1.87 KB
#2656 EnrichedLog netcoreapp3.1 5.3μs 29.3ns 178ns 0.0196 0 0 1.49 KB
Benchmarks.Trace.SpanBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net472 973ns 4.7ns 18.8ns 0.0717 0 0 457 B
master StartFinishSpan netcoreapp3.1 864ns 3.35ns 12.5ns 0.00604 0 0 456 B
master StartFinishScope net472 1.06μs 5.78ns 33.2ns 0.0846 0 0 538 B
master StartFinishScope netcoreapp3.1 1.1μs 6.33ns 49.8ns 0.00806 0 0 576 B
#2656 StartFinishSpan net472 998ns 4.94ns 21.5ns 0.0718 0 0 457 B
#2656 StartFinishSpan netcoreapp3.1 897ns 4.63ns 22.2ns 0.00629 0 0 456 B
#2656 StartFinishScope net472 1.11μs 6.24ns 39.5ns 0.0844 0 0 538 B
#2656 StartFinishScope netcoreapp3.1 1.05μs 5.77ns 36.9ns 0.0076 0 0 576 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net472 1.48μs 7.56ns 33.8ns 0.0838 0 0 538 B
master RunOnMethodBegin netcoreapp3.1 1.22μs 4.71ns 17ns 0.00821 0 0 576 B
#2656 RunOnMethodBegin net472 1.32μs 7.57ns 60.5ns 0.0842 0 0 538 B
#2656 RunOnMethodBegin netcoreapp3.1 1.21μs 6.84ns 46.4ns 0.00808 0 0 576 B

@thedavlee
thedavlee merged commit a565f1b into master Apr 18, 2022
@thedavlee
thedavlee deleted the david.lee/serverless-send-lambda-context-headers-to-lambda-extension branch April 18, 2022 14:34
@github-actions github-actions Bot added this to the vNext milestone Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants