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

[tracer] add support for match sampling rules by resource and tags #5013

Merged
merged 27 commits into from
Jan 19, 2024

Conversation

lucaspimentel
Copy link
Member

@lucaspimentel lucaspimentel commented Jan 3, 2024

Summary of changes

Allow matching by resource name and tags in trace sampling rules (DD_TRACE_SAMPLING_RULES) and single-span sampling rules (DD_SPAN_SAMPLING_RULES).

Reason for change

These additions provide users with sampling scenarios that were not available before.

Implementation details

Add fields resource and tags to the sampling rules models for traces and single spans. Matching works the same as previously existing fields.

Test coverage

Added tests:

  • trace sampling, match by resource or tags (regex)
  • trace sampling, match by resource or tags (glob)
  • single-span sampling, match by resource or tags (glob only)

Other details

@lucaspimentel lucaspimentel added type:enhancement Improvement to an existing feature area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) labels Jan 3, 2024
@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Jan 3, 2024

Datadog Report

Branch report: lpimentel/trace-sampling-2
Commit report: 52aa432
Test service: dd-trace-dotnet

✅ 0 Failed, 306431 Passed, 1501 Skipped, 56m 35.89s Wall Time

@andrewlock
Copy link
Member

andrewlock commented Jan 4, 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 (5013) - mean (72ms)  : 63, 82
     .   : milestone, 72,
    master - mean (71ms)  : 62, 80
     .   : milestone, 71,

    section CallTarget+Inlining+NGEN
    This PR (5013) - mean (951ms)  : 923, 979
     .   : milestone, 951,
    master - mean (962ms)  : 942, 982
     .   : milestone, 962,

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

    section CallTarget+Inlining+NGEN
    This PR (5013) - mean (697ms)  : 676, 718
     .   : milestone, 697,
    master - mean (706ms)  : 687, 726
     .   : milestone, 706,

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

    section CallTarget+Inlining+NGEN
    This PR (5013) - mean (654ms)  : 638, 669
     .   : milestone, 654,
    master - mean (658ms)  : 640, 676
     .   : milestone, 658,

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

    section CallTarget+Inlining+NGEN
    This PR (5013) - mean (1,066ms)  : 1045, 1088
     .   : milestone, 1066,
    master - mean (1,069ms)  : 1048, 1091
     .   : milestone, 1069,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5013) - mean (271ms)  : 268, 275
     .   : milestone, 271,
    master - mean (271ms)  : 267, 275
     .   : milestone, 271,

    section CallTarget+Inlining+NGEN
    This PR (5013) - mean (1,051ms)  : 1025, 1078
     .   : milestone, 1051,
    master - mean (1,052ms)  : 1025, 1079
     .   : milestone, 1052,

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

    section CallTarget+Inlining+NGEN
    This PR (5013) - mean (1,012ms)  : 993, 1031
     .   : milestone, 1012,
    master - mean (1,018ms)  : 988, 1047
     .   : milestone, 1018,

Loading

@andrewlock
Copy link
Member

andrewlock commented Jan 4, 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 (5013) (11.682M)   : 0, 11681821
    master (11.793M)   : 0, 11792846
    benchmarks/2.9.0 (11.757M)   : 0, 11756801

    section Automatic
    This PR (5013) (7.982M)   : 0, 7981851
    master (8.076M)   : 0, 8076448
    benchmarks/2.9.0 (8.573M)   : 0, 8573327

    section Trace stats
    This PR (5013) (8.371M)   : 0, 8371403
    master (8.407M)   : 0, 8406782

    section Manual
    This PR (5013) (10.128M)   : 0, 10127577
    master (10.353M)   : 0, 10352820

    section Manual + Automatic
    This PR (5013) (7.553M)   : 0, 7552623
    master (7.610M)   : 0, 7610023

    section Version Conflict
    This PR (5013) (6.751M)   : 0, 6750630
    master (6.845M)   : 0, 6845162

Loading
gantt
    title Throughput Linux arm64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5013) (9.530M)   : 0, 9530048
    master (9.498M)   : 0, 9497633
    benchmarks/2.9.0 (9.605M)   : 0, 9605360

    section Automatic
    This PR (5013) (6.463M)   : 0, 6463396
    master (6.538M)   : 0, 6538176

    section Trace stats
    This PR (5013) (6.992M)   : 0, 6991933
    master (6.967M)   : 0, 6966769

    section Manual
    This PR (5013) (8.293M)   : 0, 8293448
    master (8.183M)   : 0, 8183082

    section Manual + Automatic
    This PR (5013) (6.161M)   : 0, 6161076
    master (6.155M)   : 0, 6155194

    section Version Conflict
    This PR (5013) (5.616M)   : 0, 5615854
    master (5.582M)   : 0, 5581839

Loading
gantt
    title Throughput Windows x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5013) (10.245M)   : 0, 10244670
    master (10.290M)   : 0, 10289786
    benchmarks/2.9.0 (9.956M)   : 0, 9956027

    section Automatic
    This PR (5013) (7.323M)   : 0, 7323143
    master (7.052M)   : 0, 7051599
    benchmarks/2.9.0 (7.438M)   : 0, 7437608

    section Trace stats
    This PR (5013) (7.576M)   : 0, 7575838
    master (7.398M)   : 0, 7397958

    section Manual
    This PR (5013) (9.098M)   : 0, 9098213
    master (8.955M)   : 0, 8954877

    section Manual + Automatic
    This PR (5013) (6.966M)   : 0, 6965773
    master (6.754M)   : 0, 6754356

    section Version Conflict
    This PR (5013) (6.177M)   : 0, 6177308
    master (6.121M)   : 0, 6120614

Loading
gantt
    title Throughput Linux x64 (ASM) (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    master (7.304M)   : 0, 7303586
    benchmarks/2.9.0 (7.813M)   : 0, 7813475

    section No attack
    master (1.762M)   : 0, 1762048
    benchmarks/2.9.0 (3.251M)   : 0, 3251456

    section Attack
    master (1.413M)   : 0, 1413289
    benchmarks/2.9.0 (2.577M)   : 0, 2577462

    section Blocking
    master (3.108M)   : 0, 3107757

    section IAST default
    master (6.434M)   : 0, 6433540

    section IAST full
    master (5.532M)   : 0, 5532224

    section Base vuln
    master (0.929M)   : 0, 928748

    section IAST vuln
    master (0.890M)   : 0, 890135

Loading

@andrewlock
Copy link
Member

andrewlock commented Jan 4, 2024

Benchmarks Report 🐌

Benchmarks for #5013 compared to master:

  • 1 benchmarks are faster, with geometric mean 1.119
  • 4 benchmarks are slower, with geometric mean 1.152
  • 2 benchmarks have fewer 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.66μs 47.4ns 284ns 0.0302 0.0129 0 7.48 KB
master StartStopWithChild netcoreapp3.1 10.9μs 58.6ns 337ns 0.0264 0.0106 0 7.57 KB
master StartStopWithChild net472 17.4μs 51.8ns 187ns 1.32 0.326 0.112 7.96 KB
#5013 StartStopWithChild net6.0 8.62μs 47.2ns 263ns 0.0215 0.0086 0 7.48 KB
#5013 StartStopWithChild netcoreapp3.1 10.8μs 58.4ns 355ns 0.0264 0.0106 0 7.58 KB
#5013 StartStopWithChild net472 17.2μs 40ns 155ns 1.32 0.336 0.103 7.95 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 457μs 119ns 461ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 630μs 341ns 1.32μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 790μs 247ns 854ns 0.393 0 0 3.3 KB
#5013 WriteAndFlushEnrichedTraces net6.0 443μs 242ns 871ns 0 0 0 2.7 KB
#5013 WriteAndFlushEnrichedTraces netcoreapp3.1 633μs 203ns 788ns 0 0 0 2.7 KB
#5013 WriteAndFlushEnrichedTraces net472 808μs 362ns 1.35μs 0.403 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 38.2μs 23ns 85.9ns 0.0191 0 0 1.77 KB
master AllCycleSimpleBody netcoreapp3.1 41.4μs 41.7ns 161ns 0.0204 0 0 1.74 KB
master AllCycleSimpleBody net472 44.1μs 38.3ns 148ns 0.267 0 0 1.81 KB
master AllCycleMoreComplexBody net6.0 201μs 58.7ns 219ns 0.101 0 0 9.25 KB
master AllCycleMoreComplexBody netcoreapp3.1 211μs 234ns 907ns 0.105 0 0 9.14 KB
master AllCycleMoreComplexBody net472 227μs 82ns 296ns 1.47 0 0 9.32 KB
master ObjectExtractorSimpleBody net6.0 139ns 0.0449ns 0.168ns 0.00397 0 0 280 B
master ObjectExtractorSimpleBody netcoreapp3.1 191ns 0.286ns 1.11ns 0.00373 0 0 272 B
master ObjectExtractorSimpleBody net472 165ns 0.0546ns 0.204ns 0.0446 0 0 281 B
master ObjectExtractorMoreComplexBody net6.0 2.99μs 1.65ns 6.19ns 0.0527 0 0 3.78 KB
master ObjectExtractorMoreComplexBody netcoreapp3.1 4.1μs 4.34ns 16.8ns 0.051 0 0 3.69 KB
master ObjectExtractorMoreComplexBody net472 3.76μs 1.58ns 5.9ns 0.601 0.00567 0 3.8 KB
#5013 AllCycleSimpleBody net6.0 38.8μs 9.62ns 36ns 0.0194 0 0 1.77 KB
#5013 AllCycleSimpleBody netcoreapp3.1 41.9μs 36.8ns 138ns 0.0207 0 0 1.74 KB
#5013 AllCycleSimpleBody net472 44.4μs 8.09ns 30.3ns 0.271 0 0 1.81 KB
#5013 AllCycleMoreComplexBody net6.0 200μs 36.6ns 132ns 0.1 0 0 9.25 KB
#5013 AllCycleMoreComplexBody netcoreapp3.1 212μs 207ns 801ns 0.106 0 0 9.14 KB
#5013 AllCycleMoreComplexBody net472 226μs 74.1ns 277ns 1.47 0 0 9.32 KB
#5013 ObjectExtractorSimpleBody net6.0 139ns 0.058ns 0.209ns 0.00393 0 0 280 B
#5013 ObjectExtractorSimpleBody netcoreapp3.1 197ns 0.0403ns 0.145ns 0.00369 0 0 272 B
#5013 ObjectExtractorSimpleBody net472 166ns 0.125ns 0.484ns 0.0446 0 0 281 B
#5013 ObjectExtractorMoreComplexBody net6.0 2.96μs 0.986ns 3.69ns 0.0533 0 0 3.78 KB
#5013 ObjectExtractorMoreComplexBody netcoreapp3.1 3.94μs 1.89ns 7.07ns 0.0493 0 0 3.69 KB
#5013 ObjectExtractorMoreComplexBody net472 3.73μs 1.27ns 4.77ns 0.602 0.00559 0 3.8 KB
Benchmarks.Trace.Asm.AppSecWafBenchmark - Faster 🎉 Same allocations ✔️

Faster 🎉 in #5013

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafTwice(args: NestedMap (10))‑net6.0 1.119 59,432.24 53,092.33

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 84.8ns 370ns 0.227 0 0 16.06 KB
master RunWaf(args=NestedMap (10)) netcoreapp3.1 67.9μs 320ns 1.2μs 0.197 0 0 16.06 KB
master RunWaf(args=NestedMap (10)) net472 95.3μs 43.6ns 163ns 2.52 0.0953 0 16.14 KB
master RunWafTwice(args=NestedMap (10)) net6.0 59.5μs 38.2ns 148ns 0.226 0 0 16.6 KB
master RunWafTwice(args=NestedMap (10)) netcoreapp3.1 74.6μs 394ns 2.08μs 0.221 0 0 16.58 KB
master RunWafTwice(args=NestedMap (10)) net472 102μs 53.6ns 208ns 2.65 0.102 0 16.69 KB
master RunWafWithAttack(args=Neste(...)tack) [22]) net6.0 108μs 43.2ns 156ns 0.269 0 0 22.41 KB
master RunWafWithAttack(args=Neste(...)tack) [22]) netcoreapp3.1 129μs 648ns 3.11μs 0.259 0 0 22.36 KB
master RunWafWithAttack(args=Neste(...)tack) [22]) net472 163μs 783ns 3.23μs 3.56 0.158 0 22.7 KB
master RunWaf(args=NestedMap (100)) net6.0 109μs 132ns 509ns 0.436 0 0 32.76 KB
master RunWaf(args=NestedMap (100)) netcoreapp3.1 130μs 623ns 2.64μs 0.448 0 0 33.33 KB
master RunWaf(args=NestedMap (100)) net472 193μs 77.2ns 289ns 5.28 0.384 0 33.67 KB
master RunWafTwice(args=NestedMap (100)) net6.0 112μs 69ns 267ns 0.47 0 0 33.3 KB
master RunWafTwice(args=NestedMap (100)) netcoreapp3.1 142μs 220ns 851ns 0.399 0 0 33.86 KB
master RunWafTwice(args=NestedMap (100)) net472 194μs 822ns 3.18μs 5.44 0.382 0 34.23 KB
master RunWafWithAttack(args=Neste(...)tack) [23]) net6.0 158μs 38.4ns 144ns 0.509 0 0 39.1 KB
master RunWafWithAttack(args=Neste(...)tack) [23]) netcoreapp3.1 199μs 940ns 3.76μs 0.506 0 0 39.63 KB
master RunWafWithAttack(args=Neste(...)tack) [23]) net472 254μs 172ns 664ns 6.33 0.506 0 40.23 KB
master RunWaf(args=NestedMap (20)) net6.0 108μs 38.1ns 148ns 0.431 0 0 32.18 KB
master RunWaf(args=NestedMap (20)) netcoreapp3.1 132μs 657ns 3.01μs 0.399 0 0 32.3 KB
master RunWaf(args=NestedMap (20)) net472 186μs 141ns 545ns 5.17 0.369 0 32.63 KB
master RunWafTwice(args=NestedMap (20)) net6.0 106μs 618ns 5.39μs 0.449 0 0 32.72 KB
master RunWafTwice(args=NestedMap (20)) netcoreapp3.1 139μs 616ns 2.39μs 0.423 0 0 32.82 KB
master RunWafTwice(args=NestedMap (20)) net472 192μs 136ns 526ns 5.26 0.383 0 33.19 KB
master RunWafWithAttack(args=Neste(...)tack) [22]) net6.0 156μs 83.3ns 289ns 0.543 0 0 38.53 KB
master RunWafWithAttack(args=Neste(...)tack) [22]) netcoreapp3.1 199μs 283ns 1.02μs 0.484 0 0 38.6 KB
master RunWafWithAttack(args=Neste(...)tack) [22]) net472 256μs 966ns 3.74μs 6.17 0.504 0 39.2 KB
#5013 RunWaf(args=NestedMap (10)) net6.0 50.9μs 15.7ns 58.6ns 0.232 0 0 16.06 KB
#5013 RunWaf(args=NestedMap (10)) netcoreapp3.1 70.6μs 400ns 2.74μs 0.183 0 0 16.06 KB
#5013 RunWaf(args=NestedMap (10)) net472 96.5μs 111ns 428ns 2.55 0.0962 0 16.14 KB
#5013 RunWafTwice(args=NestedMap (10)) net6.0 53.1μs 16ns 59.7ns 0.213 0 0 16.6 KB
#5013 RunWafTwice(args=NestedMap (10)) netcoreapp3.1 72.8μs 391ns 2.25μs 0.207 0 0 16.58 KB
#5013 RunWafTwice(args=NestedMap (10)) net472 107μs 540ns 2.29μs 2.63 0.103 0 16.69 KB
#5013 RunWafWithAttack(args=Neste(...)tack) [22]) net6.0 109μs 79.1ns 306ns 0.323 0 0 22.41 KB
#5013 RunWafWithAttack(args=Neste(...)tack) [22]) netcoreapp3.1 127μs 567ns 2.19μs 0.314 0 0 22.36 KB
#5013 RunWafWithAttack(args=Neste(...)tack) [22]) net472 163μs 692ns 2.68μs 3.55 0.158 0 22.7 KB
#5013 RunWaf(args=NestedMap (100)) net6.0 107μs 590ns 3.54μs 0.434 0 0 32.76 KB
#5013 RunWaf(args=NestedMap (100)) netcoreapp3.1 132μs 716ns 3.99μs 0.446 0 0 33.33 KB
#5013 RunWaf(args=NestedMap (100)) net472 186μs 131ns 508ns 5.3 0.372 0 33.67 KB
#5013 RunWafTwice(args=NestedMap (100)) net6.0 104μs 65.9ns 247ns 0.434 0 0 33.3 KB
#5013 RunWafTwice(args=NestedMap (100)) netcoreapp3.1 137μs 645ns 2.74μs 0.422 0 0 33.86 KB
#5013 RunWafTwice(args=NestedMap (100)) net472 192μs 133ns 516ns 5.35 0.382 0 34.23 KB
#5013 RunWafWithAttack(args=Neste(...)tack) [23]) net6.0 167μs 84.9ns 329ns 0.501 0 0 39.1 KB
#5013 RunWafWithAttack(args=Neste(...)tack) [23]) netcoreapp3.1 196μs 907ns 3.51μs 0.487 0 0 39.63 KB
#5013 RunWafWithAttack(args=Neste(...)tack) [23]) net472 252μs 212ns 821ns 6.29 0.503 0 40.23 KB
#5013 RunWaf(args=NestedMap (20)) net6.0 107μs 27.7ns 107ns 0.451 0 0 32.18 KB
#5013 RunWaf(args=NestedMap (20)) netcoreapp3.1 136μs 756ns 4.54μs 0.412 0 0 32.3 KB
#5013 RunWaf(args=NestedMap (20)) net472 188μs 881ns 3.41μs 5.16 0.369 0 32.63 KB
#5013 RunWafTwice(args=NestedMap (20)) net6.0 110μs 29.7ns 115ns 0.448 0 0 32.72 KB
#5013 RunWafTwice(args=NestedMap (20)) netcoreapp3.1 138μs 491ns 1.9μs 0.427 0 0 32.82 KB
#5013 RunWafTwice(args=NestedMap (20)) net472 199μs 89.8ns 348ns 5.23 0.388 0 33.19 KB
#5013 RunWafWithAttack(args=Neste(...)tack) [22]) net6.0 158μs 58.5ns 227ns 0.554 0 0 38.53 KB
#5013 RunWafWithAttack(args=Neste(...)tack) [22]) netcoreapp3.1 197μs 1.07μs 5.93μs 0.497 0 0 38.6 KB
#5013 RunWafWithAttack(args=Neste(...)tack) [22]) net472 250μs 142ns 550ns 6.12 0.5 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 174μs 142ns 531ns 0.173 0 0 18.25 KB
master SendRequest netcoreapp3.1 194μs 203ns 787ns 0.194 0 0 20.41 KB
master SendRequest net472 0ns 0ns 0ns 0 0 0 0 b
#5013 SendRequest net6.0 174μs 153ns 594ns 0.174 0 0 18.25 KB
#5013 SendRequest netcoreapp3.1 192μs 428ns 1.66μs 0.145 0 0 20.41 KB
#5013 SendRequest net472 0.000221ns 0.000138ns 0.000515ns 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 550μs 2.17μs 8.42μs 0.558 0 0 41.6 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 646μs 878ns 3.4μs 0.326 0 0 41.87 KB
master WriteAndFlushEnrichedTraces net472 827μs 1.61μs 5.81μs 8.33 2.5 0.417 53.24 KB
#5013 WriteAndFlushEnrichedTraces net6.0 560μs 366ns 1.37μs 0.561 0 0 41.81 KB
#5013 WriteAndFlushEnrichedTraces netcoreapp3.1 651μs 852ns 3.3μs 0.324 0 0 41.87 KB
#5013 WriteAndFlushEnrichedTraces net472 867μs 4.25μs 17.5μs 8.25 2.6 0.434 53.24 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.1μs 2.38ns 9.23ns 0.0108 0 0 768 B
master ExecuteNonQuery netcoreapp3.1 1.52μs 2.33ns 9.04ns 0.0106 0 0 768 B
master ExecuteNonQuery net472 1.67μs 0.715ns 2.58ns 0.115 0 0 730 B
#5013 ExecuteNonQuery net6.0 1.16μs 0.915ns 3.55ns 0.0106 0 0 768 B
#5013 ExecuteNonQuery netcoreapp3.1 1.42μs 0.932ns 3.61ns 0.0105 0 0 768 B
#5013 ExecuteNonQuery net472 1.85μs 1.16ns 4.34ns 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.19μs 0.581ns 2.25ns 0.0132 0 0 936 B
master CallElasticsearch netcoreapp3.1 1.52μs 3.04ns 11.8ns 0.0122 0 0 936 B
master CallElasticsearch net472 2.5μs 1.86ns 7.22ns 0.151 0 0 955 B
master CallElasticsearchAsync net6.0 1.38μs 0.318ns 1.19ns 0.0125 0 0 912 B
master CallElasticsearchAsync netcoreapp3.1 1.71μs 0.523ns 1.89ns 0.0136 0 0 984 B
master CallElasticsearchAsync net472 2.6μs 2.15ns 8.33ns 0.16 0 0 1.01 KB
#5013 CallElasticsearch net6.0 1.22μs 0.587ns 2.27ns 0.013 0 0 936 B
#5013 CallElasticsearch netcoreapp3.1 1.49μs 1.12ns 4.35ns 0.0128 0 0 936 B
#5013 CallElasticsearch net472 2.56μs 0.801ns 3ns 0.151 0 0 955 B
#5013 CallElasticsearchAsync net6.0 1.35μs 0.329ns 1.19ns 0.0122 0 0 912 B
#5013 CallElasticsearchAsync netcoreapp3.1 1.61μs 1.09ns 4.21ns 0.0136 0 0 984 B
#5013 CallElasticsearchAsync net472 2.58μs 0.672ns 2.6ns 0.16 0.00129 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.24μs 0.474ns 1.71ns 0.0127 0 0 912 B
master ExecuteAsync netcoreapp3.1 1.67μs 1.34ns 4.84ns 0.0125 0 0 912 B
master ExecuteAsync net472 1.75μs 1.05ns 3.91ns 0.139 0 0 875 B
#5013 ExecuteAsync net6.0 1.38μs 1.44ns 5.39ns 0.013 0 0 912 B
#5013 ExecuteAsync netcoreapp3.1 1.69μs 0.997ns 3.86ns 0.0119 0 0 912 B
#5013 ExecuteAsync net472 1.86μs 1.17ns 4.52ns 0.138 0.000927 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.15μs 2.62ns 9.8ns 0.029 0 0 2.1 KB
master SendAsync netcoreapp3.1 4.95μs 1.72ns 6.65ns 0.0346 0 0 2.63 KB
master SendAsync net472 7.83μs 4.66ns 18ns 0.525 0 0 3.31 KB
#5013 SendAsync net6.0 4.05μs 1.34ns 4.82ns 0.0285 0 0 2.1 KB
#5013 SendAsync netcoreapp3.1 4.97μs 1.7ns 6.14ns 0.0347 0 0 2.63 KB
#5013 SendAsync net472 7.78μs 3.15ns 12.2ns 0.524 0 0 3.31 KB
Benchmarks.Trace.Iast.StringAspectsBenchmark - Slower ⚠️ Fewer allocations 🎉

Slower ⚠️ in #5013

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark(parameters: System.Collections.Generic.List`1[System.String])‑net6.0 1.181 51,500.00 60,800.00 bimodal

Fewer allocations 🎉 in #5013

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark(parameters: System.Collections.Generic.List`1[System.String])‑net472 62.39 KB 58.54 KB -3.86 KB -6.18%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark(parameters: System.Collections.Generic.List`1[System.String])‑net472 65.54 KB 57.34 KB -8.19 KB -12.50%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StringConcatBenchmark(parameters=Syste(...)ring] [48]) net6.0 51.6μs 137ns 496ns 0 0 0 43.44 KB
master StringConcatBenchmark(parameters=Syste(...)ring] [48]) netcoreapp3.1 53.3μs 266ns 1.13μs 0 0 0 42.64 KB
master StringConcatBenchmark(parameters=Syste(...)ring] [48]) net472 38μs 140ns 524ns 0 0 0 62.39 KB
master StringConcatAspectBenchmark(parameters=Syste(...)ring] [48]) net6.0 96.9μs 2.83μs 28.3μs 0 0 0 43.29 KB
master StringConcatAspectBenchmark(parameters=Syste(...)ring] [48]) netcoreapp3.1 89.8μs 3.79μs 37.5μs 0 0 0 42.64 KB
master StringConcatAspectBenchmark(parameters=Syste(...)ring] [48]) net472 61.4μs 674ns 6.46μs 0 0 0 65.54 KB
#5013 StringConcatBenchmark(parameters=Syste(...)ring] [48]) net6.0 61.8μs 753ns 7.53μs 0 0 0 43.44 KB
#5013 StringConcatBenchmark(parameters=Syste(...)ring] [48]) netcoreapp3.1 52.9μs 247ns 924ns 0 0 0 42.64 KB
#5013 StringConcatBenchmark(parameters=Syste(...)ring] [48]) net472 37.9μs 124ns 465ns 0 0 0 58.54 KB
#5013 StringConcatAspectBenchmark(parameters=Syste(...)ring] [48]) net6.0 86.7μs 2.77μs 27.7μs 0 0 0 43.29 KB
#5013 StringConcatAspectBenchmark(parameters=Syste(...)ring] [48]) netcoreapp3.1 71.6μs 328ns 1.47μs 0 0 0 42.64 KB
#5013 StringConcatAspectBenchmark(parameters=Syste(...)ring] [48]) net472 62.1μs 207ns 774ns 0 0 0 57.34 KB
Benchmarks.Trace.ILoggerBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #5013

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.ILoggerBenchmark.EnrichedLog‑net6.0 1.138 1,409.24 1,603.84

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 1.41μs 1.03ns 3.99ns 0.0219 0 0 1.57 KB
master EnrichedLog netcoreapp3.1 2.3μs 0.994ns 3.72ns 0.0205 0 0 1.57 KB
master EnrichedLog net472 2.68μs 2.2ns 7.95ns 0.238 0 0 1.5 KB
#5013 EnrichedLog net6.0 1.6μs 0.752ns 2.81ns 0.0224 0 0 1.57 KB
#5013 EnrichedLog netcoreapp3.1 2.3μs 4.01ns 15.5ns 0.0213 0 0 1.57 KB
#5013 EnrichedLog net472 2.7μs 1.79ns 6.95ns 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 122ns 471ns 0.0558 0 0 4.21 KB
master EnrichedLog netcoreapp3.1 118μs 181ns 678ns 0 0 0 4.21 KB
master EnrichedLog net472 150μs 105ns 408ns 0.669 0.223 0 4.39 KB
#5013 EnrichedLog net6.0 111μs 110ns 398ns 0.0557 0 0 4.21 KB
#5013 EnrichedLog netcoreapp3.1 119μs 90.3ns 350ns 0.0591 0 0 4.21 KB
#5013 EnrichedLog net472 147μs 57ns 213ns 0.664 0.221 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.18μs 3.49ns 13.5ns 0.0301 0 0 2.13 KB
master EnrichedLog netcoreapp3.1 4.14μs 1.52ns 5.88ns 0.0288 0 0 2.13 KB
master EnrichedLog net472 4.86μs 2.48ns 9.62ns 0.308 0 0 1.95 KB
#5013 EnrichedLog net6.0 3.16μs 1.08ns 4.19ns 0.03 0 0 2.13 KB
#5013 EnrichedLog netcoreapp3.1 4.1μs 1.56ns 6.06ns 0.0292 0 0 2.13 KB
#5013 EnrichedLog net472 4.9μs 2.5ns 9.68ns 0.307 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.42μs 0.925ns 3.34ns 0.0156 0 0 1.1 KB
master SendReceive netcoreapp3.1 1.75μs 0.461ns 1.73ns 0.0149 0 0 1.1 KB
master SendReceive net472 2.12μs 1.76ns 6.59ns 0.177 0 0 1.12 KB
#5013 SendReceive net6.0 1.35μs 1.13ns 4.25ns 0.0156 0 0 1.1 KB
#5013 SendReceive netcoreapp3.1 1.72μs 1.86ns 7.21ns 0.0155 0 0 1.1 KB
#5013 SendReceive net472 2.2μs 2.78ns 10.8ns 0.176 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.62μs 0.718ns 2.59ns 0.021 0 0 1.53 KB
master EnrichedLog netcoreapp3.1 4.02μs 2.06ns 8ns 0.0203 0 0 1.58 KB
master EnrichedLog net472 4.42μs 1.73ns 6.49ns 0.312 0 0 1.97 KB
#5013 EnrichedLog net6.0 2.75μs 2.48ns 9.6ns 0.0206 0 0 1.53 KB
#5013 EnrichedLog netcoreapp3.1 3.85μs 1.56ns 6.02ns 0.0212 0 0 1.58 KB
#5013 EnrichedLog net472 4.21μs 2.43ns 9.42ns 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 451ns 0.264ns 1.02ns 0.00757 0 0 536 B
master StartFinishSpan netcoreapp3.1 701ns 0.437ns 1.63ns 0.00726 0 0 536 B
master StartFinishSpan net472 692ns 0.274ns 1.02ns 0.0854 0 0 538 B
master StartFinishScope net6.0 593ns 0.541ns 2.1ns 0.00913 0 0 656 B
master StartFinishScope netcoreapp3.1 872ns 0.386ns 1.49ns 0.00882 0 0 656 B
master StartFinishScope net472 971ns 3.63ns 14.1ns 0.0979 0 0 618 B
#5013 StartFinishSpan net6.0 481ns 0.229ns 0.887ns 0.00743 0 0 536 B
#5013 StartFinishSpan netcoreapp3.1 739ns 0.347ns 1.25ns 0.00724 0 0 536 B
#5013 StartFinishSpan net472 735ns 0.798ns 3.09ns 0.0851 0 0 538 B
#5013 StartFinishScope net6.0 603ns 0.281ns 1.09ns 0.00904 0 0 656 B
#5013 StartFinishScope netcoreapp3.1 889ns 4.7ns 24ns 0.00913 0 0 656 B
#5013 StartFinishScope net472 958ns 0.608ns 2.35ns 0.0981 0 0 618 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #5013

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑net6.0 1.174 601.15 705.97
Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑netcoreapp3.1 1.117 909.76 1,015.98

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net6.0 601ns 0.494ns 1.91ns 0.00913 0 0 656 B
master RunOnMethodBegin netcoreapp3.1 910ns 0.278ns 1.08ns 0.0086 0 0 656 B
master RunOnMethodBegin net472 1.09μs 0.377ns 1.41ns 0.0981 0 0 618 B
#5013 RunOnMethodBegin net6.0 706ns 0.251ns 0.972ns 0.00912 0 0 656 B
#5013 RunOnMethodBegin netcoreapp3.1 1.02μs 0.337ns 1.26ns 0.00863 0 0 656 B
#5013 RunOnMethodBegin net472 1.07μs 0.491ns 1.9ns 0.0981 0 0 618 B

@lucaspimentel lucaspimentel changed the title Lpimentel/trace sampling 2 [tracer] match sampling rules by resource name and span tags Jan 4, 2024
@lucaspimentel lucaspimentel force-pushed the lpimentel/trace-sampling-1 branch 2 times, most recently from 4bc6b5f to 66b5c1f Compare January 8, 2024 21:11
@lucaspimentel lucaspimentel force-pushed the lpimentel/trace-sampling-2 branch 4 times, most recently from 7590db6 to d120a14 Compare January 8, 2024 22:26
@lucaspimentel lucaspimentel force-pushed the lpimentel/trace-sampling-1 branch from 9850ebe to 07b8bcf Compare January 10, 2024 00:13
@lucaspimentel lucaspimentel force-pushed the lpimentel/trace-sampling-2 branch from 715d911 to d982a91 Compare January 10, 2024 00:13
@lucaspimentel lucaspimentel force-pushed the lpimentel/trace-sampling-1 branch from 706ee2e to e9e4c70 Compare January 10, 2024 17:43
@lucaspimentel lucaspimentel force-pushed the lpimentel/trace-sampling-2 branch from d982a91 to 85e67fa Compare January 10, 2024 19:49
@lucaspimentel lucaspimentel force-pushed the lpimentel/trace-sampling-1 branch from 4f61d41 to 85c991a Compare January 10, 2024 20:41
@lucaspimentel lucaspimentel force-pushed the lpimentel/trace-sampling-2 branch from 85e67fa to 512f4b8 Compare January 10, 2024 21:04
@lucaspimentel lucaspimentel force-pushed the lpimentel/trace-sampling-1 branch from 3e1938e to 1aeed0a Compare January 11, 2024 16:39
@lucaspimentel lucaspimentel force-pushed the lpimentel/trace-sampling-2 branch from 512f4b8 to 996411b Compare January 11, 2024 16:40
@lucaspimentel lucaspimentel force-pushed the lpimentel/trace-sampling-1 branch from 1aeed0a to 8e1e3a6 Compare January 12, 2024 18:48
@lucaspimentel lucaspimentel force-pushed the lpimentel/trace-sampling-2 branch from f15848e to f457633 Compare January 12, 2024 18:49
@lucaspimentel lucaspimentel marked this pull request as ready for review January 12, 2024 18:53
@lucaspimentel lucaspimentel force-pushed the lpimentel/trace-sampling-2 branch from ba5649a to 1128802 Compare January 18, 2024 20:05
@lucaspimentel lucaspimentel merged commit 4f57259 into master Jan 19, 2024
53 of 55 checks passed
@lucaspimentel lucaspimentel deleted the lpimentel/trace-sampling-2 branch January 19, 2024 16:45
@github-actions github-actions bot added this to the vNext milestone Jan 19, 2024
@lucaspimentel lucaspimentel changed the title [tracer] match sampling rules by resource name and span tags [tracer] match sampling rules in DD_TRACE_SAMPLING_RULES by resource name and span tags Apr 9, 2024
@lucaspimentel lucaspimentel changed the title [tracer] match sampling rules in DD_TRACE_SAMPLING_RULES by resource name and span tags [tracer] add support for match sampling rules by resource and tags Apr 17, 2024
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:enhancement Improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants