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

Update CI Visibility metrics to latest requirements #5747

Merged
merged 8 commits into from
Jul 4, 2024

Conversation

andrewlock
Copy link
Member

Summary of changes

Updates the common_metrics.json to the latest, and fixes the issues that arise

Reason for change

We have tests to make sure we only send valid metrics. The intake metrics.json has changed and our tests were failing with the latest.

Implementation details

  • src_library has been added to many metrics. We can safely ignore this one, as it's optional, and added by the rust library/sidecar
  • Many CIVisibility metrics have changed as definied in this internal RFC.
    • Note I didn't add the new test_session metric proposed in the RFC. I'll leave that to @tonyredondo once he's back, as it's not blocking us

Test coverage

Unit tests were updated and now pass
Added a "smoke" integration tests for the test_cycle "rq_compressed" tag.

Other details

@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Jun 27, 2024

Datadog Report

Branch report: andrew/fix-metrics
Commit report: b4cc925
Test service: dd-trace-dotnet

✅ 0 Failed, 344111 Passed, 1807 Skipped, 14h 21m 34.91s Total Time

@andrewlock
Copy link
Member Author

andrewlock commented Jun 27, 2024

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 (5747) - mean (71ms)  : 66, 76
     .   : milestone, 71,
    master - mean (70ms)  : 68, 72
     .   : milestone, 70,

    section CallTarget+Inlining+NGEN
    This PR (5747) - mean (1,021ms)  : crit, 999, 1043
     .   : crit, milestone, 1021,
    master - mean (912ms)  : 891, 934
     .   : milestone, 912,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5747) - mean (110ms)  : 107, 113
     .   : milestone, 110,
    master - mean (109ms)  : 107, 112
     .   : milestone, 109,

    section CallTarget+Inlining+NGEN
    This PR (5747) - mean (710ms)  : crit, 684, 737
     .   : crit, milestone, 710,
    master - mean (638ms)  : 620, 656
     .   : milestone, 638,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5747) - mean (94ms)  : 91, 97
     .   : milestone, 94,
    master - mean (93ms)  : 90, 97
     .   : milestone, 93,

    section CallTarget+Inlining+NGEN
    This PR (5747) - mean (665ms)  : crit, 643, 686
     .   : crit, milestone, 665,
    master - mean (590ms)  : 573, 607
     .   : milestone, 590,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5747) - mean (197ms)  : 191, 203
     .   : milestone, 197,
    master - mean (190ms)  : 187, 194
     .   : milestone, 190,

    section CallTarget+Inlining+NGEN
    This PR (5747) - mean (1,127ms)  : crit, 1097, 1157
     .   : crit, milestone, 1127,
    master - mean (1,017ms)  : 983, 1051
     .   : milestone, 1017,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5747) - mean (282ms)  : 274, 289
     .   : milestone, 282,
    master - mean (276ms)  : 271, 280
     .   : milestone, 276,

    section CallTarget+Inlining+NGEN
    This PR (5747) - mean (885ms)  : crit, 858, 912
     .   : crit, milestone, 885,
    master - mean (824ms)  : 791, 857
     .   : milestone, 824,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5747) - mean (272ms)  : 262, 281
     .   : milestone, 272,
    master - mean (265ms)  : 261, 269
     .   : milestone, 265,

    section CallTarget+Inlining+NGEN
    This PR (5747) - mean (883ms)  : crit, 847, 919
     .   : crit, milestone, 883,
    master - mean (809ms)  : 778, 840
     .   : milestone, 809,

Loading

@andrewlock
Copy link
Member Author

andrewlock commented Jun 27, 2024

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 (5747) (11.827M)   : 0, 11827219
    master (11.716M)   : 0, 11716370
    benchmarks/2.9.0 (11.959M)   : 0, 11959218

    section Automatic
    This PR (5747) (7.894M)   : 0, 7894096
    master (8.019M)   : 0, 8019217
    benchmarks/2.9.0 (8.424M)   : 0, 8423539

    section Trace stats
    master (8.211M)   : 0, 8210949

    section Manual
    This PR (5747) (10.076M)   : 0, 10075867
    master (10.165M)   : 0, 10165125

    section Manual + Automatic
    This PR (5747) (7.441M)   : 0, 7441488
    master (7.491M)   : 0, 7491415

    section Version Conflict
    master (6.704M)   : 0, 6704048

Loading
gantt
    title Throughput Linux arm64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5747) (9.537M)   : 0, 9537220
    master (9.678M)   : 0, 9677607
    benchmarks/2.9.0 (9.647M)   : 0, 9646678

    section Automatic
    This PR (5747) (6.609M)   : 0, 6608894
    master (6.494M)   : 0, 6493916

    section Trace stats
    master (6.867M)   : 0, 6866744

    section Manual
    This PR (5747) (8.389M)   : 0, 8389401
    master (8.353M)   : 0, 8353119

    section Manual + Automatic
    This PR (5747) (6.126M)   : 0, 6125628
    master (6.149M)   : 0, 6148874

    section Version Conflict
    master (5.635M)   : 0, 5635422

Loading
gantt
    title Throughput Windows x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5747) (10.267M)   : 0, 10266912
    master (10.277M)   : 0, 10276790
    benchmarks/2.9.0 (10.154M)   : 0, 10153990

    section Automatic
    This PR (5747) (7.224M)   : 0, 7223824
    master (7.193M)   : 0, 7193100
    benchmarks/2.9.0 (7.563M)   : 0, 7562893

    section Trace stats
    master (7.542M)   : 0, 7542132

    section Manual
    This PR (5747) (9.130M)   : 0, 9129986
    master (9.045M)   : 0, 9045425

    section Manual + Automatic
    This PR (5747) (7.046M)   : 0, 7046312
    master (6.963M)   : 0, 6963205

    section Version Conflict
    master (6.250M)   : 0, 6250263

Loading

@andrewlock
Copy link
Member Author

andrewlock commented Jun 27, 2024

Benchmarks Report for tracer 🐌

Benchmarks for #5747 compared to master:

  • 1 benchmarks are faster, with geometric mean 1.186
  • 3 benchmarks are slower, with geometric mean 1.150
  • 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.9ns 327ns 0.0115 0.00383 0 5.43 KB
master StartStopWithChild netcoreapp3.1 10μs 48.3ns 187ns 0.0206 0.0103 0 5.62 KB
master StartStopWithChild net472 16.8μs 46.8ns 181ns 1.04 0.326 0.1 6.07 KB
#5747 StartStopWithChild net6.0 7.72μs 43.4ns 304ns 0.0117 0.0039 0 5.43 KB
#5747 StartStopWithChild netcoreapp3.1 9.67μs 52.6ns 345ns 0.0141 0.0047 0 5.62 KB
#5747 StartStopWithChild net472 16.7μs 34.9ns 131ns 1.03 0.331 0.091 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 487μs 136ns 526ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 660μs 216ns 807ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 819μs 332ns 1.28μs 0.408 0 0 3.3 KB
#5747 WriteAndFlushEnrichedTraces net6.0 465μs 309ns 1.2μs 0 0 0 2.7 KB
#5747 WriteAndFlushEnrichedTraces netcoreapp3.1 633μs 185ns 693ns 0 0 0 2.7 KB
#5747 WriteAndFlushEnrichedTraces net472 818μs 233ns 873ns 0.406 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 170μs 152ns 590ns 0.17 0 0 18.45 KB
master SendRequest netcoreapp3.1 190μs 259ns 1μs 0.189 0 0 20.61 KB
master SendRequest net472 0.000972ns 0.000431ns 0.00161ns 0 0 0 0 b
#5747 SendRequest net6.0 172μs 264ns 1.02μs 0.172 0 0 18.45 KB
#5747 SendRequest netcoreapp3.1 190μs 243ns 940ns 0.188 0 0 20.61 KB
#5747 SendRequest net472 0.000804ns 0.000368ns 0.00142ns 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 548μs 557ns 2.09μs 0.551 0 0 41.55 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 652μs 1.67μs 6.48μs 0.322 0 0 41.73 KB
master WriteAndFlushEnrichedTraces net472 860μs 4.02μs 16.6μs 8.13 2.57 0.428 53.25 KB
#5747 WriteAndFlushEnrichedTraces net6.0 528μs 406ns 1.46μs 0.534 0 0 41.46 KB
#5747 WriteAndFlushEnrichedTraces netcoreapp3.1 633μs 2.25μs 8.72μs 0.326 0 0 41.68 KB
#5747 WriteAndFlushEnrichedTraces net472 873μs 4.32μs 19.3μs 8.13 2.57 0.428 53.28 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.4μs 1.61ns 6.22ns 0.0141 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.71μs 0.937ns 3.63ns 0.0138 0 0 1.02 KB
master ExecuteNonQuery net472 1.95μs 0.588ns 2.04ns 0.157 0 0 987 B
#5747 ExecuteNonQuery net6.0 1.28μs 0.424ns 1.64ns 0.0141 0 0 1.02 KB
#5747 ExecuteNonQuery netcoreapp3.1 1.68μs 0.882ns 3.42ns 0.0135 0 0 1.02 KB
#5747 ExecuteNonQuery net472 1.98μs 1.37ns 5.3ns 0.157 0 0 987 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 net6.0 1.13μs 0.536ns 2.08ns 0.0136 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.54μs 0.888ns 3.32ns 0.0132 0 0 976 B
master CallElasticsearch net472 2.46μs 1.48ns 5.75ns 0.158 0 0 995 B
master CallElasticsearchAsync net6.0 1.34μs 0.937ns 3.51ns 0.0135 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.6μs 1.15ns 4.3ns 0.0136 0 0 1.02 KB
master CallElasticsearchAsync net472 2.62μs 1.93ns 7.49ns 0.167 0 0 1.05 KB
#5747 CallElasticsearch net6.0 1.14μs 0.501ns 1.81ns 0.0137 0 0 976 B
#5747 CallElasticsearch netcoreapp3.1 1.61μs 0.571ns 2.14ns 0.0128 0 0 976 B
#5747 CallElasticsearch net472 2.52μs 1.07ns 4.13ns 0.158 0 0 995 B
#5747 CallElasticsearchAsync net6.0 1.29μs 0.571ns 2.14ns 0.0128 0 0 952 B
#5747 CallElasticsearchAsync netcoreapp3.1 1.56μs 0.811ns 3.03ns 0.0134 0 0 1.02 KB
#5747 CallElasticsearchAsync net472 2.55μs 0.838ns 3.14ns 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.32μs 0.569ns 2.13ns 0.0139 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.66μs 0.939ns 3.51ns 0.0124 0 0 952 B
master ExecuteAsync net472 1.76μs 0.485ns 1.81ns 0.145 0 0 915 B
#5747 ExecuteAsync net6.0 1.29μs 0.693ns 2.59ns 0.013 0 0 952 B
#5747 ExecuteAsync netcoreapp3.1 1.63μs 1.92ns 7.43ns 0.013 0 0 952 B
#5747 ExecuteAsync net472 1.8μs 0.548ns 2.12ns 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.08μs 7.51ns 29.1ns 0.0309 0 0 2.22 KB
master SendAsync netcoreapp3.1 5.11μs 2.48ns 9.59ns 0.0356 0 0 2.76 KB
master SendAsync net472 7.72μs 2.63ns 9.84ns 0.498 0 0 3.15 KB
#5747 SendAsync net6.0 4.2μs 1.71ns 6.39ns 0.0294 0 0 2.22 KB
#5747 SendAsync netcoreapp3.1 5.21μs 10.8ns 38.9ns 0.0361 0 0 2.76 KB
#5747 SendAsync net472 7.53μs 1.87ns 7.24ns 0.497 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.47μs 0.773ns 2.89ns 0.0229 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.41μs 1.52ns 5.69ns 0.0228 0 0 1.64 KB
master EnrichedLog net472 2.57μs 1.49ns 5.75ns 0.249 0 0 1.57 KB
#5747 EnrichedLog net6.0 1.47μs 0.85ns 3.29ns 0.0227 0 0 1.64 KB
#5747 EnrichedLog netcoreapp3.1 2.31μs 1.38ns 5.16ns 0.022 0 0 1.64 KB
#5747 EnrichedLog net472 2.48μs 1.62ns 6.26ns 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 113μs 62.1ns 232ns 0.0563 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 119μs 211ns 817ns 0.0588 0 0 4.28 KB
master EnrichedLog net472 149μs 92ns 356ns 0.659 0.22 0 4.46 KB
#5747 EnrichedLog net6.0 115μs 237ns 918ns 0.0574 0 0 4.28 KB
#5747 EnrichedLog netcoreapp3.1 121μs 149ns 577ns 0.0603 0 0 4.28 KB
#5747 EnrichedLog net472 148μs 148ns 574ns 0.663 0.221 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 2.93μs 0.69ns 2.58ns 0.0307 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.24μs 1.71ns 6.62ns 0.0296 0 0 2.2 KB
master EnrichedLog net472 4.86μs 1.03ns 3.72ns 0.319 0 0 2.02 KB
#5747 EnrichedLog net6.0 3.04μs 1.4ns 5.42ns 0.0306 0 0 2.2 KB
#5747 EnrichedLog netcoreapp3.1 4.22μs 1.1ns 4.26ns 0.0295 0 0 2.2 KB
#5747 EnrichedLog net472 4.77μs 2.33ns 9.03ns 0.318 0 0 2.02 KB
Benchmarks.Trace.RedisBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #5747

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.RedisBenchmark.SendReceive‑net6.0 1.147 1,251.28 1,435.07

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendReceive net6.0 1.25μs 0.552ns 2.14ns 0.0157 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.77μs 1.19ns 4.61ns 0.0151 0 0 1.14 KB
master SendReceive net472 1.98μs 1.27ns 4.92ns 0.183 0 0 1.16 KB
#5747 SendReceive net6.0 1.44μs 0.804ns 3.01ns 0.0158 0 0 1.14 KB
#5747 SendReceive netcoreapp3.1 1.78μs 1.49ns 5.77ns 0.0157 0 0 1.14 KB
#5747 SendReceive net472 2.04μs 0.802ns 3ns 0.183 0 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.68μs 0.699ns 2.71ns 0.0215 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 3.87μs 1.33ns 4.97ns 0.0215 0 0 1.65 KB
master EnrichedLog net472 4.41μs 1.8ns 6.75ns 0.322 0 0 2.04 KB
#5747 EnrichedLog net6.0 2.67μs 1.02ns 3.94ns 0.0226 0 0 1.6 KB
#5747 EnrichedLog netcoreapp3.1 3.95μs 1.39ns 5.2ns 0.0219 0 0 1.65 KB
#5747 EnrichedLog net472 4.34μs 1.51ns 5.85ns 0.322 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #5747

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑netcoreapp3.1 1.159 677.74 785.78

Faster 🎉 in #5747

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑net6.0 1.186 557.63 470.25

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 422ns 0.142ns 0.552ns 0.00815 0 0 576 B
master StartFinishSpan netcoreapp3.1 551ns 0.534ns 1.92ns 0.008 0 0 576 B
master StartFinishSpan net472 660ns 0.365ns 1.41ns 0.0916 0 0 578 B
master StartFinishScope net6.0 557ns 0.354ns 1.37ns 0.00966 0 0 696 B
master StartFinishScope netcoreapp3.1 678ns 0.22ns 0.794ns 0.00934 0 0 696 B
master StartFinishScope net472 833ns 0.142ns 0.514ns 0.104 0 0 658 B
#5747 StartFinishSpan net6.0 406ns 0.111ns 0.43ns 0.00816 0 0 576 B
#5747 StartFinishSpan netcoreapp3.1 613ns 0.237ns 0.886ns 0.00768 0 0 576 B
#5747 StartFinishSpan net472 696ns 0.607ns 2.35ns 0.0916 0 0 578 B
#5747 StartFinishScope net6.0 470ns 0.11ns 0.427ns 0.00968 0 0 696 B
#5747 StartFinishScope netcoreapp3.1 785ns 0.4ns 1.55ns 0.00945 0 0 696 B
#5747 StartFinishScope net472 903ns 0.594ns 2.06ns 0.104 0 0 658 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #5747

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑net6.0 1.143 647.45 739.77

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net6.0 647ns 0.27ns 1.04ns 0.00973 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 906ns 0.54ns 2.09ns 0.00952 0 0 696 B
master RunOnMethodBegin net472 1.11μs 0.516ns 1.93ns 0.104 0 0 658 B
#5747 RunOnMethodBegin net6.0 740ns 0.258ns 0.999ns 0.00963 0 0 696 B
#5747 RunOnMethodBegin netcoreapp3.1 947ns 0.319ns 1.19ns 0.0091 0 0 696 B
#5747 RunOnMethodBegin net472 1.11μs 0.371ns 1.44ns 0.104 0 0 658 B

Copy link

@nikita-tkachenko-datadog nikita-tkachenko-datadog left a comment

Choose a reason for hiding this comment

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

I could not find the test_session metric and the exit_code:missing tag for the Git command. Are they outside the scope of this PR?

@andrewlock
Copy link
Member Author

andrewlock commented Jul 1, 2024

I could not find the test_session metric and the exit_code:missing tag for the Git command. Are they outside the scope of this PR?

The test_session metric is outside the scope of this PR, but the exit_code:missing is an oversight, thanks! Addresed in d7f86cc

@andrewlock andrewlock force-pushed the andrew/fix-metrics branch 2 times, most recently from 596eb13 to c04c62c Compare July 2, 2024 15:17
andrewlock added a commit that referenced this pull request Jul 3, 2024
## Summary of changes

- The `IApiResponse.ContentEncoding` property was confusing and
incorrectly implemented
- Refactored as `GetCharsetEncoding()`
- Added `GetContentEncodingType`

## Reason for change

The `ContentEncoding` property was meant to return [the `charset`
associated with a
`Content-type`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type#charset)
i.e. the `charset=utf-8` part of `text/plain;charset=utf-8`, converted
into a .NET `Encoding` object. However, there's also [a
`ContentEncoding`
_header_](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding)
which defines whether the content is encoded with a compression
algorithm, e.g. gzip/brotli etc.

This PR aims to fix the bug, clear up the confusion by renaming, add
some unit tests, and make the behaviour consistent across our various
`IApiResponse` implementations.

## Implementation details

- Expose `ContentTypeHeader` and `ContentEncodingHeader` as values on
the `IApiResponse`.
- This is necessary because you _can't_ necessarily get these values
directly from `GetHeaders` in some cases (e.g. `HttpClient`)
- Rename `ContentEncoding` to `GetCharsetEncoding()`
- Made it a method so we don't bother processing the header until we
need it. In most cases we never use it (and use it at most once)
- Re-used the optimized implementation we were using in `HttpMessage`
where possible. Tweaked it slightly to always return UTF-8 by default
(as our calling code wasn't resistant to it anyway and would have
thrown)
- Made it fallback to "any" charset, as was previously _always_
happening for `HttpClientResponse`
- Add `GetContentEncodingType()` which returns an enum of compression
values
- We don't currently use this, but I could do with it in
#5747

## Test coverage

Added unit tests for the parsing logic used for decoding the `charset`
and the content-encoding

## Other details
I initially based this on
#5658 but ultimately
changed a lot (and we still don't need that mime-type handling yet)

<!-- ⚠️ 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. -->
@andrewlock andrewlock merged commit 6d24c7d into master Jul 4, 2024
55 of 57 checks passed
@andrewlock andrewlock deleted the andrew/fix-metrics branch July 4, 2024 08:48
@github-actions github-actions bot added this to the vNext-v2 milestone Jul 4, 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.

None yet

3 participants