Skip to content

Conversation

@andrewlock
Copy link
Member

@andrewlock andrewlock commented Nov 25, 2022

Summary of changes

  • Reduces the frameworks we test in PRs to reduce impact of flakiness and reduce pressure on CI.
    • On PRs, reduces the tested frameworks to net461, netcoreapp2.1, netcoreapp3.1, net7.0. See below for rationale.
  • Fixes a bug introduced in Add support for .NET 7 #3482 causing us to skip integration tests on .NET 461

Reason for change

We have been seeing a lot of flakiness in general, and although we're working to tackle the source of the flakiness, the sheer number of tests we run means even a tiny percentage chance of flake appears more often then not. By reducing the number of test permutations we run, it should reduce the number of times the pipeline errors.

Additionally, we recently added another test framework to our matrix (net7.0). As we continue to support out-of-support versions of frameworks (e.g. .NET Core2.1 and .NET Core 3.0), our test matrix will continue to grow. This adds an increasing burden on our CI infrastructure, as we use more and more machines. We need to keep this in check, while not sacrificing reliability.

Also, we realised that the fix for net461 code coverage introduced in #3482 was not working for unit tests. This is because the Framework variable isn't set in that case and we're calling dotnet test instead of dotnet test --framework {Framework}.

Implementation details

This PR takes a simple approach - we simply don't run tests on a subset of target frameworks.

  • For integration tests, we simply don't generate a job for the framework
  • For unit tests, we switch to calling dotnet test and passing in --framework, instead of letting the CLI test all frameworks. Note that this was also necessary to fix the code coverage bug.

Added a parameter to Nuke IncludeAllTestFrameworks. When true this runs against all frameworks, as we do currently. This is the default if not overridden.

In CI, we set this to true for merges to master. For PRs and for scheduled builds, this is false. You can override it, and run a full test on a branch by setting run_all_test_frameworks=true when scheduling the build in Azure Devops. Consider doing this whenever you add a new integration, or make a change that you expect to effect different frameworks differently

To try to make sure we catch the "modified integrations" case, in this commit we look for changes to integrations, and run on all frameworks if changes are detected

I chose the following test frameworks to be run on every PR, as they test each of the generated dlls we produce for Datadog.Trace:

  • net461 for the .NET FX dll
  • netcoreapp2.1 for the netstandard2.0 dll
  • netcoreapp3.1 for the netcoreapp3.1 dll
  • net7.0 for the net6.0 dll

Which means we no longer test the following:

  • netcoreapp3.0 has been out of support for a long time, and there are only a couple of (pretty obsolete by now) ASP.NET Core paths where it branches differently from the netcoreapp2.1 behaviour
  • net5.0 is out of support, uses the same dll as netcoreapp3.1, and doesn't (AFAIK) have any behaviour not covered by netcoreapp3.
  • net6.0 is still in support, but should use the same paths as net7.0 in general. net7.0 support is still new, so thought we wanted to keep testing that more intensely, to flush out any issues.

I only removed these stages for integration/unit tests where we test them all. For the smoke tests I continued to test all (as we already run a reduced set in PRs). For benchmark/azure functions/lambda where we already only test a limited set of frameworks, I left them unchanged.

Test coverage

Other details

I originally investigated a more detailed approach, dynamically changing the <TargetFrameworks> based on the IncludeAllTestFrameworks variable. This has the advantage that it can significantly reduce the Restore (and some build stages) which speeds up the build.

Unfortunately, this is made complicated by the complex web of samples and dependency projects we have. Some samples always need building, regardless of the targeted frameworks. And as some stages still use the excluded frameworks (e.g. benchmarks, azure functions), it's all quite confusing. Chose to park this approach for now, and we can revisit later if we see fit (potentially revisiting the whole sample-building process etc).

@andrewlock andrewlock added area:builds project files, build scripts, pipelines, versioning, releases, packages area:tests unit tests, integration tests area:test-apps apps used to test integrations labels Nov 25, 2022
@andrewlock andrewlock requested review from a team as code owners November 25, 2022 12:31
@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Nov 25, 2022

Datadog Report

Branch report: andrew/simplified-reduced-frameworks
Commit report: 31321f4

dd-trace-dotnet 0 Failed, 0 New Flaky, 223590 Passed, 981 Skipped, 19m 40.69s Wall Time

@andrewlock

This comment has been minimized.

Copy link
Member

@tonyredondo tonyredondo left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@pierotibou pierotibou left a comment

Choose a reason for hiding this comment

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

Thanks a lot

@andrewlock

This comment has been minimized.

@andrewlock andrewlock force-pushed the andrew/simplified-reduced-frameworks branch from 3cee051 to 93f0bbe Compare November 25, 2022 15:44
@andrewlock

This comment has been minimized.

@andrewlock

This comment has been minimized.

@andrewlock
Copy link
Member Author

Benchmarks Report 🐌

Benchmarks for #3511 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 755μs 464ns 1.8μs 0.377 0 0 3.22 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 542μs 317ns 1.23μs 0 0 0 2.63 KB
#3511 WriteAndFlushEnrichedTraces net472 757μs 315ns 1.18μs 0.377 0 0 3.22 KB
#3511 WriteAndFlushEnrichedTraces netcoreapp3.1 553μs 209ns 811ns 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 182ns 0.106ns 0.383ns 0.0675 0 0 425 B
master AllCycleSimpleBody netcoreapp3.1 242ns 0.264ns 0.987ns 0.00578 0 0 424 B
master AllCycleMoreComplexBody net472 182ns 0.0999ns 0.374ns 0.0637 0 0 401 B
master AllCycleMoreComplexBody netcoreapp3.1 238ns 0.186ns 0.672ns 0.00549 0 0 400 B
master BodyExtractorSimpleBody net472 277ns 0.216ns 0.777ns 0.0574 0 0 361 B
master BodyExtractorSimpleBody netcoreapp3.1 244ns 0.139ns 0.52ns 0.00367 0 0 272 B
master BodyExtractorMoreComplexBody net472 16μs 17.4ns 67.5ns 1.2 0.0158 0 7.62 KB
master BodyExtractorMoreComplexBody netcoreapp3.1 12.8μs 2.93ns 10.6ns 0.0896 0 0 6.75 KB
#3511 AllCycleSimpleBody net472 182ns 0.0792ns 0.307ns 0.0675 0 0 425 B
#3511 AllCycleSimpleBody netcoreapp3.1 240ns 0.185ns 0.715ns 0.0058 0 0 424 B
#3511 AllCycleMoreComplexBody net472 180ns 0.106ns 0.411ns 0.0638 0 0 401 B
#3511 AllCycleMoreComplexBody netcoreapp3.1 239ns 0.172ns 0.665ns 0.00545 0 0 400 B
#3511 BodyExtractorSimpleBody net472 293ns 0.534ns 2.07ns 0.0574 0 0 361 B
#3511 BodyExtractorSimpleBody netcoreapp3.1 243ns 0.184ns 0.687ns 0.00368 0 0 272 B
#3511 BodyExtractorMoreComplexBody net472 15.9μs 7.18ns 26.9ns 1.21 0.016 0 7.62 KB
#3511 BodyExtractorMoreComplexBody netcoreapp3.1 12.5μs 2.78ns 10.4ns 0.094 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 174μs 141ns 547ns 0.262 0 0 20.44 KB
#3511 SendRequest net472 0ns 0ns 0ns 0 0 0 0 b
#3511 SendRequest netcoreapp3.1 174μs 114ns 441ns 0.26 0 0 20.44 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.71μs 0.619ns 2.32ns 0.16 0.000855 0 1.01 KB
master ExecuteNonQuery netcoreapp3.1 1.42μs 0.78ns 3.02ns 0.0135 0 0 1 KB
#3511 ExecuteNonQuery net472 1.76μs 0.29ns 1.04ns 0.16 0.000884 0 1.01 KB
#3511 ExecuteNonQuery netcoreapp3.1 1.43μs 1.05ns 4.05ns 0.0129 0 0 1 KB
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.44μs 0.661ns 2.38ns 0.194 0 0 1.22 KB
master CallElasticsearch netcoreapp3.1 1.57μs 0.588ns 2.28ns 0.0157 0 0 1.16 KB
master CallElasticsearchAsync net472 2.65μs 1.59ns 6.14ns 0.215 0 0 1.36 KB
master CallElasticsearchAsync netcoreapp3.1 1.69μs 0.564ns 1.95ns 0.0167 0 0 1.28 KB
#3511 CallElasticsearch net472 2.46μs 1.26ns 4.72ns 0.194 0 0 1.22 KB
#3511 CallElasticsearch netcoreapp3.1 1.53μs 0.762ns 2.95ns 0.016 0 0 1.16 KB
#3511 CallElasticsearchAsync net472 2.65μs 0.66ns 2.56ns 0.215 0 0 1.36 KB
#3511 CallElasticsearchAsync netcoreapp3.1 1.62μs 0.536ns 2ns 0.0172 0 0 1.28 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.69μs 0.902ns 3.49ns 0.235 0 0 1.49 KB
master ExecuteAsync netcoreapp3.1 1.78μs 1.22ns 4.72ns 0.0197 0 0 1.41 KB
#3511 ExecuteAsync net472 2.78μs 0.811ns 3.14ns 0.235 0 0 1.49 KB
#3511 ExecuteAsync netcoreapp3.1 1.77μs 0.607ns 2.27ns 0.0194 0 0 1.41 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.8μs 2.13ns 8.25ns 0.449 0 0 2.83 KB
master SendAsync netcoreapp3.1 3.65μs 2.77ns 10.4ns 0.0365 0 0 2.66 KB
#3511 SendAsync net472 5.81μs 1.69ns 6.56ns 0.449 0 0 2.83 KB
#3511 SendAsync netcoreapp3.1 3.62μs 1.98ns 7.68ns 0.0363 0 0 2.66 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 2.97μs 14.2ns 54.8ns 0.298 0 0 1.88 KB
master EnrichedLog netcoreapp3.1 2.25μs 6.63ns 41.4ns 0.0256 0 0 1.91 KB
#3511 EnrichedLog net472 2.9μs 1.7ns 6.59ns 0.297 0 0 1.88 KB
#3511 EnrichedLog netcoreapp3.1 2.29μs 0.828ns 3.1ns 0.0262 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 150μs 139ns 538ns 0.739 0.222 0 4.72 KB
master EnrichedLog netcoreapp3.1 119μs 159ns 617ns 0.0592 0 0 4.55 KB
#3511 EnrichedLog net472 152μs 123ns 461ns 0.683 0.228 0 4.72 KB
#3511 EnrichedLog netcoreapp3.1 120μs 152ns 588ns 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.46μs 3.4ns 12.7ns 0.58 0.00272 0 3.65 KB
master EnrichedLog netcoreapp3.1 4.26μs 1.33ns 4.61ns 0.0534 0 0 3.98 KB
#3511 EnrichedLog net472 5.39μs 1.03ns 3.7ns 0.578 0.0027 0 3.65 KB
#3511 EnrichedLog netcoreapp3.1 4.2μs 1.36ns 5.26ns 0.0544 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.14μs 1.84ns 7.11ns 0.228 0 0 1.44 KB
master SendReceive netcoreapp3.1 1.76μs 0.525ns 1.89ns 0.0184 0 0 1.38 KB
#3511 SendReceive net472 2.17μs 1.95ns 7.04ns 0.228 0 0 1.44 KB
#3511 SendReceive netcoreapp3.1 1.77μs 0.518ns 1.94ns 0.0185 0 0 1.38 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 4.76μs 1.1ns 3.98ns 0.364 0 0 2.3 KB
master EnrichedLog netcoreapp3.1 3.95μs 2.78ns 10.4ns 0.024 0 0 1.86 KB
#3511 EnrichedLog net472 4.7μs 1.78ns 6.43ns 0.364 0 0 2.3 KB
#3511 EnrichedLog netcoreapp3.1 3.84μs 2.4ns 9ns 0.0251 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.15μs 0.549ns 2.13ns 0.139 0 0 875 B
master StartFinishSpan netcoreapp3.1 966ns 0.37ns 1.38ns 0.0111 0 0 824 B
master StartFinishScope net472 1.41μs 0.583ns 2.26ns 0.151 0 0 955 B
master StartFinishScope netcoreapp3.1 1.11μs 0.507ns 1.96ns 0.0127 0 0 944 B
#3511 StartFinishSpan net472 1.11μs 0.562ns 2.18ns 0.139 0 0 875 B
#3511 StartFinishSpan netcoreapp3.1 957ns 0.268ns 1ns 0.011 0 0 824 B
#3511 StartFinishScope net472 1.36μs 0.326ns 1.22ns 0.151 0 0 955 B
#3511 StartFinishScope netcoreapp3.1 1.02μs 0.264ns 0.986ns 0.0128 0 0 944 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.61μs 0.639ns 2.48ns 0.152 0 0 955 B
master RunOnMethodBegin netcoreapp3.1 1.18μs 1.19ns 4.29ns 0.0126 0 0 944 B
#3511 RunOnMethodBegin net472 1.49μs 0.504ns 1.89ns 0.151 0 0 955 B
#3511 RunOnMethodBegin netcoreapp3.1 1.14μs 0.716ns 2.77ns 0.0125 0 0 944 B

@andrewlock
Copy link
Member Author

Code Coverage Report 📊

✔️ Merging #3511 into master will will increase line coverage by 3%
✔️ Merging #3511 into master will will increase branch coverage by 5%
✔️ Merging #3511 into master will will decrease complexity by 1404

master #3511 Change
Lines 19712 / 28123 19674 / 27079
Lines % 70% 73% 3% ✔️
Branches 11308 / 17781 11291 / 16409
Branches % 64% 69% 5% ✔️
Complexity 19231 17827 -1404 ✔️

View the full report for further details:

Datadog.Trace Breakdown ✔️

master #3511 Change
Lines % 70% 73% 3% ✔️
Branches % 64% 69% 5% ✔️
Complexity 19231 17827 -1404 ✔️

The following classes have significant coverage changes.

File Line coverage change Branch coverage change Complexity change
Datadog.Trace.Ci.GitInfo -17% -11% 0 ✔️
Datadog.Trace.Debugger.PInvoke.DebuggerNativeMethods 6% ✔️ 0% ✔️ 0 ✔️
Datadog.Trace.TracerManagerFactory 7% ✔️ 4% ✔️ -2 ✔️
Datadog.Trace.ClrProfiler.AutoInstrumentation.Http.HttpClient.WinHttpHandler.WinHttpHandlerIntegration 100% ✔️ 0% ✔️ 0 ✔️

32 classes were removed from Datadog.Trace in #3511

View the full reports for further details:

Copy link
Collaborator

@OmerRaviv OmerRaviv left a comment

Choose a reason for hiding this comment

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

LGTM

@andrewlock andrewlock merged commit c9ddd97 into master Nov 28, 2022
@andrewlock andrewlock deleted the andrew/simplified-reduced-frameworks branch November 28, 2022 15:24
@github-actions github-actions bot added this to the vNext milestone Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:builds project files, build scripts, pipelines, versioning, releases, packages 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.

5 participants