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

Tiny cleanup of static Tracer instance usages #4936

Merged
merged 4 commits into from
Nov 30, 2023

Conversation

andrewlock
Copy link
Member

Summary of changes

  • Use the static Tracer instance associated with a span in OtelHelpers
  • Create some "internal" versions of methods that we need for the initial implementation of v3

Reason for change

While tracking down flakiness in a manual instrumentation sample I'm working on, I noticed that we're accessing the global tracer version. Technically that may have different settings than the tracer used to create the span, and we should use that instead AFAIK.

The "internal" methods are just to make it easier to incrementally work on the v3-public-api changes. Moving those changes here will reduce the footprint of the v3 PRs when they land.

Implementation details

We expose the tracer instance that created the span at Span.Context.TracerContext.Tracer.

The other changes are just creating "internal" versions of methods

Test coverage

Should be covered by existing.

Other details

@andrewlock andrewlock added area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) type:cleanup Minor code clean up labels Nov 29, 2023
@andrewlock andrewlock requested a review from a team as a code owner November 29, 2023 12:03
@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Nov 29, 2023

Datadog Report

Branch report: andrew/nit-static-tracer
Commit report: ece6aa1

dd-trace-dotnet: 0 Failed, 0 New Flaky, 302032 Passed, 952 Skipped, 30m 58.23s Wall Time

@andrewlock
Copy link
Member Author

andrewlock commented Nov 29, 2023

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 (4936) - mean (68ms)  : 64, 73
     .   : milestone, 68,
    master - mean (69ms)  : 61, 77
     .   : milestone, 69,

    section CallTarget+Inlining+NGEN
    This PR (4936) - mean (1,005ms)  : 983, 1026
     .   : milestone, 1005,
    master - mean (1,003ms)  : 978, 1028
     .   : milestone, 1003,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (4936) - mean (106ms)  : 103, 109
     .   : milestone, 106,
    master - mean (106ms)  : 103, 109
     .   : milestone, 106,

    section CallTarget+Inlining+NGEN
    This PR (4936) - mean (689ms)  : 674, 704
     .   : milestone, 689,
    master - mean (685ms)  : 667, 703
     .   : milestone, 685,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (4936) - mean (90ms)  : 88, 92
     .   : milestone, 90,
    master - mean (90ms)  : 86, 94
     .   : milestone, 90,

    section CallTarget+Inlining+NGEN
    This PR (4936) - mean (663ms)  : 639, 686
     .   : milestone, 663,
    master - mean (659ms)  : 635, 682
     .   : milestone, 659,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (4936) - mean (189ms)  : 185, 193
     .   : milestone, 189,
    master - mean (189ms)  : 186, 191
     .   : milestone, 189,

    section CallTarget+Inlining+NGEN
    This PR (4936) - mean (1,132ms)  : 1112, 1153
     .   : milestone, 1132,
    master - mean (1,132ms)  : 1111, 1153
     .   : milestone, 1132,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (4936) - mean (273ms)  : 269, 277
     .   : milestone, 273,
    master - mean (272ms)  : 269, 275
     .   : milestone, 272,

    section CallTarget+Inlining+NGEN
    This PR (4936) - mean (1,096ms)  : 1075, 1116
     .   : milestone, 1096,
    master - mean (1,094ms)  : 1069, 1119
     .   : milestone, 1094,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (4936) - mean (262ms)  : 257, 267
     .   : milestone, 262,
    master - mean (262ms)  : 259, 265
     .   : milestone, 262,

    section CallTarget+Inlining+NGEN
    This PR (4936) - mean (1,059ms)  : 1035, 1082
     .   : milestone, 1059,
    master - mean (1,061ms)  : 1031, 1091
     .   : milestone, 1061,

Loading

Copy link
Contributor

@bouwkast bouwkast left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@andrewlock
Copy link
Member Author

andrewlock commented Nov 29, 2023

Benchmarks Report 🐌

Benchmarks for #4936 compared to master:

  • All benchmarks have the same speed
  • 1 benchmarks have fewer allocations
  • 1 benchmarks have more 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 8.51μs 47.4ns 284ns 0.0216 0.00862 0 7.48 KB
master StartStopWithChild netcoreapp3.1 10.9μs 59.3ns 346ns 0.0277 0.0111 0 7.58 KB
master StartStopWithChild net472 16.9μs 58.7ns 227ns 1.33 0.338 0.11 7.96 KB
#4936 StartStopWithChild net6.0 8.58μs 46.8ns 281ns 0.0255 0.0128 0 7.48 KB
#4936 StartStopWithChild netcoreapp3.1 10.6μs 58.2ns 334ns 0.0258 0.0103 0 7.58 KB
#4936 StartStopWithChild net472 17.1μs 65.9ns 255ns 1.33 0.332 0.111 7.96 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 467μs 207ns 774ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 665μs 1.34μs 5.19μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 773μs 388ns 1.34μs 0.386 0 0 3.3 KB
#4936 WriteAndFlushEnrichedTraces net6.0 454μs 103ns 385ns 0 0 0 2.7 KB
#4936 WriteAndFlushEnrichedTraces netcoreapp3.1 628μs 197ns 763ns 0 0 0 2.7 KB
#4936 WriteAndFlushEnrichedTraces net472 785μs 226ns 815ns 0.393 0 0 3.3 KB
Benchmarks.Trace.Asm.AppSecBodyBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master AllCycleSimpleBody net6.0 43.6μs 37.4ns 140ns 0.0217 0 0 1.77 KB
master AllCycleSimpleBody netcoreapp3.1 47.4μs 57.3ns 222ns 0.0237 0 0 1.74 KB
master AllCycleSimpleBody net472 48.4μs 22ns 76.1ns 0.288 0 0 1.81 KB
master AllCycleMoreComplexBody net6.0 214μs 378ns 1.46μs 0.107 0 0 9.25 KB
master AllCycleMoreComplexBody netcoreapp3.1 224μs 229ns 888ns 0.112 0 0 9.14 KB
master AllCycleMoreComplexBody net472 239μs 444ns 1.66μs 1.42 0 0 9.32 KB
master ObjectExtractorSimpleBody net6.0 133ns 0.057ns 0.213ns 0.00397 0 0 280 B
master ObjectExtractorSimpleBody netcoreapp3.1 180ns 0.277ns 1.07ns 0.00371 0 0 272 B
master ObjectExtractorSimpleBody net472 152ns 0.0716ns 0.268ns 0.0446 0 0 281 B
master ObjectExtractorMoreComplexBody net6.0 2.86μs 1.39ns 5.37ns 0.0527 0 0 3.78 KB
master ObjectExtractorMoreComplexBody netcoreapp3.1 3.62μs 1.75ns 6.78ns 0.0508 0 0 3.69 KB
master ObjectExtractorMoreComplexBody net472 3.42μs 1.77ns 6.86ns 0.602 0.00515 0 3.8 KB
#4936 AllCycleSimpleBody net6.0 44.9μs 20.3ns 78.5ns 0.0226 0 0 1.77 KB
#4936 AllCycleSimpleBody netcoreapp3.1 45.9μs 43.9ns 170ns 0.0231 0 0 1.74 KB
#4936 AllCycleSimpleBody net472 49.1μs 99.9ns 458ns 0.267 0 0 1.81 KB
#4936 AllCycleMoreComplexBody net6.0 214μs 50.6ns 182ns 0.106 0 0 9.25 KB
#4936 AllCycleMoreComplexBody netcoreapp3.1 226μs 264ns 2.21μs 0.112 0 0 9.14 KB
#4936 AllCycleMoreComplexBody net472 238μs 67.3ns 261ns 1.42 0 0 9.32 KB
#4936 ObjectExtractorSimpleBody net6.0 129ns 0.0445ns 0.154ns 0.00397 0 0 280 B
#4936 ObjectExtractorSimpleBody netcoreapp3.1 189ns 0.126ns 0.489ns 0.0037 0 0 272 B
#4936 ObjectExtractorSimpleBody net472 151ns 0.0778ns 0.291ns 0.0446 0 0 281 B
#4936 ObjectExtractorMoreComplexBody net6.0 2.77μs 0.669ns 2.59ns 0.0526 0 0 3.78 KB
#4936 ObjectExtractorMoreComplexBody netcoreapp3.1 3.77μs 1.2ns 4.65ns 0.0508 0 0 3.69 KB
#4936 ObjectExtractorMoreComplexBody net472 3.42μs 2.28ns 8.82ns 0.603 0.00511 0 3.8 KB
Benchmarks.Trace.Asm.AppSecWafBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunWaf(args=NestedMap (10)) net6.0 51.5μs 291ns 2.06μs 0.216 0 0 16.06 KB
master RunWaf(args=NestedMap (10)) netcoreapp3.1 70.3μs 86.6ns 324ns 0.21 0 0 16.06 KB
master RunWaf(args=NestedMap (10)) net472 93.1μs 37.4ns 145ns 2.52 0.0933 0 16.14 KB
master RunWafWithAttack(args=Neste(...)tack) [22]) net6.0 120μs 659ns 3.73μs 0.286 0 0 22.41 KB
master RunWafWithAttack(args=Neste(...)tack) [22]) netcoreapp3.1 137μs 443ns 1.77μs 0.271 0 0 22.36 KB
master RunWafWithAttack(args=Neste(...)tack) [22]) net472 169μs 222ns 861ns 3.58 0.167 0 22.7 KB
master RunWaf(args=NestedMap (100)) net6.0 100μs 574ns 4.33μs 0.464 0 0 32.76 KB
master RunWaf(args=NestedMap (100)) netcoreapp3.1 134μs 713ns 3.56μs 0.44 0 0 33.33 KB
master RunWaf(args=NestedMap (100)) net472 188μs 561ns 2.17μs 5.28 0.364 0 33.67 KB
master RunWafWithAttack(args=Neste(...)tack) [23]) net6.0 169μs 824ns 3.59μs 0.52 0 0 39.1 KB
master RunWafWithAttack(args=Neste(...)tack) [23]) netcoreapp3.1 209μs 1.17μs 7.49μs 0.506 0 0 39.63 KB
master RunWafWithAttack(args=Neste(...)tack) [23]) net472 264μs 1.43μs 7.68μs 6.33 0.517 0 40.23 KB
master RunWaf(args=NestedMap (20)) net6.0 103μs 485ns 1.94μs 0.43 0 0 32.18 KB
master RunWaf(args=NestedMap (20)) netcoreapp3.1 131μs 678ns 3.25μs 0.401 0 0 32.3 KB
master RunWaf(args=NestedMap (20)) net472 186μs 462ns 1.79μs 5.18 0.363 0 32.63 KB
master RunWafWithAttack(args=Neste(...)tack) [22]) net6.0 173μs 462ns 1.79μs 0.512 0 0 38.53 KB
master RunWafWithAttack(args=Neste(...)tack) [22]) netcoreapp3.1 207μs 391ns 1.52μs 0.507 0 0 38.6 KB
master RunWafWithAttack(args=Neste(...)tack) [22]) net472 267μs 166ns 643ns 6.11 0.39 0 39.2 KB
#4936 RunWaf(args=NestedMap (10)) net6.0 53.6μs 293ns 1.68μs 0.219 0 0 16.06 KB
#4936 RunWaf(args=NestedMap (10)) netcoreapp3.1 69.5μs 227ns 879ns 0.193 0 0 16.06 KB
#4936 RunWaf(args=NestedMap (10)) net472 97μs 486ns 2.23μs 2.55 0.0946 0 16.14 KB
#4936 RunWafWithAttack(args=Neste(...)tack) [22]) net6.0 115μs 182ns 707ns 0.286 0 0 22.41 KB
#4936 RunWafWithAttack(args=Neste(...)tack) [22]) netcoreapp3.1 136μs 710ns 3.33μs 0.265 0 0 22.36 KB
#4936 RunWafWithAttack(args=Neste(...)tack) [22]) net472 165μs 72.9ns 263ns 3.6 0.164 0 22.7 KB
#4936 RunWaf(args=NestedMap (100)) net6.0 104μs 86.5ns 335ns 0.463 0 0 32.76 KB
#4936 RunWaf(args=NestedMap (100)) netcoreapp3.1 133μs 167ns 645ns 0.439 0 0 33.33 KB
#4936 RunWaf(args=NestedMap (100)) net472 187μs 736ns 2.66μs 5.32 0.367 0 33.67 KB
#4936 RunWafWithAttack(args=Neste(...)tack) [23]) net6.0 167μs 774ns 3μs 0.579 0 0 39.1 KB
#4936 RunWafWithAttack(args=Neste(...)tack) [23]) netcoreapp3.1 204μs 923ns 4.79μs 0.517 0 0 39.63 KB
#4936 RunWafWithAttack(args=Neste(...)tack) [23]) net472 258μs 145ns 562ns 6.3 0.514 0 40.23 KB
#4936 RunWaf(args=NestedMap (20)) net6.0 104μs 580ns 3.76μs 0.423 0 0 32.18 KB
#4936 RunWaf(args=NestedMap (20)) netcoreapp3.1 128μs 680ns 3.47μs 0.391 0 0 32.3 KB
#4936 RunWaf(args=NestedMap (20)) net472 187μs 71.7ns 268ns 5.17 0.363 0 32.63 KB
#4936 RunWafWithAttack(args=Neste(...)tack) [22]) net6.0 171μs 50.7ns 190ns 0.516 0 0 38.53 KB
#4936 RunWafWithAttack(args=Neste(...)tack) [22]) netcoreapp3.1 205μs 1.11μs 5.75μs 0.497 0 0 38.6 KB
#4936 RunWafWithAttack(args=Neste(...)tack) [22]) net472 258μs 130ns 504ns 6.17 0.514 0 39.2 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 173μs 141ns 526ns 0.258 0 0 18.25 KB
master SendRequest netcoreapp3.1 190μs 413ns 1.6μs 0.189 0 0 20.41 KB
master SendRequest net472 0.000221ns 0.00016ns 0.000577ns 0 0 0 0 b
#4936 SendRequest net6.0 173μs 149ns 577ns 0.258 0 0 18.25 KB
#4936 SendRequest netcoreapp3.1 193μs 332ns 1.28μs 0.191 0 0 20.41 KB
#4936 SendRequest net472 5.56E‑05ns 5.33E‑05ns 0.000207ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Fewer allocations 🎉

Fewer allocations 🎉 in #4936

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net6.0 41.89 KB 41.51 KB -378 B -0.90%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 571μs 1.72μs 6.68μs 0.566 0 0 41.89 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 652μs 665ns 2.49μs 0.332 0 0 41.72 KB
master WriteAndFlushEnrichedTraces net472 818μs 3.07μs 11.9μs 8.22 2.47 0.411 53.25 KB
#4936 WriteAndFlushEnrichedTraces net6.0 545μs 230ns 862ns 0.607 0 0 41.51 KB
#4936 WriteAndFlushEnrichedTraces netcoreapp3.1 655μs 359ns 1.29μs 0.329 0 0 41.82 KB
#4936 WriteAndFlushEnrichedTraces net472 827μs 2.63μs 9.84μs 8.28 2.48 0.414 53.26 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.16μs 0.586ns 2.27ns 0.0104 0 0 768 B
master ExecuteNonQuery netcoreapp3.1 1.45μs 0.879ns 3.4ns 0.0103 0 0 768 B
master ExecuteNonQuery net472 1.72μs 3.4ns 13.2ns 0.116 0 0 730 B
#4936 ExecuteNonQuery net6.0 1.2μs 0.592ns 2.29ns 0.0108 0 0 768 B
#4936 ExecuteNonQuery netcoreapp3.1 1.41μs 0.703ns 2.72ns 0.0106 0 0 768 B
#4936 ExecuteNonQuery net472 1.79μs 1.02ns 3.95ns 0.115 0 0 730 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.626ns 2.34ns 0.0133 0 0 936 B
master CallElasticsearch netcoreapp3.1 1.52μs 0.877ns 3.28ns 0.0128 0 0 936 B
master CallElasticsearch net472 2.46μs 0.945ns 3.66ns 0.152 0 0 955 B
master CallElasticsearchAsync net6.0 1.23μs 0.438ns 1.69ns 0.0123 0 0 912 B
master CallElasticsearchAsync netcoreapp3.1 1.64μs 0.594ns 2.22ns 0.0131 0 0 984 B
master CallElasticsearchAsync net472 2.47μs 1.14ns 4.43ns 0.16 0 0 1.01 KB
#4936 CallElasticsearch net6.0 1.22μs 0.511ns 1.98ns 0.0134 0 0 936 B
#4936 CallElasticsearch netcoreapp3.1 1.52μs 1.35ns 5.04ns 0.0122 0 0 936 B
#4936 CallElasticsearch net472 2.57μs 0.721ns 2.7ns 0.151 0 0 955 B
#4936 CallElasticsearchAsync net6.0 1.27μs 0.742ns 2.57ns 0.0127 0 0 912 B
#4936 CallElasticsearchAsync netcoreapp3.1 1.6μs 0.957ns 3.32ns 0.0129 0 0 984 B
#4936 CallElasticsearchAsync net472 2.57μs 0.596ns 2.23ns 0.16 0 0 1.01 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.765ns 2.86ns 0.0125 0 0 912 B
master ExecuteAsync netcoreapp3.1 1.64μs 0.729ns 2.73ns 0.0123 0 0 912 B
master ExecuteAsync net472 1.81μs 1.71ns 6.61ns 0.138 0 0 875 B
#4936 ExecuteAsync net6.0 1.24μs 0.904ns 3.38ns 0.0124 0 0 912 B
#4936 ExecuteAsync netcoreapp3.1 1.58μs 0.628ns 2.43ns 0.0126 0 0 912 B
#4936 ExecuteAsync net472 1.79μs 1.74ns 6.74ns 0.139 0 0 875 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.12μs 1.2ns 4.65ns 0.0288 0 0 2.1 KB
master SendAsync netcoreapp3.1 4.93μs 1.18ns 4.24ns 0.0345 0 0 2.63 KB
master SendAsync net472 7.68μs 2.02ns 7.83ns 0.522 0 0 3.31 KB
#4936 SendAsync net6.0 4.15μs 12.1ns 45.2ns 0.0285 0 0 2.1 KB
#4936 SendAsync netcoreapp3.1 4.99μs 1.85ns 7.17ns 0.0349 0 0 2.63 KB
#4936 SendAsync net472 7.77μs 2.6ns 10.1ns 0.525 0 0 3.31 KB
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #4936

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark(parameters: System.Collections.Generic.List`1[System.String])‑net472 58.26 KB 59.7 KB 1.43 KB 2.46%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StringConcatBenchmark(parameters=Syste(...)ring] [48]) net6.0 60.3μs 770ns 7.63μs 0 0 0 43.44 KB
master StringConcatBenchmark(parameters=Syste(...)ring] [48]) netcoreapp3.1 53.2μs 119ns 461ns 0 0 0 42.64 KB
master StringConcatBenchmark(parameters=Syste(...)ring] [48]) net472 37.8μs 97.8ns 366ns 0 0 0 58.26 KB
master StringConcatAspectBenchmark(parameters=Syste(...)ring] [48]) net6.0 98.8μs 2.72μs 27.2μs 0 0 0 43.29 KB
master StringConcatAspectBenchmark(parameters=Syste(...)ring] [48]) netcoreapp3.1 97.1μs 2.8μs 28μs 0 0 0 42.64 KB
master StringConcatAspectBenchmark(parameters=Syste(...)ring] [48]) net472 61.9μs 284ns 1.06μs 0 0 0 57.34 KB
#4936 StringConcatBenchmark(parameters=Syste(...)ring] [48]) net6.0 60.8μs 827ns 8.1μs 0 0 0 43.44 KB
#4936 StringConcatBenchmark(parameters=Syste(...)ring] [48]) netcoreapp3.1 53.5μs 236ns 1.11μs 0 0 0 42.64 KB
#4936 StringConcatBenchmark(parameters=Syste(...)ring] [48]) net472 37.4μs 90.9ns 340ns 0 0 0 59.7 KB
#4936 StringConcatAspectBenchmark(parameters=Syste(...)ring] [48]) net6.0 81.4μs 2.77μs 27.7μs 0 0 0 43.29 KB
#4936 StringConcatAspectBenchmark(parameters=Syste(...)ring] [48]) netcoreapp3.1 103μs 3.54μs 35.1μs 0 0 0 42.64 KB
#4936 StringConcatAspectBenchmark(parameters=Syste(...)ring] [48]) net472 62.7μs 308ns 1.31μs 0 0 0 57.34 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.682ns 2.55ns 0.0218 0 0 1.57 KB
master EnrichedLog netcoreapp3.1 2.15μs 0.695ns 2.41ns 0.0215 0 0 1.57 KB
master EnrichedLog net472 2.54μs 2.87ns 11.1ns 0.238 0 0 1.5 KB
#4936 EnrichedLog net6.0 1.4μs 0.397ns 1.43ns 0.0222 0 0 1.57 KB
#4936 EnrichedLog netcoreapp3.1 2.17μs 0.969ns 3.63ns 0.0217 0 0 1.57 KB
#4936 EnrichedLog net472 2.48μs 2.03ns 7.87ns 0.237 0 0 1.5 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 165ns 638ns 0.0564 0 0 4.21 KB
master EnrichedLog netcoreapp3.1 119μs 314ns 1.22μs 0.0597 0 0 4.21 KB
master EnrichedLog net472 148μs 146ns 564ns 0.667 0.222 0 4.39 KB
#4936 EnrichedLog net6.0 114μs 152ns 587ns 0.0564 0 0 4.21 KB
#4936 EnrichedLog netcoreapp3.1 120μs 144ns 540ns 0.0598 0 0 4.21 KB
#4936 EnrichedLog net472 146μs 102ns 383ns 0.66 0.22 0 4.39 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.1μs 1.45ns 5.42ns 0.0288 0 0 2.13 KB
master EnrichedLog netcoreapp3.1 4.22μs 3.68ns 14.3ns 0.0278 0 0 2.13 KB
master EnrichedLog net472 4.84μs 4.21ns 16.3ns 0.307 0 0 1.95 KB
#4936 EnrichedLog net6.0 3.05μs 1.3ns 4.88ns 0.0289 0 0 2.13 KB
#4936 EnrichedLog netcoreapp3.1 4.2μs 2.61ns 10.1ns 0.0291 0 0 2.13 KB
#4936 EnrichedLog net472 4.81μs 5.57ns 21.6ns 0.308 0 0 1.95 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.903ns 3.38ns 0.0154 0 0 1.1 KB
master SendReceive netcoreapp3.1 1.74μs 1.13ns 4.37ns 0.0151 0 0 1.1 KB
master SendReceive net472 2.13μs 1.61ns 6.25ns 0.176 0 0 1.12 KB
#4936 SendReceive net6.0 1.38μs 1.23ns 4.77ns 0.0151 0 0 1.1 KB
#4936 SendReceive netcoreapp3.1 1.73μs 0.911ns 3.41ns 0.0147 0 0 1.1 KB
#4936 SendReceive net472 2.07μs 0.96ns 3.72ns 0.177 0 0 1.12 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.81μs 0.717ns 2.68ns 0.0211 0 0 1.53 KB
master EnrichedLog netcoreapp3.1 4.03μs 1.66ns 6.45ns 0.0201 0 0 1.58 KB
master EnrichedLog net472 4.3μs 1.22ns 4.71ns 0.31 0 0 1.97 KB
#4936 EnrichedLog net6.0 2.83μs 0.871ns 3.26ns 0.0212 0 0 1.53 KB
#4936 EnrichedLog netcoreapp3.1 3.83μs 2.05ns 7.68ns 0.021 0 0 1.58 KB
#4936 EnrichedLog net472 4.47μs 1.8ns 6.99ns 0.311 0 0 1.97 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 net6.0 521ns 0.186ns 0.719ns 0.00741 0 0 536 B
master StartFinishSpan netcoreapp3.1 719ns 0.251ns 0.938ns 0.00731 0 0 536 B
master StartFinishSpan net472 722ns 0.417ns 1.61ns 0.0851 0 0 538 B
master StartFinishScope net6.0 564ns 0.258ns 1ns 0.00917 0 0 656 B
master StartFinishScope netcoreapp3.1 862ns 0.453ns 1.75ns 0.00895 0 0 656 B
master StartFinishScope net472 926ns 0.374ns 1.4ns 0.0981 0 0 618 B
#4936 StartFinishSpan net6.0 503ns 0.141ns 0.508ns 0.0076 0 0 536 B
#4936 StartFinishSpan netcoreapp3.1 679ns 0.35ns 1.31ns 0.00725 0 0 536 B
#4936 StartFinishSpan net472 797ns 0.181ns 0.703ns 0.0851 0 0 538 B
#4936 StartFinishScope net6.0 585ns 0.204ns 0.79ns 0.00908 0 0 656 B
#4936 StartFinishScope netcoreapp3.1 908ns 1.1ns 4.25ns 0.00888 0 0 656 B
#4936 StartFinishScope net472 968ns 0.429ns 1.66ns 0.098 0 0 618 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 667ns 0.276ns 1.03ns 0.00902 0 0 656 B
master RunOnMethodBegin netcoreapp3.1 978ns 0.274ns 1.06ns 0.00902 0 0 656 B
master RunOnMethodBegin net472 1.1μs 0.419ns 1.57ns 0.098 0 0 618 B
#4936 RunOnMethodBegin net6.0 622ns 0.17ns 0.638ns 0.00937 0 0 656 B
#4936 RunOnMethodBegin netcoreapp3.1 979ns 0.371ns 1.44ns 0.00884 0 0 656 B
#4936 RunOnMethodBegin net472 1.11μs 0.449ns 1.74ns 0.0976 0 0 618 B

@andrewlock
Copy link
Member Author

andrewlock commented Nov 29, 2023

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 (4936) (10.832M)   : 0, 10832114
    master (11.077M)   : 0, 11077020
    benchmarks/2.9.0 (11.143M)   : 0, 11142820

    section Automatic
    This PR (4936) (7.555M)   : 0, 7555307
    master (7.716M)   : 0, 7715976
    benchmarks/2.9.0 (8.193M)   : 0, 8192573

    section Trace stats
    This PR (4936) (7.843M)   : 0, 7843349
    master (8.166M)   : 0, 8165739

    section Manual
    This PR (4936) (9.258M)   : crit ,0, 9257558
    master (10.081M)   : 0, 10081357

    section Manual + Automatic
    This PR (4936) (6.894M)   : crit ,0, 6894107
    master (7.302M)   : 0, 7302104

    section Version Conflict
    This PR (4936) (6.034M)   : crit ,0, 6034348
    master (6.485M)   : 0, 6484599

Loading
gantt
    title Throughput Linux arm64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (4936) (9.339M)   : 0, 9339328
    master (9.329M)   : 0, 9328988
    benchmarks/2.9.0 (9.251M)   : 0, 9251121

    section Automatic
    This PR (4936) (6.596M)   : 0, 6596129
    master (6.570M)   : 0, 6569593

    section Trace stats
    This PR (4936) (6.851M)   : 0, 6850642
    master (6.706M)   : 0, 6705822

    section Manual
    This PR (4936) (8.189M)   : 0, 8189067
    master (8.346M)   : 0, 8345824

    section Manual + Automatic
    This PR (4936) (6.030M)   : 0, 6030130
    master (6.092M)   : 0, 6092428

    section Version Conflict
    This PR (4936) (5.708M)   : 0, 5708348
    master (5.758M)   : 0, 5757731

Loading
gantt
    title Throughput Windows x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (4936) (10.885M)   : 0, 10884606
    master (10.683M)   : 0, 10683420
    benchmarks/2.9.0 (10.246M)   : 0, 10245668

    section Automatic
    This PR (4936) (7.451M)   : 0, 7451206
    master (7.444M)   : 0, 7444053
    benchmarks/2.9.0 (7.548M)   : 0, 7548392

    section Trace stats
    This PR (4936) (7.745M)   : 0, 7745004
    master (7.807M)   : 0, 7806630

    section Manual
    This PR (4936) (9.589M)   : 0, 9588509
    master (9.421M)   : 0, 9420919

    section Manual + Automatic
    This PR (4936) (7.219M)   : 0, 7219202
    master (7.146M)   : 0, 7146261

    section Version Conflict
    This PR (4936) (6.449M)   : 0, 6449464
    master (6.484M)   : 0, 6484232

Loading
gantt
    title Throughput Linux x64 (ASM) (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    master (7.443M)   : 0, 7443080
    benchmarks/2.9.0 (7.835M)   : 0, 7834773

    section No attack
    master (2.004M)   : 0, 2004124
    benchmarks/2.9.0 (3.220M)   : 0, 3219927

    section Attack
    master (1.575M)   : 0, 1575145
    benchmarks/2.9.0 (2.545M)   : 0, 2545308

    section Blocking
    master (3.284M)   : 0, 3284355

    section IAST default
    master (6.444M)   : 0, 6444298

    section IAST full
    master (5.750M)   : 0, 5750291

    section Base vuln
    master (0.967M)   : 0, 967013

    section IAST vuln
    master (0.830M)   : 0, 830046

Loading

@@ -61,8 +59,10 @@ private static void AgentConvertSpan<TInner>(TInner activity, Span span)
}

// Fixup "version" tag
if (Tracer.Instance.Settings.ServiceVersionInternal is null
Copy link
Member

Choose a reason for hiding this comment

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

Good catch.

@@ -38,6 +38,11 @@ public static class SpanExtensions
public static void SetTraceSamplingPriority(this ISpan span, SamplingPriority samplingPriority)
{
TelemetryFactory.Metrics.Record(PublicApiUsage.SpanExtensions_SetTraceSamplingPriority);
SetTraceSamplingPriorityInternal(span, samplingPriority);
Copy link
Member

Choose a reason for hiding this comment

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

fwiw, I think longer term we should move away from using the SamplingPriority enum or even numeric values (-1, 0, 1, 2) in the public API. From a user's perspective, it should be a Boolean keep/drop. Internally, we already use int everywhere instead of SamplingPriority.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good to me! v3? 😄

@andrewlock andrewlock merged commit 0ff5c74 into master Nov 30, 2023
54 checks passed
@andrewlock andrewlock deleted the andrew/nit-static-tracer branch November 30, 2023 15:45
@github-actions github-actions bot added this to the vNext milestone Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) type:cleanup Minor code clean up
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants