Skip to content

[serverless] No-op AWS Lambda integration on missing API Key#5900

Merged
duncanista merged 6 commits into
masterfrom
jordan.gonzalez/SLES-1806/aws/no-op-on-missing-api-key
Aug 16, 2024
Merged

[serverless] No-op AWS Lambda integration on missing API Key#5900
duncanista merged 6 commits into
masterfrom
jordan.gonzalez/SLES-1806/aws/no-op-on-missing-api-key

Conversation

@duncanista

@duncanista duncanista commented Aug 15, 2024

Copy link
Copy Markdown
Contributor

Summary of changes

Verifies that an API key is set in order to call the Lambda Extension.

Reason for change

It would not crash the customers, but it logs errors that should be avoided and handled better by not doing the operation.

Implementation details

Just created an API key getter in order to then check if the API is missing.

Test coverage

Tested manually on AWS Lambda.
Screenshot 2024-08-14 at 9 00 16 PM

Other details

@andrewlock

andrewlock commented Aug 15, 2024

Copy link
Copy Markdown
Member

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing the following branches/commits:

Execution-time benchmarks measure the whole time it takes to execute a program. And are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are shown in red. The following thresholds were used for comparing the execution times:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard.

Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph).

@datadog-ddstaging

datadog-ddstaging Bot commented Aug 15, 2024

Copy link
Copy Markdown

Datadog Report

Branch report: jordan.gonzalez/SLES-1806/aws/no-op-on-missing-api-key
Commit report: 6a6947f
Test service: dd-trace-dotnet

✅ 0 Failed, 350893 Passed, 1782 Skipped, 14h 38m 33.94s Total Time

@andrewlock

Copy link
Copy Markdown
Member

Benchmarks Report for tracer 🐌

Benchmarks for #5900 compared to master:

  • 4 benchmarks are faster, with geometric mean 1.596
  • 2 benchmarks are slower, with geometric mean 1.133
  • 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.ActivityBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 7.85μs 44.8ns 313ns 0.0191 0.00764 0 5.42 KB
master StartStopWithChild netcoreapp3.1 9.73μs 31.3ns 113ns 0.0197 0.00985 0 5.61 KB
master StartStopWithChild net472 16.2μs 58.5ns 227ns 1.01 0.287 0.0901 6.06 KB
#5900 StartStopWithChild net6.0 7.66μs 42ns 245ns 0.019 0.0076 0 5.43 KB
#5900 StartStopWithChild netcoreapp3.1 9.63μs 52ns 290ns 0.0181 0.00905 0 5.62 KB
#5900 StartStopWithChild net472 15.9μs 27.8ns 100ns 1.02 0.309 0.0951 6.06 KB
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 464μs 154ns 575ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 637μs 270ns 1.04μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 833μs 369ns 1.38μs 0.414 0 0 3.3 KB
#5900 WriteAndFlushEnrichedTraces net6.0 463μs 172ns 667ns 0 0 0 2.7 KB
#5900 WriteAndFlushEnrichedTraces netcoreapp3.1 646μs 229ns 889ns 0 0 0 2.7 KB
#5900 WriteAndFlushEnrichedTraces net472 847μs 568ns 2.13μs 0.422 0 0 3.3 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 net6.0 187μs 989ns 5.04μs 0.179 0 0 18.45 KB
master SendRequest netcoreapp3.1 212μs 1.17μs 6.95μs 0.199 0 0 20.61 KB
master SendRequest net472 0.00305ns 0.00106ns 0.00398ns 0 0 0 0 b
#5900 SendRequest net6.0 197μs 1.27μs 12.6μs 0.201 0 0 18.45 KB
#5900 SendRequest netcoreapp3.1 211μs 1.16μs 6.65μs 0.198 0 0 20.61 KB
#5900 SendRequest net472 0.00112ns 0.000484ns 0.00188ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 561μs 1.66μs 5.97μs 0.536 0 0 41.66 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 668μs 3.21μs 12.5μs 0.331 0 0 41.62 KB
master WriteAndFlushEnrichedTraces net472 901μs 4.22μs 16.4μs 8.09 2.25 0.45 53.3 KB
#5900 WriteAndFlushEnrichedTraces net6.0 571μs 2.59μs 10μs 0.561 0 0 41.55 KB
#5900 WriteAndFlushEnrichedTraces netcoreapp3.1 671μs 3.19μs 12.8μs 0.351 0 0 41.7 KB
#5900 WriteAndFlushEnrichedTraces net472 872μs 2.79μs 10.4μs 8.42 2.66 0.443 53.3 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 net6.0 1.31μs 1.58ns 5.93ns 0.0144 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.65μs 1.18ns 4.56ns 0.0132 0 0 1.02 KB
master ExecuteNonQuery net472 2μs 1.44ns 5.38ns 0.156 0 0 987 B
#5900 ExecuteNonQuery net6.0 1.2μs 0.805ns 3.12ns 0.0145 0 0 1.02 KB
#5900 ExecuteNonQuery netcoreapp3.1 1.74μs 0.772ns 2.89ns 0.0139 0 0 1.02 KB
#5900 ExecuteNonQuery net472 2.07μs 1.99ns 7.71ns 0.156 0 0 987 B
Benchmarks.Trace.ElasticsearchBenchmark - Faster 🎉 Same allocations ✔️

Faster 🎉 in #5900

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync‑net6.0 1.833 2,208.71 1,205.04 several?
Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch‑net6.0 1.770 2,192.63 1,238.51 bimodal
Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch‑netcoreapp3.1 1.644 2,684.47 1,633.38

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master CallElasticsearch net6.0 2.22μs 22.2ns 222ns 0.0131 0 0 976 B
master CallElasticsearch netcoreapp3.1 2.68μs 19.8ns 197ns 0.0133 0 0 976 B
master CallElasticsearch net472 2.57μs 1.93ns 7.47ns 0.157 0 0 995 B
master CallElasticsearchAsync net6.0 2.23μs 21.2ns 212ns 0.0128 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.67μs 1.13ns 4.36ns 0.0143 0 0 1.02 KB
master CallElasticsearchAsync net472 2.53μs 1.71ns 6.63ns 0.166 0 0 1.05 KB
#5900 CallElasticsearch net6.0 1.24μs 0.515ns 1.93ns 0.0133 0 0 976 B
#5900 CallElasticsearch netcoreapp3.1 1.63μs 0.808ns 3.13ns 0.0131 0 0 976 B
#5900 CallElasticsearch net472 2.48μs 1.71ns 6.64ns 0.157 0 0 995 B
#5900 CallElasticsearchAsync net6.0 1.2μs 0.666ns 2.49ns 0.0133 0 0 952 B
#5900 CallElasticsearchAsync netcoreapp3.1 1.72μs 0.685ns 2.56ns 0.0137 0 0 1.02 KB
#5900 CallElasticsearchAsync net472 2.63μs 0.891ns 3.33ns 0.166 0 0 1.05 KB
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteAsync net6.0 1.26μs 0.757ns 2.73ns 0.0133 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.63μs 0.963ns 3.6ns 0.0123 0 0 952 B
master ExecuteAsync net472 1.77μs 0.685ns 2.65ns 0.145 0 0 915 B
#5900 ExecuteAsync net6.0 1.26μs 0.609ns 2.36ns 0.0133 0 0 952 B
#5900 ExecuteAsync netcoreapp3.1 1.7μs 1.55ns 5.8ns 0.0127 0 0 952 B
#5900 ExecuteAsync net472 1.7μs 1.61ns 6.22ns 0.145 0 0 915 B
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendAsync net6.0 4.18μs 2.31ns 8.33ns 0.0312 0 0 2.22 KB
master SendAsync netcoreapp3.1 5.07μs 2.67ns 10.3ns 0.0354 0 0 2.76 KB
master SendAsync net472 7.75μs 3.09ns 11.6ns 0.497 0 0 3.15 KB
#5900 SendAsync net6.0 4.24μs 2.31ns 8.94ns 0.0299 0 0 2.22 KB
#5900 SendAsync netcoreapp3.1 5.05μs 3.41ns 13.2ns 0.0354 0 0 2.76 KB
#5900 SendAsync net472 7.85μs 2.69ns 10.4ns 0.498 0 0 3.15 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 net6.0 1.49μs 0.756ns 2.83ns 0.0228 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.16μs 1.76ns 6.81ns 0.0216 0 0 1.64 KB
master EnrichedLog net472 2.69μs 1.91ns 6.6ns 0.249 0 0 1.57 KB
#5900 EnrichedLog net6.0 1.56μs 0.711ns 2.75ns 0.0229 0 0 1.64 KB
#5900 EnrichedLog netcoreapp3.1 2.18μs 2.87ns 10.7ns 0.0216 0 0 1.64 KB
#5900 EnrichedLog net472 2.68μs 1.26ns 4.7ns 0.249 0 0 1.57 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 net6.0 116μs 180ns 699ns 0.058 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 120μs 106ns 397ns 0 0 0 4.28 KB
master EnrichedLog net472 151μs 113ns 437ns 0.684 0.228 0 4.46 KB
#5900 EnrichedLog net6.0 118μs 231ns 895ns 0 0 0 4.28 KB
#5900 EnrichedLog netcoreapp3.1 121μs 211ns 818ns 0.0609 0 0 4.28 KB
#5900 EnrichedLog net472 153μs 181ns 702ns 0.694 0.231 0 4.46 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 net6.0 3.06μs 0.879ns 3.29ns 0.0306 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.33μs 1.39ns 5.4ns 0.0281 0 0 2.2 KB
master EnrichedLog net472 5.05μs 1.66ns 6.21ns 0.319 0 0 2.02 KB
#5900 EnrichedLog net6.0 2.97μs 2.94ns 11ns 0.03 0 0 2.2 KB
#5900 EnrichedLog netcoreapp3.1 4.23μs 2.8ns 10.8ns 0.0279 0 0 2.2 KB
#5900 EnrichedLog net472 4.88μs 2.33ns 9.02ns 0.321 0 0 2.02 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 net6.0 1.34μs 0.682ns 2.55ns 0.0162 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.85μs 0.859ns 3.33ns 0.0158 0 0 1.14 KB
master SendReceive net472 2.1μs 0.52ns 1.88ns 0.183 0 0 1.16 KB
#5900 SendReceive net6.0 1.34μs 1.05ns 4.06ns 0.0161 0 0 1.14 KB
#5900 SendReceive netcoreapp3.1 1.8μs 0.755ns 2.93ns 0.0149 0 0 1.14 KB
#5900 SendReceive net472 2.08μs 1.65ns 5.94ns 0.184 0.00106 0 1.16 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 net6.0 2.77μs 0.893ns 3.22ns 0.0222 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 3.98μs 1.83ns 7.11ns 0.0219 0 0 1.65 KB
master EnrichedLog net472 4.46μs 2.99ns 11.2ns 0.322 0 0 2.04 KB
#5900 EnrichedLog net6.0 2.61μs 5.36ns 20.8ns 0.0219 0 0 1.6 KB
#5900 EnrichedLog netcoreapp3.1 4.08μs 2.42ns 9.36ns 0.0204 0 0 1.65 KB
#5900 EnrichedLog net472 4.36μs 1.91ns 7.15ns 0.324 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #5900

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑netcoreapp3.1 1.136 561.35 637.71
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net472 1.130 582.32 658.06

Faster 🎉 in #5900

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net6.0 1.218 483.57 397.07

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 484ns 0.177ns 0.684ns 0.00799 0 0 576 B
master StartFinishSpan netcoreapp3.1 563ns 0.804ns 3.11ns 0.00783 0 0 576 B
master StartFinishSpan net472 583ns 0.504ns 1.95ns 0.0916 0 0 578 B
master StartFinishScope net6.0 484ns 0.138ns 0.533ns 0.00977 0 0 696 B
master StartFinishScope netcoreapp3.1 736ns 0.692ns 2.68ns 0.00953 0 0 696 B
master StartFinishScope net472 908ns 1.49ns 5.56ns 0.104 0 0 658 B
#5900 StartFinishSpan net6.0 397ns 0.365ns 1.41ns 0.00819 0 0 576 B
#5900 StartFinishSpan netcoreapp3.1 633ns 2.45ns 9.51ns 0.00763 0 0 576 B
#5900 StartFinishSpan net472 658ns 1.19ns 4.62ns 0.0915 0 0 578 B
#5900 StartFinishScope net6.0 485ns 0.633ns 2.45ns 0.00976 0 0 696 B
#5900 StartFinishScope netcoreapp3.1 707ns 3.82ns 20.9ns 0.00956 0 0 696 B
#5900 StartFinishScope net472 817ns 1.33ns 5.14ns 0.104 0 0 658 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 net6.0 613ns 0.267ns 1.04ns 0.00984 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 896ns 0.281ns 1.05ns 0.00937 0 0 696 B
master RunOnMethodBegin net472 1.11μs 0.768ns 2.98ns 0.104 0 0 658 B
#5900 RunOnMethodBegin net6.0 582ns 0.5ns 1.94ns 0.00994 0 0 696 B
#5900 RunOnMethodBegin netcoreapp3.1 914ns 1.17ns 4.52ns 0.00911 0 0 696 B
#5900 RunOnMethodBegin net472 1.09μs 1.53ns 5.91ns 0.104 0 0 658 B

@andrewlock andrewlock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice job 👍

/// <returns>CallTarget state value</returns>
internal static CallTargetState OnMethodBegin<TTarget>(TTarget instance, ref Delegate handler)
{
if (IsApiKeyMissing.Value)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this definitely the only place you need it? No other handlers?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It seems like it, there's no other method which calls our delegates

@bouwkast bouwkast left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@duncanista
duncanista requested a review from a team as a code owner August 15, 2024 19:22
@duncanista
duncanista merged commit 8e63384 into master Aug 16, 2024
@duncanista
duncanista deleted the jordan.gonzalez/SLES-1806/aws/no-op-on-missing-api-key branch August 16, 2024 12:08
@github-actions github-actions Bot added this to the vNext-v3 milestone Aug 16, 2024
andrewlock pushed a commit that referenced this pull request Aug 23, 2024
## Summary of changes

Verifies that an API key is set in order to call the Lambda Extension.

## Reason for change

It would not crash the customers, but it logs errors that should be
avoided and handled better by not doing the operation.

## Implementation details

Just created an API key getter in order to then check if the API is
missing.

## Test coverage

Tested manually on AWS Lambda.
<img width="1486" alt="Screenshot 2024-08-14 at 9 00 16 PM"
src="https://github.com/user-attachments/assets/7a993627-3b68-4ef1-9960-3d69890a8f56">

## Other details
<!-- Fixes #{issue} -->

<!-- ⚠️ Note: where possible, please obtain 2 approvals prior to
merging. Unless CODEOWNERS specifies otherwise, for external teams it is
typically best to have one review from a team member, and one review
from apm-dotnet. Trivial changes do not require 2 reviews. -->
duncanista added a commit that referenced this pull request Aug 23, 2024
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.

4 participants