Skip to content

[ASM][ATO] Collect request headers on login user events (failures and success)#6225

Merged
anna-git merged 7 commits into
masterfrom
anna/asm/ato-headers-success
Nov 25, 2024
Merged

[ASM][ATO] Collect request headers on login user events (failures and success)#6225
anna-git merged 7 commits into
masterfrom
anna/asm/ato-headers-success

Conversation

@anna-git

@anna-git anna-git commented Oct 31, 2024

Copy link
Copy Markdown
Contributor

Summary of changes

Collect request headers on user events, whether it's a failure or success. Adapt snapshosts

Reason for change

Collect request headers on user events

Implementation details

Test coverage

Other details

@anna-git anna-git changed the title try add headers and see [ASM][ATO] try add headers and see Oct 31, 2024
@datadog-ddstaging

datadog-ddstaging Bot commented Oct 31, 2024

Copy link
Copy Markdown

Datadog Report

Branch report: anna/asm/ato-headers-success
Commit report: dae27bb
Test service: dd-trace-dotnet

✅ 0 Failed, 454557 Passed, 2753 Skipped, 20h 47m 21.28s Total Time
❄️ 2 New Flaky

New Flaky Tests (2)

  • Serialization_RootSpan - Datadog.Trace.Tests.Tagging.TagsListTests - Last Failure

    Expand for error
     Expected collection to contain 20 item(s), but found 27: {["_dd.code_origin.type"] = "exit", ["_dd.code_origin.frames.0.index"] = "4", ["_dd.code_origin.frames.0.method"] = "MoveNext", ["_dd.code_origin.frames.0.type"] = "Datadog.Trace.Tests.Tagging.TagsListTests+<Serialization_RootSpan>d__5", ["_dd.code_origin.frames.0.file"] = "/project/tracer/test/Datadog.Trace.Tests/Tagging/TagsListTests.cs", ["_dd.code_origin.frames.0.line"] = "94", ["_dd.code_origin.frames.0.column"] = "20", ["0"] = "0", ["1"] = "1", ["2"] = "2", ["3"] = "3", ["4"] = "4", ["5"] = "5", ["6"] = "6", ["7"] = "7", ["8"] = "8", ["9"] = "9", ["10"] = "10", ["11"] = "11", ["12"] = "12", ["13"] = "13", ["14"] = "14", ["_dd.p.dm"] = "-0", ["_dd.p.tid"] = "67447cd600000000", ["runtime-id"] = "eb1f5b17-dcb1-49a8-b05b-721c6292d78f", ["env"] = "Overridden Environment", ["language"] = "dotnet"}.
    
  • Serialization_ServiceEntrySpan - Datadog.Trace.Tests.Tagging.TagsListTests - Last Failure

    Expand for error
     Expected deserializedSpan.Tags.Count to be 21, but found 31 (difference of 10).
    

@andrewlock

andrewlock commented Oct 31, 2024

Copy link
Copy Markdown
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 (6225) - mean (72ms)  : 62, 82
     .   : milestone, 72,
    master - mean (71ms)  : 65, 78
     .   : milestone, 71,

    section CallTarget+Inlining+NGEN
    This PR (6225) - mean (1,016ms)  : 907, 1124
     .   : milestone, 1016,
    master - mean (981ms)  : 960, 1003
     .   : milestone, 981,

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

    section CallTarget+Inlining+NGEN
    This PR (6225) - mean (698ms)  : 642, 754
     .   : milestone, 698,
    master - mean (683ms)  : 665, 702
     .   : milestone, 683,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6225) - mean (95ms)  : 88, 102
     .   : milestone, 95,
    master - mean (92ms)  : 89, 95
     .   : milestone, 92,

    section CallTarget+Inlining+NGEN
    This PR (6225) - mean (702ms)  : crit, 591, 813
     .   : crit, milestone, 702,
    master - mean (638ms)  : 623, 653
     .   : milestone, 638,

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

    section CallTarget+Inlining+NGEN
    This PR (6225) - mean (1,098ms)  : 1063, 1132
     .   : milestone, 1098,
    master - mean (1,094ms)  : 1072, 1115
     .   : milestone, 1094,

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

    section CallTarget+Inlining+NGEN
    This PR (6225) - mean (881ms)  : 848, 914
     .   : milestone, 881,
    master - mean (875ms)  : 850, 900
     .   : milestone, 875,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6225) - mean (266ms)  : 262, 269
     .   : milestone, 266,
    master - mean (264ms)  : 260, 268
     .   : milestone, 264,

    section CallTarget+Inlining+NGEN
    This PR (6225) - mean (859ms)  : 822, 897
     .   : milestone, 859,
    master - mean (854ms)  : 825, 884
     .   : milestone, 854,

Loading

@andrewlock

andrewlock commented Oct 31, 2024

Copy link
Copy Markdown
Member

Benchmarks Report for appsec 🐌

Benchmarks for #6225 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.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 220μs 60.9ns 211ns 2.52 0 0 176.83 KB
master AllCycleSimpleBody netcoreapp3.1 334μs 192ns 693ns 2.49 0 0 184.27 KB
master AllCycleSimpleBody net472 282μs 215ns 833ns 33.4 2.53 0 210.04 KB
master AllCycleMoreComplexBody net6.0 226μs 185ns 718ns 2.47 0 0 180.33 KB
master AllCycleMoreComplexBody netcoreapp3.1 332μs 164ns 613ns 2.48 0 0 187.68 KB
master AllCycleMoreComplexBody net472 292μs 296ns 1.15μs 33.8 2.51 0 213.56 KB
master ObjectExtractorSimpleBody net6.0 141ns 0.0963ns 0.36ns 0.00393 0 0 280 B
master ObjectExtractorSimpleBody netcoreapp3.1 209ns 0.325ns 1.26ns 0.00369 0 0 272 B
master ObjectExtractorSimpleBody net472 218ns 0.27ns 1.05ns 0.0445 0 0 281 B
master ObjectExtractorMoreComplexBody net6.0 3.15μs 2.37ns 8.53ns 0.0528 0 0 3.78 KB
master ObjectExtractorMoreComplexBody netcoreapp3.1 3.96μs 1.81ns 6.77ns 0.0494 0 0 3.69 KB
master ObjectExtractorMoreComplexBody net472 4.47μs 7.59ns 29.4ns 0.603 0.00672 0 3.8 KB
#6225 AllCycleSimpleBody net6.0 220μs 126ns 470ns 2.4 0 0 176.82 KB
#6225 AllCycleSimpleBody netcoreapp3.1 317μs 153ns 571ns 2.53 0 0 184.27 KB
#6225 AllCycleSimpleBody net472 286μs 151ns 566ns 33.3 2.56 0 210.04 KB
#6225 AllCycleMoreComplexBody net6.0 223μs 83ns 321ns 2.47 0 0 180.33 KB
#6225 AllCycleMoreComplexBody netcoreapp3.1 329μs 149ns 539ns 2.48 0 0 187.68 KB
#6225 AllCycleMoreComplexBody net472 291μs 336ns 1.3μs 33.8 2.59 0 213.56 KB
#6225 ObjectExtractorSimpleBody net6.0 138ns 0.117ns 0.452ns 0.00392 0 0 280 B
#6225 ObjectExtractorSimpleBody netcoreapp3.1 210ns 0.117ns 0.437ns 0.00368 0 0 272 B
#6225 ObjectExtractorSimpleBody net472 218ns 0.227ns 0.879ns 0.0446 0 0 281 B
#6225 ObjectExtractorMoreComplexBody net6.0 3.05μs 1.08ns 4.2ns 0.0537 0 0 3.78 KB
#6225 ObjectExtractorMoreComplexBody netcoreapp3.1 3.93μs 2.05ns 7.4ns 0.0491 0 0 3.69 KB
#6225 ObjectExtractorMoreComplexBody net472 4.53μs 5.32ns 18.4ns 0.601 0.00452 0 3.8 KB
Benchmarks.Trace.Asm.AppSecEncoderBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EncodeArgs net6.0 39μs 33.8ns 131ns 0.445 0 0 32.4 KB
master EncodeArgs netcoreapp3.1 53.9μs 17.5ns 60.5ns 0.429 0 0 32.4 KB
master EncodeArgs net472 66.3μs 20.6ns 77.1ns 5.16 0.0666 0 32.5 KB
master EncodeLegacyArgs net6.0 71.3μs 82.1ns 307ns 0 0 0 2.14 KB
master EncodeLegacyArgs netcoreapp3.1 106μs 96.3ns 373ns 0 0 0 2.14 KB
master EncodeLegacyArgs net472 159μs 185ns 716ns 0.316 0 0 2.15 KB
#6225 EncodeArgs net6.0 36.9μs 17.4ns 65.1ns 0.461 0 0 32.4 KB
#6225 EncodeArgs netcoreapp3.1 54.4μs 26.1ns 97.5ns 0.43 0 0 32.4 KB
#6225 EncodeArgs net472 69.2μs 94ns 364ns 5.15 0.0691 0 32.5 KB
#6225 EncodeLegacyArgs net6.0 75μs 131ns 507ns 0 0 0 2.14 KB
#6225 EncodeLegacyArgs netcoreapp3.1 108μs 297ns 1.15μs 0 0 0 2.14 KB
#6225 EncodeLegacyArgs net472 158μs 89.1ns 345ns 0.317 0 0 2.15 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 RunWafRealisticBenchmark net6.0 181μs 97.3ns 377ns 0 0 0 2.44 KB
master RunWafRealisticBenchmark netcoreapp3.1 195μs 210ns 814ns 0 0 0 2.39 KB
master RunWafRealisticBenchmark net472 212μs 198ns 768ns 0.316 0 0 2.46 KB
master RunWafRealisticBenchmarkWithAttack net6.0 122μs 90.9ns 328ns 0 0 0 1.47 KB
master RunWafRealisticBenchmarkWithAttack netcoreapp3.1 130μs 51.7ns 193ns 0 0 0 1.46 KB
master RunWafRealisticBenchmarkWithAttack net472 140μs 52.3ns 181ns 0.211 0 0 1.49 KB
#6225 RunWafRealisticBenchmark net6.0 185μs 76.8ns 287ns 0 0 0 2.44 KB
#6225 RunWafRealisticBenchmark netcoreapp3.1 193μs 108ns 418ns 0 0 0 2.39 KB
#6225 RunWafRealisticBenchmark net472 208μs 72ns 269ns 0.31 0 0 2.46 KB
#6225 RunWafRealisticBenchmarkWithAttack net6.0 123μs 63.5ns 246ns 0 0 0 1.47 KB
#6225 RunWafRealisticBenchmarkWithAttack netcoreapp3.1 130μs 184ns 714ns 0 0 0 1.46 KB
#6225 RunWafRealisticBenchmarkWithAttack net472 141μs 66.8ns 250ns 0.211 0 0 1.49 KB
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #6225

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 253.31 KB 254.79 KB 1.48 KB 0.58%

Fewer allocations 🎉 in #6225

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net472 59.54 KB 57.34 KB -2.2 KB -3.69%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StringConcatBenchmark net6.0 60.3μs 771ns 7.6μs 0 0 0 43.44 KB
master StringConcatBenchmark netcoreapp3.1 65.6μs 833ns 8.2μs 0 0 0 42.64 KB
master StringConcatBenchmark net472 37.6μs 88.2ns 318ns 0 0 0 59.54 KB
master StringConcatAspectBenchmark net6.0 305μs 1.42μs 5.48μs 0 0 0 253.31 KB
master StringConcatAspectBenchmark netcoreapp3.1 340μs 1.45μs 8.06μs 0 0 0 253.77 KB
master StringConcatAspectBenchmark net472 290μs 6.57μs 64μs 0 0 0 278.53 KB
#6225 StringConcatBenchmark net6.0 60μs 918ns 9.04μs 0 0 0 43.44 KB
#6225 StringConcatBenchmark netcoreapp3.1 63.3μs 891ns 8.87μs 0 0 0 42.64 KB
#6225 StringConcatBenchmark net472 39.1μs 216ns 1.39μs 0 0 0 57.34 KB
#6225 StringConcatAspectBenchmark net6.0 306μs 5.16μs 49μs 0 0 0 254.79 KB
#6225 StringConcatAspectBenchmark netcoreapp3.1 348μs 2.29μs 22.1μs 0 0 0 254.2 KB
#6225 StringConcatAspectBenchmark net472 295μs 5.7μs 55.9μs 0 0 0 278.53 KB

@andrewlock

andrewlock commented Oct 31, 2024

Copy link
Copy Markdown
Member

Benchmarks Report for tracer 🐌

Benchmarks for #6225 compared to master:

  • 1 benchmarks are slower, with geometric mean 1.196
  • 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.84μs 42.3ns 247ns 0.0112 0.00372 0 5.61 KB
master StartStopWithChild netcoreapp3.1 10.1μs 52.1ns 244ns 0.0145 0.00482 0 5.8 KB
master StartStopWithChild net472 16.1μs 65.2ns 252ns 1.04 0.3 0.0972 6.21 KB
#6225 StartStopWithChild net6.0 7.84μs 40.2ns 193ns 0.0155 0.00777 0 5.61 KB
#6225 StartStopWithChild netcoreapp3.1 10.1μs 55.1ns 344ns 0.0145 0.00485 0 5.8 KB
#6225 StartStopWithChild net472 16.3μs 64.9ns 252ns 1.04 0.304 0.0936 6.21 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 490μs 463ns 1.79μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 652μs 267ns 1μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 838μs 365ns 1.37μs 0.417 0 0 3.3 KB
#6225 WriteAndFlushEnrichedTraces net6.0 483μs 211ns 818ns 0 0 0 2.7 KB
#6225 WriteAndFlushEnrichedTraces netcoreapp3.1 688μs 291ns 1.09μs 0 0 0 2.7 KB
#6225 WriteAndFlushEnrichedTraces net472 857μs 462ns 1.79μs 0.425 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 150μs 860ns 6.93μs 0.148 0 0 14.47 KB
master SendRequest netcoreapp3.1 169μs 953ns 7.69μs 0.154 0 0 17.27 KB
master SendRequest net472 0.000269ns 0.000209ns 0.000783ns 0 0 0 0 b
#6225 SendRequest net6.0 150μs 866ns 6.87μs 0.209 0 0 14.47 KB
#6225 SendRequest netcoreapp3.1 174μs 1.07μs 10.5μs 0.175 0 0 17.27 KB
#6225 SendRequest net472 0.000967ns 0.000339ns 0.00131ns 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 586μs 2.86μs 11.8μs 0.553 0 0 41.77 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 673μs 3.4μs 15.2μs 0.331 0 0 41.74 KB
master WriteAndFlushEnrichedTraces net472 873μs 4.48μs 20μs 8.68 2.6 0.434 53.31 KB
#6225 WriteAndFlushEnrichedTraces net6.0 555μs 2.65μs 10.6μs 0.543 0 0 41.62 KB
#6225 WriteAndFlushEnrichedTraces netcoreapp3.1 674μs 2.22μs 8.29μs 0.342 0 0 41.9 KB
#6225 WriteAndFlushEnrichedTraces net472 869μs 3.49μs 13.5μs 8.22 2.47 0.411 53.29 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.34μs 0.985ns 3.69ns 0.0143 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.76μs 1.76ns 6.83ns 0.0131 0 0 1.02 KB
master ExecuteNonQuery net472 2.05μs 1.84ns 7.12ns 0.157 0.00103 0 987 B
#6225 ExecuteNonQuery net6.0 1.26μs 0.764ns 2.86ns 0.0141 0 0 1.02 KB
#6225 ExecuteNonQuery netcoreapp3.1 1.78μs 1.56ns 6.04ns 0.0133 0 0 1.02 KB
#6225 ExecuteNonQuery net472 2.03μs 2.04ns 7.88ns 0.156 0.00101 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.27μs 0.534ns 2ns 0.0133 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.55μs 0.877ns 3.28ns 0.0132 0 0 976 B
master CallElasticsearch net472 2.62μs 1.67ns 6.47ns 0.158 0 0 995 B
master CallElasticsearchAsync net6.0 1.29μs 0.46ns 1.78ns 0.0136 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.66μs 0.788ns 2.95ns 0.014 0 0 1.02 KB
master CallElasticsearchAsync net472 2.57μs 1.6ns 5.97ns 0.167 0 0 1.05 KB
#6225 CallElasticsearch net6.0 1.27μs 0.61ns 2.2ns 0.0133 0 0 976 B
#6225 CallElasticsearch netcoreapp3.1 1.65μs 1.21ns 4.54ns 0.0131 0 0 976 B
#6225 CallElasticsearch net472 2.71μs 2.07ns 8.01ns 0.157 0 0 995 B
#6225 CallElasticsearchAsync net6.0 1.3μs 0.827ns 3.2ns 0.013 0 0 952 B
#6225 CallElasticsearchAsync netcoreapp3.1 1.64μs 0.591ns 2.29ns 0.0139 0 0 1.02 KB
#6225 CallElasticsearchAsync net472 2.73μs 2.32ns 8.97ns 0.167 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.24μs 0.418ns 1.56ns 0.0131 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.69μs 0.393ns 1.42ns 0.0127 0 0 952 B
master ExecuteAsync net472 1.85μs 0.57ns 2.21ns 0.145 0 0 915 B
#6225 ExecuteAsync net6.0 1.13μs 0.512ns 1.92ns 0.013 0 0 952 B
#6225 ExecuteAsync netcoreapp3.1 1.58μs 0.673ns 2.43ns 0.0128 0 0 952 B
#6225 ExecuteAsync net472 1.79μs 0.455ns 1.7ns 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.44μs 2.22ns 8.6ns 0.0311 0 0 2.31 KB
master SendAsync netcoreapp3.1 5.11μs 2.24ns 8.37ns 0.0383 0 0 2.85 KB
master SendAsync net472 7.19μs 2.21ns 8.57ns 0.493 0 0 3.12 KB
#6225 SendAsync net6.0 4.32μs 1.18ns 4.58ns 0.0321 0 0 2.31 KB
#6225 SendAsync netcoreapp3.1 5.24μs 7.89ns 30.6ns 0.0392 0 0 2.85 KB
#6225 SendAsync net472 7.27μs 3.42ns 11.8ns 0.495 0 0 3.12 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.55μs 0.814ns 3.04ns 0.0232 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.14μs 6.14ns 23.8ns 0.0214 0 0 1.64 KB
master EnrichedLog net472 2.65μs 1.55ns 6.02ns 0.249 0 0 1.57 KB
#6225 EnrichedLog net6.0 1.52μs 0.866ns 3.24ns 0.0228 0 0 1.64 KB
#6225 EnrichedLog netcoreapp3.1 2.24μs 0.922ns 3.33ns 0.0224 0 0 1.64 KB
#6225 EnrichedLog net472 2.7μs 2.07ns 7.73ns 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 120μs 115ns 446ns 0.0599 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 124μs 92.3ns 357ns 0 0 0 4.28 KB
master EnrichedLog net472 152μs 137ns 529ns 0.684 0.228 0 4.46 KB
#6225 EnrichedLog net6.0 120μs 192ns 742ns 0.0602 0 0 4.28 KB
#6225 EnrichedLog netcoreapp3.1 122μs 203ns 761ns 0 0 0 4.28 KB
#6225 EnrichedLog net472 152μs 109ns 423ns 0.679 0.226 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.99μs 0.917ns 3.55ns 0.0314 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.1μs 1.36ns 4.91ns 0.0286 0 0 2.2 KB
master EnrichedLog net472 4.82μs 1.16ns 4.47ns 0.32 0 0 2.02 KB
#6225 EnrichedLog net6.0 3.21μs 0.929ns 3.48ns 0.0305 0 0 2.2 KB
#6225 EnrichedLog netcoreapp3.1 4.28μs 2.16ns 8.36ns 0.03 0 0 2.2 KB
#6225 EnrichedLog net472 4.97μs 1.58ns 6.11ns 0.32 0 0 2.02 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.35μs 0.38ns 1.42ns 0.0162 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.73μs 0.869ns 3.25ns 0.0156 0 0 1.14 KB
master SendReceive net472 2.06μs 1.19ns 4.44ns 0.183 0 0 1.16 KB
#6225 SendReceive net6.0 1.33μs 0.467ns 1.75ns 0.0159 0 0 1.14 KB
#6225 SendReceive netcoreapp3.1 1.83μs 1.08ns 4.17ns 0.0155 0 0 1.14 KB
#6225 SendReceive net472 2.15μs 0.957ns 3.58ns 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.65μs 1.63ns 6.3ns 0.0226 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 3.96μs 2.55ns 9.89ns 0.022 0 0 1.65 KB
master EnrichedLog net472 4.35μs 3.38ns 13.1ns 0.322 0 0 2.04 KB
#6225 EnrichedLog net6.0 2.91μs 1.8ns 6.96ns 0.0217 0 0 1.6 KB
#6225 EnrichedLog netcoreapp3.1 4.08μs 9.37ns 35.1ns 0.0223 0 0 1.65 KB
#6225 EnrichedLog net472 4.44μs 2.19ns 8.2ns 0.322 0 0 2.04 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 399ns 0.725ns 2.81ns 0.00807 0 0 576 B
master StartFinishSpan netcoreapp3.1 590ns 1.42ns 5.51ns 0.00775 0 0 576 B
master StartFinishSpan net472 659ns 0.643ns 2.32ns 0.0916 0 0 578 B
master StartFinishScope net6.0 478ns 0.619ns 2.4ns 0.00968 0 0 696 B
master StartFinishScope netcoreapp3.1 705ns 1.06ns 4.1ns 0.0095 0 0 696 B
master StartFinishScope net472 844ns 1.45ns 5.62ns 0.105 0 0 658 B
#6225 StartFinishSpan net6.0 408ns 0.434ns 1.68ns 0.00807 0 0 576 B
#6225 StartFinishSpan netcoreapp3.1 562ns 0.819ns 3.17ns 0.00765 0 0 576 B
#6225 StartFinishSpan net472 611ns 1.54ns 5.96ns 0.0915 0 0 578 B
#6225 StartFinishScope net6.0 481ns 0.585ns 2.26ns 0.00982 0 0 696 B
#6225 StartFinishScope netcoreapp3.1 752ns 1.16ns 4.48ns 0.00935 0 0 696 B
#6225 StartFinishScope net472 865ns 2.03ns 7.87ns 0.104 0 0 658 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #6225

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑net6.0 1.196 656.26 784.99

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net6.0 656ns 0.758ns 2.94ns 0.00974 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 903ns 1.41ns 5.45ns 0.00941 0 0 696 B
master RunOnMethodBegin net472 1.06μs 1.46ns 5.66ns 0.105 0 0 658 B
#6225 RunOnMethodBegin net6.0 785ns 1.11ns 4.29ns 0.00951 0 0 696 B
#6225 RunOnMethodBegin netcoreapp3.1 942ns 1.28ns 4.95ns 0.00935 0 0 696 B
#6225 RunOnMethodBegin net472 1.14μs 3.23ns 12.5ns 0.104 0 0 658 B

@andrewlock

andrewlock commented Nov 4, 2024

Copy link
Copy Markdown
Member

Throughput/Crank Report ⚡

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 (6225) (11.352M)   : 0, 11351646
    master (11.247M)   : 0, 11246955
    benchmarks/2.9.0 (11.033M)   : 0, 11032866

    section Automatic
    This PR (6225) (7.219M)   : 0, 7218764
    master (7.407M)   : 0, 7406927
    benchmarks/2.9.0 (7.786M)   : 0, 7785853

    section Trace stats
    master (7.695M)   : 0, 7695476

    section Manual
    master (11.240M)   : 0, 11240426

    section Manual + Automatic
    This PR (6225) (6.792M)   : 0, 6792009
    master (6.871M)   : 0, 6870622

    section DD_TRACE_ENABLED=0
    master (10.206M)   : 0, 10206195

Loading
gantt
    title Throughput Linux arm64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (6225) (9.656M)   : 0, 9656005
    master (9.563M)   : 0, 9563014
    benchmarks/2.9.0 (9.495M)   : 0, 9494821

    section Automatic
    This PR (6225) (6.397M)   : 0, 6396564
    master (6.412M)   : 0, 6411572

    section Trace stats
    master (6.703M)   : 0, 6703390

    section Manual
    master (9.369M)   : 0, 9369266

    section Manual + Automatic
    This PR (6225) (5.983M)   : 0, 5982884
    master (5.978M)   : 0, 5977872

    section DD_TRACE_ENABLED=0
    master (8.996M)   : 0, 8996087

Loading
gantt
    title Throughput Windows x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (6225) (9.100M)   : 0, 9100181
    benchmarks/2.9.0 (10.020M)   : 0, 10019592

    section Automatic
    This PR (6225) (6.063M)   : 0, 6063464
    benchmarks/2.9.0 (7.255M)   : 0, 7255257

    section Manual + Automatic
    This PR (6225) (5.574M)   : 0, 5573857

Loading

@anna-git
anna-git force-pushed the anna/asm/ato-headers-success branch 3 times, most recently from 3336cdf to b033988 Compare November 11, 2024 16:39
@github-actions

github-actions Bot commented Nov 11, 2024

Copy link
Copy Markdown
Contributor

Snapshots difference summary

The following differences have been observed in committed snapshots. It is meant to help the reviewer.
The diff is simplistic, so please check some files anyway while we improve it.

6 occurrences of :

+      http.request.headers.content-length: 43,
+      http.request.headers.content-type: application/x-www-form-urlencoded; charset=utf-8,
[...]
+      http.request.headers.user-agent: Mistake Not...,
+      http.request.headers.x-forwarded-for: 86.242.244.246,

4 occurrences of :

+      http.request.headers.content-length: 44,
+      http.request.headers.content-type: application/x-www-form-urlencoded; charset=utf-8,
[...]
+      http.request.headers.user-agent: Mistake Not...,
+      http.request.headers.x-forwarded-for: 86.242.244.246,

4 occurrences of :

+      http.request.headers.content-length: 45,
+      http.request.headers.content-type: application/x-www-form-urlencoded; charset=utf-8,
[...]
+      http.request.headers.user-agent: Mistake Not...,
+      http.request.headers.x-forwarded-for: 86.242.244.246,

@anna-git
anna-git force-pushed the anna/asm/ato-headers-success branch from 601cffc to f8c6ed2 Compare November 12, 2024 10:52
@anna-git anna-git changed the title [ASM][ATO] try add headers and see [ASM][ATO] Collect request headers on login user events (failures and success) Nov 12, 2024
@anna-git
anna-git marked this pull request as ready for review November 12, 2024 16:33
@anna-git
anna-git requested review from a team as code owners November 12, 2024 16:33
setTag(Tags.AppSec.EventsUsers.LoginEvent.FailureSdkSource, "true");
setTag(Tags.AppSec.EventsUsers.LoginEvent.FailureUserId, userId);
setTag(Tags.AppSec.EventsUsers.LoginEvent.FailureUserExists, exists ? "true" : "false");
setTag(Tags.AppSec.EventsUsers.LoginEvent.FailureTrack, "true");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

NIT: While it was already there before this PR, maybe we could consider using constants for "true" and "false" to improve readability and decrease allocations (although the compiler might optimize that, but with this change we would be certain about this optimization)?

Using something like:

public static class Constants
{
public static readonly string TrueValue = "true";
public static readonly string FalseValue = "false";
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the idea, I'll do this in the next PR, fixing user id collection!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use actual constants though, not static readonly 😄

}

if (span is Span internalSpan)
if (metadata != null)

@NachoEchevarria NachoEchevarria Nov 15, 2024

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Small performance boost opportunity?

if (metadata is { Count: > 0 })
{
var successTagPrefix = $"{Tags.AppSec.EventsUsers.LoginEvent.Failure}.";
foreach (var kvp in metadata)
{
setTag(successTagPrefix + kvp.Key, kvp.Value);
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good idea, changed in 5eb2354

setTag($"_dd.{Tags.AppSec.Events}{eventName}.sdk", "true");

if (metadata != null)
if (metadata != null)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same as suggested earlier in with LoginEvent.Failure

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good idea, changed in 5eb2354

Comment thread tracer/src/Datadog.Trace/AppSec/EventTrackingSdk.cs
setTag($"{Tags.AppSec.Events}{eventName}.{kvp.Key}", kvp.Value);
}
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we call FillUp here too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good point I added it here as well in 5eb2354

@anna-git
anna-git force-pushed the anna/asm/ato-headers-success branch from f8c6ed2 to 5eb2354 Compare November 15, 2024 14:32
@anna-git
anna-git requested a review from a team as a code owner November 15, 2024 14:52

@NachoEchevarria NachoEchevarria left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@andrewlock andrewlock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM in general, just a few suggestions/questions

value = cookie.Value;
}

[MethodImpl(MethodImplOptions.NoInlining)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I assume this is to protect the CoreHttpContextStore, but is it really necessary? 🤔 If it's potentially going to crash, I would expect to see a try-catch in here...

@anna-git anna-git Nov 25, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Seems it's necessary as if it's inlined it will try to load Microsoft.AspNetCore.Hosting.Abstractions and crashes. I dont think we can try/catch it as it's assembly loading the moment this method is being called.. (?)
image

We had the discussion here 🤔


internal static void CollectHeaders(Span internalSpan)
{
var context = HttpContext.Current;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess this is safe to call, even if you're in a console app or something? Have you tested it, or are we already doing this elsewhere anyway?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes it doesn't crash from the Samples.ManualInstrumentation in Net4.6.2, it just returns null

setTag(Tags.AppSec.EventsUsers.LoginEvent.FailureSdkSource, "true");
setTag(Tags.AppSec.EventsUsers.LoginEvent.FailureUserId, userId);
setTag(Tags.AppSec.EventsUsers.LoginEvent.FailureUserExists, exists ? "true" : "false");
setTag(Tags.AppSec.EventsUsers.LoginEvent.FailureTrack, "true");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use actual constants though, not static readonly 😄

Comment thread tracer/src/Datadog.Trace/AppSec/EventTrackingSdk.cs Outdated
Comment thread tracer/src/Datadog.Trace/AppSec/EventTrackingSdk.cs Outdated
@anna-git
anna-git force-pushed the anna/asm/ato-headers-success branch from e051989 to 8fa918f Compare November 25, 2024 10:25
change snapshots

update snapshots
@anna-git
anna-git force-pushed the anna/asm/ato-headers-success branch from 8fa918f to 4f47cce Compare November 25, 2024 12:25
@anna-git
anna-git merged commit 0be4e8c into master Nov 25, 2024
@anna-git
anna-git deleted the anna/asm/ato-headers-success branch November 25, 2024 16:43
@github-actions github-actions Bot added this to the vNext-v3 milestone Nov 25, 2024
veerbia pushed a commit that referenced this pull request Dec 16, 2024
… success) (#6225)

## Summary of changes

Collect request headers on user events, whether it's a failure or
success. Adapt snapshosts

## Reason for change

Collect request [headers on user
events](https://datadoghq.atlassian.net/wiki/spaces/SAAL/pages/2186870984/HTTP+header+collection)


## Implementation details

## Test coverage

## Other details
<!-- Fixes #{issue} -->

<!-- ⚠️ 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 added the type:enhancement Improvement to an existing feature label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:asm type:enhancement Improvement to an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants