Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI Visibility] - Add retries support for IOException in the coverage collector #3726

Merged
merged 2 commits into from Jan 30, 2023

Conversation

tonyredondo
Copy link
Member

@tonyredondo tonyredondo commented Jan 30, 2023

Summary of changes

This PR adds support for retries on IOExceptions when processing an assembly to add coverage information.

Reason for change

Sometimes the coverage datacollector throws an IOException because the assembly we try to modify is being used by another process. This appears to be a common problem in the coverage tools space, as we can see in the following issues:

With this PR we retry at least 3 times before failing to add coverage to an assembly.

@tonyredondo tonyredondo requested a review from a team as a code owner January 30, 2023 10:10
@tonyredondo tonyredondo self-assigned this Jan 30, 2023
lstExceptions ??= new List<Exception>();
lstExceptions.Add(ioException);
Thread.Sleep(1000);
goto Retry;
Copy link
Member

Choose a reason for hiding this comment

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

👀 Haha hungarian notation and goto 😄

@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Jan 30, 2023

Datadog Report

Branch report: tony/add-retrys-on-coverage-collector
Commit report: 427bef5

❄️ dd-trace-dotnet: 0 Failed, 1 New Flaky, 228481 Passed, 638 Skipped, 20m 6.81s Wall Time

New Flaky Tests (1)

  • TestRequest - Datadog.Trace.Security.IntegrationTests.AspNetCore5TestsSecurityDisabled - Last Failure

    Expand for error
     Results do not match.
     Differences:
     Received: Security.AspNetCore5.SecurityDisabled.__test=server.request.query_expectedStatusCode=200_url=_Health_-arg&[$slice].received.txt
     Verified: Security.AspNetCore5.SecurityDisabled.__test=server.request.query_expectedStatusCode=200_url=_Health_-arg&[$slice].verified.txt
     Received Content:
     [
       {
         TraceId: Id_1,
         SpanId: Id_2,
         Name: aspnet_core.request,
     ...
    

@andrewlock
Copy link
Member

Benchmarks Report 🐌

Benchmarks for #3726 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 759μs 442ns 1.66μs 0.377 0 0 3.22 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 564μs 265ns 1.03μs 0 0 0 2.63 KB
#3726 WriteAndFlushEnrichedTraces net472 755μs 522ns 2.02μs 0.374 0 0 3.22 KB
#3726 WriteAndFlushEnrichedTraces netcoreapp3.1 557μs 482ns 1.81μs 0 0 0 2.62 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 25.7μs 12.7ns 44.1ns 0.276 0 0 1.75 KB
master AllCycleSimpleBody netcoreapp3.1 23μs 129ns 903ns 0.0118 0 0 1.62 KB
master AllCycleMoreComplexBody net472 195μs 652ns 2.53μs 2.03 0 0 13 KB
master AllCycleMoreComplexBody netcoreapp3.1 187μs 247ns 923ns 0.0941 0 0 12.07 KB
master ObjectExtractorSimpleBody net472 296ns 0.334ns 1.29ns 0.0573 0 0 361 B
master ObjectExtractorSimpleBody netcoreapp3.1 233ns 0.0738ns 0.276ns 0.00376 0 0 272 B
master ObjectExtractorMoreComplexBody net472 15.8μs 18.8ns 72.9ns 1.21 0.0158 0 7.62 KB
master ObjectExtractorMoreComplexBody netcoreapp3.1 13.1μs 4.35ns 16.3ns 0.0916 0 0 6.75 KB
#3726 AllCycleSimpleBody net472 25.4μs 132ns 633ns 0.276 0 0 1.75 KB
#3726 AllCycleSimpleBody netcoreapp3.1 24.2μs 59.9ns 232ns 0.0122 0 0 1.62 KB
#3726 AllCycleMoreComplexBody net472 194μs 51.6ns 186ns 2.05 0 0 13 KB
#3726 AllCycleMoreComplexBody netcoreapp3.1 185μs 524ns 2.03μs 0.0907 0 0 12.07 KB
#3726 ObjectExtractorSimpleBody net472 294ns 0.33ns 1.28ns 0.0573 0 0 361 B
#3726 ObjectExtractorSimpleBody netcoreapp3.1 233ns 0.132ns 0.51ns 0.00376 0 0 272 B
#3726 ObjectExtractorMoreComplexBody net472 15.9μs 17.9ns 61.9ns 1.21 0.0158 0 7.62 KB
#3726 ObjectExtractorMoreComplexBody netcoreapp3.1 13.3μs 11.2ns 42ns 0.0929 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 181μs 162ns 629ns 0.271 0 0 20.95 KB
#3726 SendRequest net472 0ns 0ns 0ns 0 0 0 0 b
#3726 SendRequest netcoreapp3.1 181μs 237ns 916ns 0.27 0 0 20.95 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.59μs 0.526ns 2.04ns 0.163 0 0 1.03 KB
master ExecuteNonQuery netcoreapp3.1 1.23μs 0.433ns 1.56ns 0.0141 0 0 1.02 KB
#3726 ExecuteNonQuery net472 1.63μs 0.91ns 3.52ns 0.163 0 0 1.03 KB
#3726 ExecuteNonQuery netcoreapp3.1 1.23μs 2.42ns 9.37ns 0.0136 0 0 1.02 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.21μs 0.658ns 2.37ns 0.196 0 0 1.24 KB
master CallElasticsearch netcoreapp3.1 1.44μs 0.733ns 2.74ns 0.0163 0 0 1.18 KB
master CallElasticsearchAsync net472 2.39μs 4.37ns 15.8ns 0.217 0.00119 0 1.37 KB
master CallElasticsearchAsync netcoreapp3.1 1.43μs 0.625ns 2.34ns 0.0172 0 0 1.3 KB
#3726 CallElasticsearch net472 2.28μs 0.842ns 3.15ns 0.196 0 0 1.24 KB
#3726 CallElasticsearch netcoreapp3.1 1.32μs 0.624ns 2.25ns 0.0159 0 0 1.18 KB
#3726 CallElasticsearchAsync net472 2.43μs 1.13ns 4.24ns 0.218 0.00122 0 1.37 KB
#3726 CallElasticsearchAsync netcoreapp3.1 1.45μs 0.871ns 3.37ns 0.0175 0 0 1.3 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.58μs 1.21ns 4.54ns 0.238 0.00129 0 1.5 KB
master ExecuteAsync netcoreapp3.1 1.56μs 1.57ns 6.07ns 0.0196 0 0 1.42 KB
#3726 ExecuteAsync net472 2.68μs 1.21ns 4.69ns 0.237 0.00135 0 1.5 KB
#3726 ExecuteAsync netcoreapp3.1 1.55μs 3.47ns 13.4ns 0.0194 0 0 1.42 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 7.12μs 2.04ns 7.63ns 0.555 0 0 3.52 KB
master SendAsync netcoreapp3.1 4.51μs 1.33ns 4.96ns 0.0434 0 0 3.21 KB
#3726 SendAsync net472 7.07μs 1.68ns 6.51ns 0.556 0 0 3.52 KB
#3726 SendAsync netcoreapp3.1 4.68μs 2.69ns 10.4ns 0.0421 0 0 3.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 2.7μs 1.62ns 6.06ns 0.302 0 0 1.9 KB
master EnrichedLog netcoreapp3.1 2.09μs 0.727ns 2.72ns 0.0261 0 0 1.93 KB
#3726 EnrichedLog net472 2.64μs 0.742ns 2.78ns 0.301 0 0 1.9 KB
#3726 EnrichedLog netcoreapp3.1 2.07μs 1.87ns 7.25ns 0.0266 0 0 1.93 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 147μs 43.6ns 169ns 0.737 0.221 0 4.74 KB
master EnrichedLog netcoreapp3.1 116μs 59.3ns 214ns 0.058 0 0 4.58 KB
#3726 EnrichedLog net472 146μs 149ns 578ns 0.723 0.217 0 4.74 KB
#3726 EnrichedLog netcoreapp3.1 118μs 204ns 792ns 0.0584 0 0 4.58 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.16μs 1.08ns 3.88ns 0.582 0.00259 0 3.68 KB
master EnrichedLog netcoreapp3.1 3.91μs 2.92ns 10.9ns 0.0546 0 0 4 KB
#3726 EnrichedLog net472 5.13μs 1.66ns 5.99ns 0.584 0.00258 0 3.68 KB
#3726 EnrichedLog netcoreapp3.1 4μs 1.59ns 6.14ns 0.0538 0 0 4 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.04μs 2.12ns 7.92ns 0.23 0.00102 0 1.45 KB
master SendReceive netcoreapp3.1 1.62μs 0.856ns 3.09ns 0.0188 0 0 1.4 KB
#3726 SendReceive net472 2.01μs 1.13ns 4.39ns 0.231 0.001 0 1.45 KB
#3726 SendReceive netcoreapp3.1 1.62μs 0.234ns 0.844ns 0.0186 0 0 1.4 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.49μs 0.94ns 3.52ns 0.367 0 0 2.32 KB
master EnrichedLog netcoreapp3.1 3.94μs 1.21ns 4.53ns 0.0256 0 0 1.89 KB
#3726 EnrichedLog net472 4.47μs 1.22ns 4.39ns 0.368 0 0 2.32 KB
#3726 EnrichedLog netcoreapp3.1 3.79μs 4.76ns 17.8ns 0.0245 0 0 1.89 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 972ns 0.311ns 1.08ns 0.142 0 0 891 B
master StartFinishSpan netcoreapp3.1 809ns 1.35ns 5.05ns 0.0113 0 0 840 B
master StartFinishScope net472 1.19μs 0.37ns 1.34ns 0.154 0 0 971 B
master StartFinishScope netcoreapp3.1 900ns 0.509ns 1.84ns 0.0131 0 0 960 B
#3726 StartFinishSpan net472 963ns 0.484ns 1.88ns 0.141 0 0 891 B
#3726 StartFinishSpan netcoreapp3.1 756ns 0.25ns 0.935ns 0.0113 0 0 840 B
#3726 StartFinishScope net472 1.24μs 0.549ns 2.13ns 0.154 0 0 971 B
#3726 StartFinishScope netcoreapp3.1 854ns 0.28ns 1.05ns 0.0132 0 0 960 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.29μs 0.467ns 1.81ns 0.154 0 0 971 B
master RunOnMethodBegin netcoreapp3.1 983ns 0.375ns 1.45ns 0.0133 0 0 960 B
#3726 RunOnMethodBegin net472 1.4μs 3.06ns 11.8ns 0.154 0 0 971 B
#3726 RunOnMethodBegin netcoreapp3.1 1.05μs 0.364ns 1.36ns 0.0132 0 0 960 B

@andrewlock
Copy link
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).

gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (3726) - mean (3,323ms)  : 3243, 3403
     .   : milestone, 3323,
    master - mean (3,322ms)  : 3276, 3368
     .   : milestone, 3322,

    section CallTarget+Inlining+NGEN
    This PR (3726) - mean (3,326ms)  : 3249, 3402
     .   : milestone, 3326,
    master - mean (3,312ms)  : 3232, 3393
     .   : milestone, 3312,

gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (3726) - mean (3,374ms)  : 3290, 3458
     .   : milestone, 3374,
    master - mean (3,389ms)  : 3270, 3508
     .   : milestone, 3389,

    section CallTarget+Inlining+NGEN
    This PR (3726) - mean (3,369ms)  : 3304, 3434
     .   : milestone, 3369,
    master - mean (3,365ms)  : 3305, 3426
     .   : milestone, 3365,

gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (3726) - mean (3,334ms)  : 3240, 3428
     .   : milestone, 3334,
    master - mean (3,341ms)  : 3283, 3399
     .   : milestone, 3341,

    section CallTarget+Inlining+NGEN
    This PR (3726) - mean (3,337ms)  : 3263, 3411
     .   : milestone, 3337,
    master - mean (3,342ms)  : 3250, 3434
     .   : milestone, 3342,

gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (3726) - mean (198ms)  : 185, 211
     .   : milestone, 198,
    master - mean (202ms)  : 186, 218
     .   : milestone, 202,

    section CallTarget+Inlining+NGEN
    This PR (3726) - mean (201ms)  : 184, 218
     .   : milestone, 201,
    master - mean (200ms)  : 188, 211
     .   : milestone, 200,

gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (3726) - mean (265ms)  : 249, 281
     .   : milestone, 265,
    master - mean (263ms)  : 252, 274
     .   : milestone, 263,

    section CallTarget+Inlining+NGEN
    This PR (3726) - mean (264ms)  : 250, 278
     .   : milestone, 264,
    master - mean (264ms)  : 245, 282
     .   : milestone, 264,

gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (3726) - mean (253ms)  : 239, 267
     .   : milestone, 253,
    master - mean (251ms)  : 241, 261
     .   : milestone, 251,

    section CallTarget+Inlining+NGEN
    This PR (3726) - mean (253ms)  : 244, 261
     .   : milestone, 253,
    master - mean (254ms)  : 243, 266
     .   : milestone, 254,

@andrewlock
Copy link
Member

Throughput/Crank Report:zap:

Throughput results for AspNetCoreSimpleController comparing the following branches/commits:

Cases where throughput results for the PR are worse than latest master (5% drop or greater), results are shown in red.

Note that these results are based on a single point-in-time result for each branch. For full results, see one of the many, many dashboards!

gantt
    title Throughput Linux x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (3726) (6.275M)   : 0, 6274917
    master (6.266M)   : 0, 6266471
    benchmarks/2.22.0 (6.309M)   : 0, 6309377
    benchmarks/2.9.0 (6.101M)   : 0, 6100845

    section Instrumented
    This PR (3726) (4.308M)   : 0, 4308072
    master (4.256M)   : 0, 4255716
    benchmarks/2.22.0 (4.312M)   : 0, 4312460
    benchmarks/2.9.0 (4.186M)   : 0, 4186139

    section Trace stats
    master (4.342M)   : 0, 4342103
    benchmarks/2.22.0 (4.268M)   : 0, 4268056

gantt
    title Throughput Linux arm64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (3726) (5.538M)   : 0, 5538362
    master (5.390M)   : 0, 5390041
    benchmarks/2.22.0 (5.149M)   : 0, 5148985
    benchmarks/2.9.0 (5.187M)   : 0, 5187235

    section Instrumented
    This PR (3726) (3.748M)   : 0, 3748064
    master (3.650M)   : 0, 3649503
    benchmarks/2.22.0 (3.657M)   : 0, 3657398

    section Trace stats
    master (3.566M)   : 0, 3566011
    benchmarks/2.22.0 (3.694M)   : 0, 3693645

gantt
    title Throughput Windows x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (3726) (6.528M)   : 0, 6527695
    master (6.563M)   : 0, 6563374
    benchmarks/2.22.0 (6.565M)   : 0, 6564616
    benchmarks/2.9.0 (6.554M)   : 0, 6553903

    section Instrumented
    This PR (3726) (4.468M)   : 0, 4467954
    master (4.411M)   : 0, 4411415
    benchmarks/2.22.0 (4.394M)   : 0, 4393787
    benchmarks/2.9.0 (4.581M)   : 0, 4581063

    section Trace stats
    master (4.561M)   : 0, 4561203
    benchmarks/2.22.0 (4.412M)   : 0, 4411809

gantt
    title Throughput Linux x64 (ASM) (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (3726) (3.571M)   : 0, 3570989
    master (3.599M)   : 0, 3598835
    benchmarks/2.22.0 (3.602M)   : 0, 3602458
    benchmarks/2.9.0 (3.747M)   : 0, 3747038

    section No attack
    This PR (3726) (1.256M)   : 0, 1255985
    master (1.241M)   : 0, 1241364
    benchmarks/2.22.0 (1.272M)   : 0, 1271742
    benchmarks/2.9.0 (1.274M)   : 0, 1274356

    section Attack
    This PR (3726) (1.075M)   : 0, 1074944
    master (1.060M)   : 0, 1059727
    benchmarks/2.22.0 (1.082M)   : 0, 1081655
    benchmarks/2.9.0 (1.103M)   : 0, 1103325

    section Blocking
    This PR (3726) (2.188M)   : 0, 2188437
    master (2.158M)   : 0, 2157737
    benchmarks/2.22.0 (2.109M)   : 0, 2109348

@andrewlock
Copy link
Member

Code Coverage Report 📊

✔️ Merging #3726 into master will not change line coverage
✔️ Merging #3726 into master will not change branch coverage
✔️ Merging #3726 into master will not change complexity

master #3726 Change
Lines 21889 / 31369 21891 / 31369
Lines % 70% 70% 0% ✔️
Branches 13135 / 20540 13128 / 20540
Branches % 64% 64% 0% ✔️
Complexity 22147 22147 0 ✔️

View the full report for further details:

Datadog.Trace Breakdown ✔️

master #3726 Change
Lines % 70% 70% 0% ✔️
Branches % 64% 64% 0% ✔️
Complexity 22147 22147 0 ✔️

The following classes have significant coverage changes.

File Line coverage change Branch coverage change Complexity change
Datadog.Trace.Ci.GitInfo 6% ✔️ -2% ⚠️ 0 ✔️

View the full reports for further details:

@tonyredondo tonyredondo merged commit 1be0ea2 into master Jan 30, 2023
@tonyredondo tonyredondo deleted the tony/add-retrys-on-coverage-collector branch January 30, 2023 18:30
@github-actions github-actions bot added this to the vNext milestone Jan 30, 2023
@tepatelcmc
Copy link

I am still getting The process can not access the file because it is being used by another process. Is it fixed?

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.

None yet

5 participants