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

[Tracing] Send the Datadog-Entity-ID header, containing either the container-id or the cgroup inode if available (AIT-9281) #5058

Merged
merged 10 commits into from
Jan 22, 2024

Conversation

zacharycmontoya
Copy link
Collaborator

@zacharycmontoya zacharycmontoya commented Jan 13, 2024

Summary of changes

This PR sends the Datadog-Entity-ID header when the Datadog-Container-Id header is usually sent, containing either the container-id or the cgroup inode if available.

Reason for change

Using the cgroup inode will allow the trace-agent to retrieve the container-id, typically on cgroupv2 without UDS.

Implementation details

This adds a new Datadog-Entity-ID header which will also be used for correlating the trace with its running container. The possible values of this are:

  • If we have the container ID: cid-<container_id>
  • If we have the inode number: in-<inode_number>

A couple notes:

  • The calculation of the container ID and the value of the Datadog-Container-Id header is unchanged
  • The inode is a property of the file system entry, so we have to calculate the correct path on the filesystem and then make a system call to get the inode value. The host and the container share the same cgroup node located at /sys/fs/cgroup{$cgroup_node}, so this is the target path. To extract the inode, this implementation starts and runs a new stat process and we parse the output for the number.

Test coverage

  • Unit tests:
    • Add Datadog.Trace.Tests.PlatformHelpers.ContainerMetadataTests.Parse_Inode_From_Cgroup_File
      • This tests the parsing of the cgroups file, the subidrectory lookup from the cgroup mounts file, and the inode extraction operation.
      • Covers both cgroupsv2 and cgroupsv1 cases
  • Integration tests:
    • Extend Datadog.Trace.IntegrationTests.ContainerTaggingTests.Http_Headers_Contain_ContainerId test case
      • This has been tested in CI for cgroupsv1 behavior and locally for cgroupsv2 behavior
  • System Tests:

Other details

N/A

@zacharycmontoya zacharycmontoya self-assigned this Jan 13, 2024
@zacharycmontoya zacharycmontoya requested a review from a team as a code owner January 13, 2024 02:52
@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Jan 13, 2024

Datadog Report

Branch report: zach/ait-9281/entity-id
Commit report: 6e868d8
Test service: dd-trace-dotnet

✅ 0 Failed, 305760 Passed, 1528 Skipped, 58m 48.68s Wall Time

@andrewlock
Copy link
Member

andrewlock commented Jan 13, 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 (5058) - mean (74ms)  : 60, 87
     .   : milestone, 74,
    master - mean (71ms)  : 61, 80
     .   : milestone, 71,

    section CallTarget+Inlining+NGEN
    This PR (5058) - mean (956ms)  : 931, 980
     .   : milestone, 956,
    master - mean (947ms)  : 927, 968
     .   : milestone, 947,

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

    section CallTarget+Inlining+NGEN
    This PR (5058) - mean (692ms)  : 668, 716
     .   : milestone, 692,
    master - mean (701ms)  : 686, 717
     .   : milestone, 701,

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

    section CallTarget+Inlining+NGEN
    This PR (5058) - mean (648ms)  : 629, 666
     .   : milestone, 648,
    master - mean (654ms)  : 635, 673
     .   : milestone, 654,

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

    section CallTarget+Inlining+NGEN
    This PR (5058) - mean (1,068ms)  : 1041, 1094
     .   : milestone, 1068,
    master - mean (1,067ms)  : 1047, 1087
     .   : milestone, 1067,

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

    section CallTarget+Inlining+NGEN
    This PR (5058) - mean (1,049ms)  : 1020, 1077
     .   : milestone, 1049,
    master - mean (1,051ms)  : 1025, 1078
     .   : milestone, 1051,

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

    section CallTarget+Inlining+NGEN
    This PR (5058) - mean (1,022ms)  : 990, 1054
     .   : milestone, 1022,
    master - mean (1,019ms)  : 997, 1040
     .   : milestone, 1019,

Loading

@andrewlock
Copy link
Member

andrewlock commented Jan 13, 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 (5058) (11.871M)   : 0, 11870743
    master (11.687M)   : 0, 11687402
    benchmarks/2.9.0 (11.682M)   : 0, 11681575

    section Automatic
    This PR (5058) (8.152M)   : 0, 8151687
    master (8.038M)   : 0, 8037986
    benchmarks/2.9.0 (8.446M)   : 0, 8445739

    section Trace stats
    This PR (5058) (8.489M)   : 0, 8489005
    master (8.498M)   : 0, 8497861

    section Manual
    This PR (5058) (10.169M)   : 0, 10168757
    master (10.189M)   : 0, 10188958

    section Manual + Automatic
    This PR (5058) (7.674M)   : 0, 7674052
    master (7.565M)   : 0, 7564964

    section Version Conflict
    This PR (5058) (6.906M)   : 0, 6906228
    master (6.895M)   : 0, 6895116

Loading
gantt
    title Throughput Linux arm64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5058) (9.485M)   : 0, 9485038
    master (9.594M)   : 0, 9593979
    benchmarks/2.9.0 (9.657M)   : 0, 9656830

    section Automatic
    This PR (5058) (6.637M)   : 0, 6637351
    master (6.645M)   : 0, 6645268

    section Trace stats
    This PR (5058) (6.724M)   : 0, 6723795
    master (6.724M)   : 0, 6724266

    section Manual
    This PR (5058) (8.238M)   : 0, 8238141
    master (8.055M)   : 0, 8054730

    section Manual + Automatic
    This PR (5058) (6.284M)   : 0, 6283954
    master (6.196M)   : 0, 6195700

    section Version Conflict
    This PR (5058) (5.726M)   : 0, 5726239
    master (5.584M)   : 0, 5584422

Loading
gantt
    title Throughput Windows x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5058) (10.227M)   : 0, 10226675
    benchmarks/2.9.0 (10.207M)   : 0, 10206890

    section Automatic
    This PR (5058) (7.004M)   : 0, 7003619
    benchmarks/2.9.0 (7.362M)   : 0, 7361712

    section Trace stats
    This PR (5058) (7.351M)   : 0, 7350571

    section Manual
    This PR (5058) (8.852M)   : 0, 8851984

    section Manual + Automatic
    This PR (5058) (6.851M)   : 0, 6850519

    section Version Conflict
    This PR (5058) (6.138M)   : 0, 6138481

Loading
gantt
    title Throughput Linux x64 (ASM) (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    master (7.151M)   : 0, 7151386
    benchmarks/2.9.0 (7.448M)   : 0, 7447634

    section No attack
    master (1.704M)   : 0, 1704139
    benchmarks/2.9.0 (3.135M)   : 0, 3134564

    section Attack
    master (1.374M)   : 0, 1374460
    benchmarks/2.9.0 (2.468M)   : 0, 2467773

    section Blocking
    master (2.981M)   : 0, 2981218

    section IAST default
    master (6.084M)   : 0, 6084230

    section IAST full
    master (5.330M)   : 0, 5329757

    section Base vuln
    master (0.932M)   : 0, 931558

    section IAST vuln
    master (0.850M)   : 0, 850132

Loading

@andrewlock
Copy link
Member

andrewlock commented Jan 13, 2024

Benchmarks Report 🐌

Benchmarks for #5058 compared to master:

  • 2 benchmarks are faster, with geometric mean 1.151
  • 3 benchmarks are slower, with geometric mean 1.212
  • 3 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.68μs 47.8ns 283ns 0.0216 0.00866 0 7.48 KB
master StartStopWithChild netcoreapp3.1 10.6μs 45.4ns 192ns 0.037 0.0158 0 7.58 KB
master StartStopWithChild net472 17.2μs 53ns 205ns 1.33 0.349 0.111 7.95 KB
#5058 StartStopWithChild net6.0 8.79μs 49.3ns 323ns 0.0187 0.00934 0 7.48 KB
#5058 StartStopWithChild netcoreapp3.1 10.9μs 60ns 345ns 0.0324 0.0162 0 7.58 KB
#5058 StartStopWithChild net472 17.1μs 52ns 201ns 1.33 0.335 0.103 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 478μs 255ns 955ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 634μs 326ns 1.26μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 804μs 158ns 548ns 0.401 0 0 3.3 KB
#5058 WriteAndFlushEnrichedTraces net6.0 461μs 375ns 1.4μs 0 0 0 2.7 KB
#5058 WriteAndFlushEnrichedTraces netcoreapp3.1 636μs 177ns 685ns 0 0 0 2.7 KB
#5058 WriteAndFlushEnrichedTraces net472 781μs 336ns 1.26μs 0.388 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 39.4μs 45.3ns 169ns 0.0198 0 0 1.77 KB
master AllCycleSimpleBody netcoreapp3.1 41.2μs 30.9ns 116ns 0.0208 0 0 1.74 KB
master AllCycleSimpleBody net472 44.8μs 19.9ns 71.7ns 0.27 0 0 1.81 KB
master AllCycleMoreComplexBody net6.0 201μs 71.6ns 277ns 0.1 0 0 9.25 KB
master AllCycleMoreComplexBody netcoreapp3.1 217μs 214ns 829ns 0.106 0 0 9.14 KB
master AllCycleMoreComplexBody net472 226μs 117ns 454ns 1.47 0 0 9.32 KB
master ObjectExtractorSimpleBody net6.0 142ns 0.143ns 0.556ns 0.00396 0 0 280 B
master ObjectExtractorSimpleBody netcoreapp3.1 203ns 0.223ns 0.864ns 0.00369 0 0 272 B
master ObjectExtractorSimpleBody net472 173ns 0.133ns 0.48ns 0.0446 0 0 281 B
master ObjectExtractorMoreComplexBody net6.0 3.05μs 4.09ns 15.3ns 0.0533 0 0 3.78 KB
master ObjectExtractorMoreComplexBody netcoreapp3.1 3.95μs 1.55ns 5.81ns 0.0495 0 0 3.69 KB
master ObjectExtractorMoreComplexBody net472 3.98μs 5.01ns 18.7ns 0.602 0.00593 0 3.8 KB
#5058 AllCycleSimpleBody net6.0 39.4μs 29.8ns 107ns 0.0196 0 0 1.77 KB
#5058 AllCycleSimpleBody netcoreapp3.1 42.9μs 102ns 393ns 0.0211 0 0 1.74 KB
#5058 AllCycleSimpleBody net472 44.9μs 14.3ns 55.6ns 0.27 0 0 1.81 KB
#5058 AllCycleMoreComplexBody net6.0 201μs 305ns 1.18μs 0.0994 0 0 9.25 KB
#5058 AllCycleMoreComplexBody netcoreapp3.1 213μs 316ns 1.22μs 0.106 0 0 9.14 KB
#5058 AllCycleMoreComplexBody net472 226μs 104ns 402ns 1.47 0 0 9.32 KB
#5058 ObjectExtractorSimpleBody net6.0 142ns 0.111ns 0.43ns 0.0039 0 0 280 B
#5058 ObjectExtractorSimpleBody netcoreapp3.1 198ns 0.11ns 0.411ns 0.00371 0 0 272 B
#5058 ObjectExtractorSimpleBody net472 165ns 0.141ns 0.527ns 0.0446 0 0 281 B
#5058 ObjectExtractorMoreComplexBody net6.0 3.02μs 2.99ns 11.6ns 0.0528 0 0 3.78 KB
#5058 ObjectExtractorMoreComplexBody netcoreapp3.1 4.27μs 2.32ns 9ns 0.0512 0 0 3.69 KB
#5058 ObjectExtractorMoreComplexBody net472 3.78μs 3.04ns 11ns 0.603 0.00567 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 54.2μs 25.7ns 96.1ns 0.222 0 0 16.06 KB
master RunWaf(args=NestedMap (10)) netcoreapp3.1 64.7μs 53.9ns 194ns 0.194 0 0 16.06 KB
master RunWaf(args=NestedMap (10)) net472 100μs 487ns 2.07μs 2.54 0.0959 0 16.14 KB
master RunWafTwice(args=NestedMap (10)) net6.0 57.7μs 306ns 1.62μs 0.234 0 0 16.6 KB
master RunWafTwice(args=NestedMap (10)) netcoreapp3.1 71.1μs 265ns 957ns 0.212 0 0 16.58 KB
master RunWafTwice(args=NestedMap (10)) net472 107μs 494ns 1.91μs 2.63 0.107 0 16.69 KB
master RunWafWithAttack(args=Neste(...)tack) [22]) net6.0 112μs 77.6ns 301ns 0.295 0 0 22.41 KB
master RunWafWithAttack(args=Neste(...)tack) [22]) netcoreapp3.1 133μs 679ns 3.18μs 0.256 0 0 22.36 KB
master RunWafWithAttack(args=Neste(...)tack) [22]) net472 164μs 761ns 2.95μs 3.55 0.161 0 22.7 KB
master RunWaf(args=NestedMap (100)) net6.0 105μs 220ns 851ns 0.417 0 0 32.76 KB
master RunWaf(args=NestedMap (100)) netcoreapp3.1 133μs 315ns 1.22μs 0.402 0 0 33.33 KB
master RunWaf(args=NestedMap (100)) net472 195μs 150ns 562ns 5.27 0.37 0 33.67 KB
master RunWafTwice(args=NestedMap (100)) net6.0 107μs 339ns 1.27μs 0.428 0 0 33.3 KB
master RunWafTwice(args=NestedMap (100)) netcoreapp3.1 141μs 127ns 493ns 0.413 0 0 33.86 KB
master RunWafTwice(args=NestedMap (100)) net472 201μs 607ns 2.35μs 5.44 0.396 0 34.22 KB
master RunWafWithAttack(args=Neste(...)tack) [23]) net6.0 162μs 56.1ns 210ns 0.517 0 0 39.1 KB
master RunWafWithAttack(args=Neste(...)tack) [23]) netcoreapp3.1 204μs 385ns 1.49μs 0.488 0 0 39.63 KB
master RunWafWithAttack(args=Neste(...)tack) [23]) net472 253μs 140ns 485ns 6.38 0.51 0 40.23 KB
master RunWaf(args=NestedMap (20)) net6.0 109μs 14ns 52.2ns 0.453 0 0 32.18 KB
master RunWaf(args=NestedMap (20)) netcoreapp3.1 134μs 437ns 1.69μs 0.438 0 0 32.3 KB
master RunWaf(args=NestedMap (20)) net472 188μs 904ns 3.62μs 5.1 0.371 0 32.63 KB
master RunWafTwice(args=NestedMap (20)) net6.0 103μs 34ns 123ns 0.464 0 0 32.72 KB
master RunWafTwice(args=NestedMap (20)) netcoreapp3.1 138μs 725ns 3.7μs 0.399 0 0 32.82 KB
master RunWafTwice(args=NestedMap (20)) net472 198μs 857ns 3.32μs 5.22 0.386 0 33.19 KB
master RunWafWithAttack(args=Neste(...)tack) [22]) net6.0 161μs 149ns 515ns 0.543 0 0 38.53 KB
master RunWafWithAttack(args=Neste(...)tack) [22]) netcoreapp3.1 198μs 80.2ns 289ns 0.512 0 0 38.6 KB
master RunWafWithAttack(args=Neste(...)tack) [22]) net472 256μs 1.1μs 4.27μs 6.21 0.507 0 39.2 KB
#5058 RunWaf(args=NestedMap (10)) net6.0 54.5μs 26.9ns 104ns 0.211 0 0 16.06 KB
#5058 RunWaf(args=NestedMap (10)) netcoreapp3.1 71.6μs 368ns 1.84μs 0.203 0 0 16.06 KB
#5058 RunWaf(args=NestedMap (10)) net472 96.1μs 72.2ns 270ns 2.53 0.0956 0 16.14 KB
#5058 RunWafTwice(args=NestedMap (10)) net6.0 59.4μs 35.5ns 128ns 0.213 0 0 16.6 KB
#5058 RunWafTwice(args=NestedMap (10)) netcoreapp3.1 71.7μs 401ns 2.69μs 0.224 0 0 16.58 KB
#5058 RunWafTwice(args=NestedMap (10)) net472 104μs 75.7ns 283ns 2.64 0.104 0 16.69 KB
#5058 RunWafWithAttack(args=Neste(...)tack) [22]) net6.0 115μs 232ns 898ns 0.283 0 0 22.41 KB
#5058 RunWafWithAttack(args=Neste(...)tack) [22]) netcoreapp3.1 131μs 496ns 1.92μs 0.255 0 0 22.36 KB
#5058 RunWafWithAttack(args=Neste(...)tack) [22]) net472 161μs 159ns 614ns 3.6 0.16 0 22.7 KB
#5058 RunWaf(args=NestedMap (100)) net6.0 111μs 54.6ns 211ns 0.437 0 0 32.76 KB
#5058 RunWaf(args=NestedMap (100)) netcoreapp3.1 133μs 742ns 4.51μs 0.399 0 0 33.33 KB
#5058 RunWaf(args=NestedMap (100)) net472 192μs 93ns 360ns 5.33 0.374 0 33.67 KB
#5058 RunWafTwice(args=NestedMap (100)) net6.0 110μs 37.7ns 146ns 0.461 0 0 33.3 KB
#5058 RunWafTwice(args=NestedMap (100)) netcoreapp3.1 135μs 718ns 3.66μs 0.459 0 0 33.86 KB
#5058 RunWafTwice(args=NestedMap (100)) net472 204μs 218ns 845ns 5.38 0.391 0 34.23 KB
#5058 RunWafWithAttack(args=Neste(...)tack) [23]) net6.0 166μs 635ns 2.46μs 0.482 0 0 39.1 KB
#5058 RunWafWithAttack(args=Neste(...)tack) [23]) netcoreapp3.1 201μs 1.07μs 5.67μs 0.501 0 0 39.63 KB
#5058 RunWafWithAttack(args=Neste(...)tack) [23]) net472 265μs 273ns 1.06μs 6.29 0.513 0 40.23 KB
#5058 RunWaf(args=NestedMap (20)) net6.0 109μs 171ns 662ns 0.427 0 0 32.18 KB
#5058 RunWaf(args=NestedMap (20)) netcoreapp3.1 130μs 420ns 1.63μs 0.4 0 0 32.3 KB
#5058 RunWaf(args=NestedMap (20)) net472 192μs 717ns 2.78μs 5.19 0.37 0 32.63 KB
#5058 RunWafTwice(args=NestedMap (20)) net6.0 112μs 55.9ns 194ns 0.431 0 0 32.72 KB
#5058 RunWafTwice(args=NestedMap (20)) netcoreapp3.1 135μs 39.5ns 142ns 0.406 0 0 32.82 KB
#5058 RunWafTwice(args=NestedMap (20)) net472 193μs 145ns 542ns 5.22 0.386 0 33.19 KB
#5058 RunWafWithAttack(args=Neste(...)tack) [22]) net6.0 157μs 131ns 508ns 0.547 0 0 38.53 KB
#5058 RunWafWithAttack(args=Neste(...)tack) [22]) netcoreapp3.1 195μs 277ns 998ns 0.494 0 0 38.6 KB
#5058 RunWafWithAttack(args=Neste(...)tack) [22]) net472 254μs 226ns 876ns 6.2 0.506 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 145ns 563ns 0.171 0 0 18.25 KB
master SendRequest netcoreapp3.1 195μs 222ns 831ns 0.192 0 0 20.41 KB
master SendRequest net472 0.000948ns 0.000384ns 0.00149ns 0 0 0 0 b
#5058 SendRequest net6.0 174μs 154ns 597ns 0.174 0 0 18.25 KB
#5058 SendRequest netcoreapp3.1 195μs 233ns 870ns 0.193 0 0 20.41 KB
#5058 SendRequest net472 0.00071ns 0.000196ns 0.00076ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Fewer allocations 🎉

Fewer allocations 🎉 in #5058

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net6.0 41.72 KB 41.41 KB -311 B -0.75%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 554μs 196ns 759ns 0.556 0 0 41.72 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 659μs 1.82μs 7.03μs 0.329 0 0 41.65 KB
master WriteAndFlushEnrichedTraces net472 840μs 3.5μs 12.6μs 8.45 2.53 0.422 53.23 KB
#5058 WriteAndFlushEnrichedTraces net6.0 542μs 349ns 1.31μs 0.532 0 0 41.41 KB
#5058 WriteAndFlushEnrichedTraces netcoreapp3.1 665μs 719ns 2.79μs 0.331 0 0 41.86 KB
#5058 WriteAndFlushEnrichedTraces net472 845μs 4μs 15.5μs 8.33 2.5 0.417 53.23 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 0.84ns 3.25ns 0.0104 0 0 768 B
master ExecuteNonQuery netcoreapp3.1 1.51μs 1.01ns 3.89ns 0.0106 0 0 768 B
master ExecuteNonQuery net472 1.83μs 1.36ns 5.08ns 0.116 0 0 730 B
#5058 ExecuteNonQuery net6.0 1.12μs 0.612ns 2.29ns 0.0106 0 0 768 B
#5058 ExecuteNonQuery netcoreapp3.1 1.58μs 0.692ns 2.68ns 0.0103 0 0 768 B
#5058 ExecuteNonQuery net472 1.79μs 5.17ns 20ns 0.116 0 0 730 B
Benchmarks.Trace.ElasticsearchBenchmark - Faster 🎉 Same allocations ✔️

Faster 🎉 in #5058

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync‑net6.0 1.175 1,410.98 1,200.78

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master CallElasticsearch net6.0 1.23μs 1.41ns 5.28ns 0.0128 0 0 936 B
master CallElasticsearch netcoreapp3.1 1.51μs 0.703ns 2.63ns 0.0129 0 0 936 B
master CallElasticsearch net472 2.48μs 0.801ns 3.1ns 0.151 0 0 955 B
master CallElasticsearchAsync net6.0 1.41μs 1.47ns 5.68ns 0.0128 0 0 912 B
master CallElasticsearchAsync netcoreapp3.1 1.79μs 5.2ns 18.8ns 0.013 0 0 984 B
master CallElasticsearchAsync net472 2.78μs 2.4ns 8.99ns 0.16 0 0 1.01 KB
#5058 CallElasticsearch net6.0 1.25μs 0.316ns 1.22ns 0.0132 0 0 936 B
#5058 CallElasticsearch netcoreapp3.1 1.57μs 1.74ns 6.74ns 0.0127 0 0 936 B
#5058 CallElasticsearch net472 2.44μs 0.939ns 3.64ns 0.151 0 0 955 B
#5058 CallElasticsearchAsync net6.0 1.2μs 0.185ns 0.669ns 0.0127 0 0 912 B
#5058 CallElasticsearchAsync netcoreapp3.1 1.64μs 1.01ns 3.77ns 0.0133 0 0 984 B
#5058 CallElasticsearchAsync net472 2.58μs 0.769ns 2.88ns 0.161 0 0 1.01 KB
Benchmarks.Trace.GraphQLBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #5058

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync‑net472 1.126 1,712.34 1,927.57

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteAsync net6.0 1.25μs 3.06ns 13.3ns 0.0127 0 0 912 B
master ExecuteAsync netcoreapp3.1 1.66μs 2.35ns 8.78ns 0.0124 0 0 912 B
master ExecuteAsync net472 1.71μs 1.12ns 4.33ns 0.139 0 0 875 B
#5058 ExecuteAsync net6.0 1.35μs 0.562ns 2.1ns 0.0129 0 0 912 B
#5058 ExecuteAsync netcoreapp3.1 1.63μs 1.04ns 4.03ns 0.0122 0 0 912 B
#5058 ExecuteAsync net472 1.93μs 1ns 3.75ns 0.138 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μs 1.76ns 6.83ns 0.0301 0 0 2.1 KB
master SendAsync netcoreapp3.1 4.95μs 1.59ns 5.94ns 0.0346 0 0 2.63 KB
master SendAsync net472 7.65μs 3.09ns 12ns 0.524 0 0 3.31 KB
#5058 SendAsync net6.0 4.06μs 1.66ns 5.99ns 0.0285 0 0 2.1 KB
#5058 SendAsync netcoreapp3.1 5.1μs 3.34ns 12.9ns 0.0357 0 0 2.63 KB
#5058 SendAsync net472 7.75μs 3.08ns 11.5ns 0.523 0 0 3.31 KB
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #5058

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1 200.89 KB 201.94 KB 1.05 KB 0.52%

Fewer allocations 🎉 in #5058

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net472 61.25 KB 60.73 KB -520 B -0.85%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 214.22 KB 203.53 KB -10.7 KB -4.99%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StringConcatBenchmark net6.0 60.4μs 1.01μs 10μs 0 0 0 43.44 KB
master StringConcatBenchmark netcoreapp3.1 53.2μs 215ns 745ns 0 0 0 42.64 KB
master StringConcatBenchmark net472 37.6μs 128ns 461ns 0 0 0 61.25 KB
master StringConcatAspectBenchmark net6.0 290μs 1.99μs 19.1μs 0 0 0 214.22 KB
master StringConcatAspectBenchmark netcoreapp3.1 284μs 2.62μs 24μs 0 0 0 200.89 KB
master StringConcatAspectBenchmark net472 244μs 4.02μs 38.6μs 0 0 0 221.18 KB
#5058 StringConcatBenchmark net6.0 62.2μs 693ns 6.79μs 0 0 0 43.44 KB
#5058 StringConcatBenchmark netcoreapp3.1 55.1μs 315ns 2.25μs 0 0 0 42.64 KB
#5058 StringConcatBenchmark net472 38μs 193ns 904ns 0 0 0 60.73 KB
#5058 StringConcatAspectBenchmark net6.0 310μs 9.32μs 91.8μs 0 0 0 203.53 KB
#5058 StringConcatAspectBenchmark netcoreapp3.1 271μs 4.92μs 46.4μs 0 0 0 201.94 KB
#5058 StringConcatAspectBenchmark net472 238μs 3.28μs 31.4μs 0 0 0 221.18 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.42μs 0.512ns 1.84ns 0.0221 0 0 1.57 KB
master EnrichedLog netcoreapp3.1 2.25μs 1.27ns 4.57ns 0.0214 0 0 1.57 KB
master EnrichedLog net472 2.74μs 4.28ns 16.6ns 0.237 0 0 1.5 KB
#5058 EnrichedLog net6.0 1.5μs 0.872ns 3.38ns 0.0217 0 0 1.57 KB
#5058 EnrichedLog netcoreapp3.1 2.3μs 1.24ns 4.64ns 0.0207 0 0 1.57 KB
#5058 EnrichedLog net472 2.68μs 1.82ns 7.04ns 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 116ns 449ns 0 0 0 4.21 KB
master EnrichedLog netcoreapp3.1 117μs 132ns 511ns 0.0591 0 0 4.21 KB
master EnrichedLog net472 149μs 70.7ns 274ns 0.668 0.223 0 4.39 KB
#5058 EnrichedLog net6.0 112μs 71.5ns 277ns 0.0558 0 0 4.21 KB
#5058 EnrichedLog netcoreapp3.1 117μs 117ns 453ns 0.0587 0 0 4.21 KB
#5058 EnrichedLog net472 148μs 148ns 574ns 0.661 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.08μs 0.662ns 2.48ns 0.0293 0 0 2.13 KB
master EnrichedLog netcoreapp3.1 4.19μs 1.89ns 7.06ns 0.0273 0 0 2.13 KB
master EnrichedLog net472 4.87μs 1.95ns 7.56ns 0.308 0 0 1.95 KB
#5058 EnrichedLog net6.0 3.08μs 0.951ns 3.68ns 0.0292 0 0 2.13 KB
#5058 EnrichedLog netcoreapp3.1 4.05μs 1.18ns 4.57ns 0.0283 0 0 2.13 KB
#5058 EnrichedLog net472 4.92μs 1.2ns 4.66ns 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.32μs 0.554ns 2.14ns 0.0152 0 0 1.1 KB
master SendReceive netcoreapp3.1 1.75μs 0.533ns 1.99ns 0.0151 0 0 1.1 KB
master SendReceive net472 2.09μs 1.52ns 5.69ns 0.176 0 0 1.12 KB
#5058 SendReceive net6.0 1.3μs 0.612ns 2.37ns 0.0155 0 0 1.1 KB
#5058 SendReceive netcoreapp3.1 1.69μs 0.545ns 2.11ns 0.0149 0 0 1.1 KB
#5058 SendReceive net472 2.14μs 1.31ns 4.73ns 0.176 0 0 1.12 KB
Benchmarks.Trace.SerilogBenchmark - Faster 🎉 Same allocations ✔️

Faster 🎉 in #5058

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SerilogBenchmark.EnrichedLog‑net6.0 1.128 2,969.44 2,631.70

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 2.97μs 1.7ns 6.58ns 0.0208 0 0 1.53 KB
master EnrichedLog netcoreapp3.1 3.95μs 1.8ns 6.97ns 0.0197 0 0 1.58 KB
master EnrichedLog net472 4.4μs 1.91ns 7.13ns 0.312 0 0 1.97 KB
#5058 EnrichedLog net6.0 2.63μs 1.06ns 3.98ns 0.0211 0 0 1.53 KB
#5058 EnrichedLog netcoreapp3.1 3.9μs 1.21ns 4.69ns 0.0214 0 0 1.58 KB
#5058 EnrichedLog net472 4.31μs 1.94ns 7.5ns 0.312 0 0 1.97 KB
Benchmarks.Trace.SpanBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #5058

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑netcoreapp3.1 1.175 655.77 770.77

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 514ns 0.212ns 0.819ns 0.00757 0 0 536 B
master StartFinishSpan netcoreapp3.1 656ns 0.392ns 1.52ns 0.00715 0 0 536 B
master StartFinishSpan net472 808ns 0.203ns 0.76ns 0.0853 0 0 538 B
master StartFinishScope net6.0 627ns 0.208ns 0.78ns 0.00899 0 0 656 B
master StartFinishScope netcoreapp3.1 834ns 0.485ns 1.88ns 0.00878 0 0 656 B
master StartFinishScope net472 963ns 0.429ns 1.66ns 0.0979 0 0 618 B
#5058 StartFinishSpan net6.0 520ns 0.19ns 0.735ns 0.00756 0 0 536 B
#5058 StartFinishSpan netcoreapp3.1 767ns 2.04ns 7.88ns 0.00711 0 0 536 B
#5058 StartFinishSpan net472 754ns 0.269ns 1.04ns 0.0852 0 0 538 B
#5058 StartFinishScope net6.0 608ns 0.2ns 0.747ns 0.00934 0 0 656 B
#5058 StartFinishScope netcoreapp3.1 820ns 0.976ns 3.78ns 0.00905 0 0 656 B
#5058 StartFinishScope net472 905ns 1.29ns 4.99ns 0.0978 0 0 618 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #5058

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑net6.0 1.344 569.26 765.24

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net6.0 569ns 0.162ns 0.627ns 0.00933 0 0 656 B
master RunOnMethodBegin netcoreapp3.1 960ns 0.758ns 2.94ns 0.00871 0 0 656 B
master RunOnMethodBegin net472 1.06μs 0.363ns 1.41ns 0.0978 0 0 618 B
#5058 RunOnMethodBegin net6.0 765ns 0.311ns 1.21ns 0.00924 0 0 656 B
#5058 RunOnMethodBegin netcoreapp3.1 894ns 2.29ns 8.88ns 0.00906 0 0 656 B
#5058 RunOnMethodBegin net472 1.04μs 0.491ns 1.9ns 0.0977 0 0 618 B

Copy link
Member

@andrewlock andrewlock left a comment

Choose a reason for hiding this comment

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

LGTM, just one question about the Process code 🙂

/// </list>
/// </summary>
/// <returns>The entity id or <c>null</c>.</returns>
public static string GetEntityId()
Copy link
Member

Choose a reason for hiding this comment

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

nit: Might be nice to sprinkle some #nullable enable in this file, but obviously not a requirement!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mm I think I'll keep this file without nullable just to keep this diff easy to read. I'll come back later for this though!

Comment on lines 223 to 224
string output = process.StandardOutput.ReadToEnd();
var isExited = process.WaitForExit(1000);
Copy link
Member

Choose a reason for hiding this comment

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

I was always struggle to remember, but aren't there race conditions around doing this? 🤔 I thought that was the main reason why our test ProcessHelper is written the way it is?

EDIT: in fact, we already have a helper for handling this I think, maybe we should extend that instead (to allow changing the timeout, for example)

public static async Task<CommandOutput?> RunCommandAsync(Command command, string? input = null)

Copy link
Collaborator Author

@zacharycmontoya zacharycmontoya Jan 20, 2024

Choose a reason for hiding this comment

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

So I created a new overload in ec65d27 to ProcessHelper to keep this synchronous. I wonder what the team will think 👀

tracer/src/Datadog.Trace/Telemetry/TelemetryConstants.cs Outdated Show resolved Hide resolved
- Use Datadog.Trace.AgentHttpHeaderNames constants for Datadog.Trace.Telemetry.TelemetryConstants values
- Refactor some of the LINQ in ContainerMetadata.cs
- Remove inode filesystem implementation in the test code, use the one in the product code
…ssHelpers.RunCommand, which is a synchronous rewrite of ProcessHelpers.RunCommandAsync
Copy link
Member

@tonyredondo tonyredondo left a comment

Choose a reason for hiding this comment

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

LGTM, just an small question.

@zacharycmontoya zacharycmontoya merged commit b314b9c into master Jan 22, 2024
53 of 55 checks passed
@zacharycmontoya zacharycmontoya deleted the zach/ait-9281/entity-id branch January 22, 2024 23:33
@github-actions github-actions bot added this to the vNext milestone Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants