Skip to content

Run serverless tests on .NET 5.0 and .NET 6.0#3369

Merged
andrewlock merged 4 commits into
masterfrom
andrew/serverless-dotnet6
Oct 21, 2022
Merged

Run serverless tests on .NET 5.0 and .NET 6.0#3369
andrewlock merged 4 commits into
masterfrom
andrew/serverless-dotnet6

Conversation

@andrewlock

@andrewlock andrewlock commented Oct 19, 2022

Copy link
Copy Markdown
Member

Summary of changes

  • Generalise the serverless tests for multiple frameworks
  • Fix support for .NET 5 and .NET 6

Reason for change

We support these frameworks, so we should probably test them, especially as we may need to add .NET 6 specific features (top-level functions).

In the course of this testing, discovered that we are generating spans from the lambda runtime itself, as this uses HttpClient, so we want to exclude those.

If you're interested, the extra http-client requests we generate in the extension look like this
  {
    TraceId: Id_173,
    SpanId: Id_174,
    Name: http.request,
    Resource: GET localhost:00000/?/runtime/invocation/next,
    Service: Amazon.Lambda.RuntimeSupport-http-client,
    Type: http,
    Tags: {
      component: HttpMessageHandler,
      http-client-handler-type: System.Net.Http.HttpClientHandler,
      http.method: GET,
      http.status_code: 200,
      http.url: http://localhost:00000/2018-06-01/runtime/invocation/next,
      runtime-id: Guid_29,
      span.kind: client,
      _dd.p.dm: -0
    },
    Metrics: {
      process_id: 0,
      _dd.agent_psr: 1.0,
      _dd.top_level: 1.0,
      _dd.tracer_kr: 1.0,
      _sampling_priority_v1: 1.0
    }
  },
  {
    TraceId: Id_183,
    SpanId: Id_184,
    Name: http.request,
    Resource: POST localhost:00000/?/runtime/invocation/?/error,
    Service: Amazon.Lambda.RuntimeSupport-http-client,
    Type: http,
    Tags: {
      component: HttpMessageHandler,
      http-client-handler-type: System.Net.Http.HttpClientHandler,
      http.method: POST,
      http.status_code: 202,
      http.url: http://localhost:00000/2018-06-01/runtime/invocation/Guid_34/error,
      runtime-id: Guid_28,
      span.kind: client,
      _dd.p.dm: -0
    },
    Metrics: {
      process_id: 0,
      _dd.agent_psr: 1.0,
      _dd.top_level: 1.0,
      _dd.tracer_kr: 1.0,
      _sampling_priority_v1: 1.0
    }
  },
  {
    TraceId: Id_185,
    SpanId: Id_186,
    Name: http.request,
    Resource: POST localhost:00000/?/runtime/invocation/?/response,
    Service: Amazon.Lambda.RuntimeSupport-http-client,
    Type: http,
    Tags: {
      component: HttpMessageHandler,
      http-client-handler-type: System.Net.Http.HttpClientHandler,
      http.method: POST,
      http.status_code: 202,
      http.url: http://localhost:00000/2018-06-01/runtime/invocation/Guid_35/response,
      runtime-id: Guid_1,
      span.kind: client,
      _dd.p.dm: -0
    },
    Metrics: {
      process_id: 0,
      _dd.agent_psr: 1.0,
      _dd.top_level: 1.0,
      _dd.tracer_kr: 1.0,
      _sampling_priority_v1: 1.0
    }
  },

Implementation details

Generalise the lambda docker files and build process to use a matrix.

Exclude the lambda endpoints from the list of traced http requests.

Test coverage

Yep

Other details

Based on #3367, so need to merge that one first.

Also, I noticed that the default service name used in .NET Core 3.1 and .NET 5/6 changes, so I'm normalizing that by setting DD_SERVICE for now, but we should address the default value used here in a later PR, once we've confirmed this is relevant (i.e. it was mentioned the Lambda extension ignores this, so will consider that)

@andrewlock andrewlock added area:tests unit tests, integration tests area:test-apps apps used to test integrations area:serverless labels Oct 19, 2022
@andrewlock
andrewlock requested review from a team as code owners October 19, 2022 12:41
@andrewlock

This comment has been minimized.

@andrewlock

This comment has been minimized.

@pierotibou pierotibou 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.

🙇

@andrewlock

This comment has been minimized.

@github-actions

This comment has been minimized.

Base automatically changed from andrew/serverless-fix to master October 20, 2022 16:37
…de "framework" requests

Analogous to the AzureAppService.Metadata property
Exposes the IsRunningInLambda property
Can use that to exclude requests from the lambda runtime
This is set to a different value in .NET Core 3.1 and .NET 5/6.
Will address the default value in a subsequent PR
@andrewlock
andrewlock force-pushed the andrew/serverless-dotnet6 branch from 73e44af to 5c60004 Compare October 20, 2022 16:38
@github-actions

This comment has been minimized.

@andrewlock

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Snapshots difference summary

The following differences have been observed in committed snapshots. It is meant to help the reviewer.
The diff is simplistic, so please check some files anyway while we improve it.

29 occurrences of :

-    Service: Bootstrap,
+    Service: Samples.Aws.Lambda,

23 occurrences of :

-    Service: Bootstrap-http-client,
+    Service: Samples.Aws.Lambda-http-client,

6 occurrences of :

-    Service: Bootstrap-http-client,
+    Service: Samples.Aws.Lambda-http-client,
[...]
-      error.msg: Cannot assign requested address Cannot assign requested address,
-      error.stack:
[...]
+      error.msg: Cannot assign requested address,
+      error.stack: Cannot assign requested address (SocketException),

@andrewlock

Copy link
Copy Markdown
Member Author

Benchmarks Report 🐌

Benchmarks for #3369 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 797μs 677ns 2.53μs 0.398 0 0 3.22 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 569μs 607ns 2.27μs 0 0 0 2.63 KB
#3369 WriteAndFlushEnrichedTraces net472 798μs 707ns 2.74μs 0.401 0 0 3.22 KB
#3369 WriteAndFlushEnrichedTraces netcoreapp3.1 562μs 771ns 2.98μs 0 0 0 2.63 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 196ns 0.0355ns 0.123ns 0.0701 0 0 441 B
master AllCycleSimpleBody netcoreapp3.1 255ns 0.115ns 0.397ns 0.00592 0 0 440 B
master AllCycleMoreComplexBody net472 197ns 0.147ns 0.549ns 0.0662 0 0 417 B
master AllCycleMoreComplexBody netcoreapp3.1 251ns 0.133ns 0.499ns 0.00566 0 0 416 B
master BodyExtractorSimpleBody net472 290ns 0.329ns 1.23ns 0.0574 0 0 361 B
master BodyExtractorSimpleBody netcoreapp3.1 232ns 0.101ns 0.379ns 0.0037 0 0 272 B
master BodyExtractorMoreComplexBody net472 16μs 13.3ns 51.4ns 1.21 0.0159 0 7.62 KB
master BodyExtractorMoreComplexBody netcoreapp3.1 13μs 6.22ns 23.3ns 0.0907 0 0 6.75 KB
#3369 AllCycleSimpleBody net472 195ns 0.128ns 0.496ns 0.0701 9.89E-05 0 441 B
#3369 AllCycleSimpleBody netcoreapp3.1 252ns 0.223ns 0.865ns 0.00604 0 0 440 B
#3369 AllCycleMoreComplexBody net472 194ns 0.0219ns 0.0788ns 0.0663 0 0 417 B
#3369 AllCycleMoreComplexBody netcoreapp3.1 250ns 0.176ns 0.658ns 0.00565 0 0 416 B
#3369 BodyExtractorSimpleBody net472 273ns 0.132ns 0.477ns 0.0573 0 0 361 B
#3369 BodyExtractorSimpleBody netcoreapp3.1 243ns 0.142ns 0.55ns 0.00378 0 0 272 B
#3369 BodyExtractorMoreComplexBody net472 16.5μs 13ns 50.4ns 1.2 0.0165 0 7.62 KB
#3369 BodyExtractorMoreComplexBody netcoreapp3.1 13.3μs 5.93ns 22.2ns 0.0932 0 0 6.75 KB
Benchmarks.Trace.AspNetCoreBenchmark - Unknown 🤷 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 181μs 195ns 753ns 0.179 0 0 20.67 KB
#3369 SendRequest net472 0ns 0ns 0ns 0 0 0 0 b
#3369 SendRequest netcoreapp3.1 181μs 261ns 1.01μs 0.18 0 0 20.66 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.84μs 0.949ns 3.55ns 0.158 0.000917 0 995 B
master ExecuteNonQuery netcoreapp3.1 1.41μs 0.869ns 3.13ns 0.0135 0 0 984 B
#3369 ExecuteNonQuery net472 1.76μs 0.791ns 3.07ns 0.157 0.000885 0 995 B
#3369 ExecuteNonQuery netcoreapp3.1 1.5μs 0.595ns 2.22ns 0.0128 0 0 984 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.46μs 1.05ns 3.78ns 0.19 0 0 1.2 KB
master CallElasticsearch netcoreapp3.1 1.59μs 1.37ns 5.3ns 0.0151 0 0 1.14 KB
master CallElasticsearchAsync net472 2.71μs 0.822ns 3.18ns 0.212 0 0 1.34 KB
master CallElasticsearchAsync netcoreapp3.1 1.62μs 0.639ns 2.39ns 0.017 0 0 1.26 KB
#3369 CallElasticsearch net472 2.49μs 1.31ns 4.89ns 0.191 0 0 1.2 KB
#3369 CallElasticsearch netcoreapp3.1 1.5μs 0.612ns 2.37ns 0.0158 0 0 1.14 KB
#3369 CallElasticsearchAsync net472 2.69μs 1.04ns 3.88ns 0.212 0 0 1.34 KB
#3369 CallElasticsearchAsync netcoreapp3.1 1.62μs 0.601ns 2.25ns 0.0169 0 0 1.26 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 net472 2.64μs 1.5ns 5.81ns 0.233 0 0 1.47 KB
master ExecuteAsync netcoreapp3.1 1.69μs 0.786ns 3.04ns 0.0185 0 0 1.39 KB
#3369 ExecuteAsync net472 2.7μs 2.07ns 8.02ns 0.232 0 0 1.47 KB
#3369 ExecuteAsync netcoreapp3.1 1.81μs 0.78ns 2.81ns 0.0188 0 0 1.39 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 5.88μs 3.27ns 12.7ns 0.445 0 0 2.82 KB
master SendAsync netcoreapp3.1 3.67μs 1.26ns 4.88ns 0.0348 0 0 2.65 KB
#3369 SendAsync net472 5.84μs 2.04ns 7.37ns 0.446 0 0 2.82 KB
#3369 SendAsync netcoreapp3.1 3.68μs 0.837ns 2.9ns 0.035 0 0 2.65 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.14μs 1.99ns 7.7ns 0.298 0 0 1.88 KB
master EnrichedLog netcoreapp3.1 2.55μs 0.799ns 2.99ns 0.0254 0 0 1.91 KB
#3369 EnrichedLog net472 3.17μs 2.19ns 8.21ns 0.297 0 0 1.88 KB
#3369 EnrichedLog netcoreapp3.1 2.58μs 1.27ns 4.76ns 0.0256 0 0 1.91 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 151μs 103ns 386ns 0.749 0.225 0 4.72 KB
master EnrichedLog netcoreapp3.1 119μs 108ns 390ns 0 0 0 4.55 KB
#3369 EnrichedLog net472 153μs 283ns 1.09μs 0.688 0.229 0 4.72 KB
#3369 EnrichedLog netcoreapp3.1 119μs 101ns 379ns 0.0599 0 0 4.55 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 5.74μs 1.33ns 5.17ns 0.579 0.0029 0 3.65 KB
master EnrichedLog netcoreapp3.1 4.57μs 3.18ns 12.3ns 0.0526 0 0 3.98 KB
#3369 EnrichedLog net472 5.82μs 2.03ns 7.58ns 0.58 0.00291 0 3.65 KB
#3369 EnrichedLog netcoreapp3.1 4.55μs 1.45ns 5.42ns 0.0543 0 0 3.98 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.3μs 1.1ns 4.11ns 0.225 0 0 1.42 KB
master SendReceive netcoreapp3.1 1.71μs 0.834ns 3.23ns 0.0188 0 0 1.37 KB
#3369 SendReceive net472 2.25μs 0.998ns 3.73ns 0.225 0 0 1.42 KB
#3369 SendReceive netcoreapp3.1 1.77μs 0.887ns 3.32ns 0.0186 0 0 1.37 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 5.05μs 1.53ns 5.74ns 0.364 0 0 2.3 KB
master EnrichedLog netcoreapp3.1 4.32μs 2.62ns 9.79ns 0.0238 0 0 1.86 KB
#3369 EnrichedLog net472 5.02μs 1.56ns 5.84ns 0.364 0 0 2.3 KB
#3369 EnrichedLog netcoreapp3.1 4.35μs 2.79ns 10.8ns 0.0239 0 0 1.86 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 1.17μs 0.276ns 1.03ns 0.136 0 0 859 B
master StartFinishSpan netcoreapp3.1 986ns 0.393ns 1.52ns 0.0109 0 0 808 B
master StartFinishScope net472 1.36μs 0.725ns 2.71ns 0.149 0 0 939 B
master StartFinishScope netcoreapp3.1 1.09μs 1.05ns 3.78ns 0.0124 0 0 928 B
#3369 StartFinishSpan net472 1.25μs 0.319ns 1.19ns 0.136 0 0 859 B
#3369 StartFinishSpan netcoreapp3.1 925ns 0.342ns 1.32ns 0.0111 0 0 808 B
#3369 StartFinishScope net472 1.47μs 0.324ns 1.26ns 0.149 0 0 939 B
#3369 StartFinishScope netcoreapp3.1 1.15μs 0.487ns 1.89ns 0.0127 0 0 928 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.52μs 0.772ns 2.99ns 0.149 0 0 939 B
master RunOnMethodBegin netcoreapp3.1 1.13μs 0.306ns 1.15ns 0.0124 0 0 928 B
#3369 RunOnMethodBegin net472 1.47μs 0.842ns 3.26ns 0.149 0 0 939 B
#3369 RunOnMethodBegin netcoreapp3.1 1.21μs 0.706ns 2.64ns 0.0121 0 0 928 B

@andrewlock

Copy link
Copy Markdown
Member Author

Code Coverage Report 📊

✔️ Merging #3369 into master will not change line coverage
⚠️ Merging #3369 into master will will decrease branch coverage by 1%
⛔ Merging #3369 into master will will increase complexity by 5

master #3369 Change
Lines 19594 / 27074 19465 / 27081
Lines % 72% 72% 0% ✔️
Branches 11593 / 16760 11498 / 16764
Branches % 69% 69% -1% ⚠️
Complexity 18141 18146 5

View the full report for further details:

Datadog.Trace Breakdown ✔️

master #3369 Change
Lines % 72% 72% 0% ✔️
Branches % 69% 69% -1% ⚠️
Complexity 18141 18146 5

The following classes have significant coverage changes.

File Line coverage change Branch coverage change Complexity change
Datadog.Trace.Agent.TraceSamplers.AnalyticsEventsSampler -100% -100% 0 ✔️
Datadog.Trace.Agent.TraceSamplers.ErrorSampler -100% -100% 0 ✔️
Datadog.Trace.Agent.TraceSamplers.PrioritySampler -100% 0% ✔️ 0 ✔️
Datadog.Trace.Sampling.GlobalSamplingRule -100% 0% ✔️ 0 ✔️
Datadog.Trace.Agent.TraceSamplers.RareSampler -89% -96% 0 ✔️
Datadog.Trace.Util.SamplingHelpers -50% -50% 0 ✔️
Datadog.Trace.Telemetry.Transports.JsonTelemetryTransport -33% -42% 0 ✔️
Datadog.Trace.Logging.DirectSubmission.DirectLogSubmissionManager -33% -33% 0 ✔️
Datadog.Trace.Logging.DirectSubmission.Sink.NullDatadogSink -25% 0% ✔️ 0 ✔️
Datadog.Trace.Processors.NormalizerTraceProcessor -22% -19% 0 ✔️
...And 9 more

View the full reports for further details:

@andrewlock
andrewlock merged commit 4c40d13 into master Oct 21, 2022
@andrewlock
andrewlock deleted the andrew/serverless-dotnet6 branch October 21, 2022 09:52
@github-actions github-actions Bot added this to the vNext milestone Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:serverless area:test-apps apps used to test integrations area:tests unit tests, integration tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants