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

fix container tagging for Alpine containers #6505

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

wantsui
Copy link

@wantsui wantsui commented Jan 6, 2025

Summary of changes

Swap out --printf=%i for -c %i because in alpine images --printf=%i is invalid, which prevents container tagging from working when using alpine based images.

Example:

docker run --rm --platform linux/amd64 -it mcr.microsoft.com/dotnet/sdk:8.0-alpine stat --printf=%i /proc/self/ns/cgroup

returns: stat: unrecognized option: printf=%i.

This fix swaps it out for the -c %i option which exists in alpine containers.

Reason for change

Implementation details

Test coverage

Other details

@github-actions github-actions bot added the area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) label Jan 6, 2025
@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Jan 6, 2025

Datadog Report

Branch report: wantsui/update-stat-for-container-tagging
Commit report: 1113e7b
Test service: dd-trace-dotnet

❌ 7 Failed (0 Known Flaky), 236107 Passed, 2062 Skipped, 18h 53m 42.81s Total Time

❌ Failed Tests (7)

This report shows up to 5 failed tests.

  • EarlyFlakeDetection - Datadog.Trace.ClrProfiler.IntegrationTests.CI.MsTestV2EvpTests - Details

    Expand for error
     The sample did not exit in 600000ms. Memory dump taken: True. Killing process.
    
  • EarlyFlakeDetection - Datadog.Trace.ClrProfiler.IntegrationTests.CI.TcpXUnitEvpTests - Details

    Expand for error
     The sample did not exit in 600000ms. Memory dump taken: True. Killing process.
    
  • Parse_TryGetInode - Datadog.Trace.Tests.PlatformHelpers.ContainerMetadataTests - Details

    Expand for error
     Expected success to be true, but found False.
    
  • Parse_TryGetInode - Datadog.Trace.Tests.PlatformHelpers.ContainerMetadataTests - Details

    Expand for error
     Expected success to be true, but found False.
    
  • Parse_TryGetInode - Datadog.Trace.Tests.PlatformHelpers.ContainerMetadataTests - Details

    Expand for error
     Expected success to be true, but found False.
    

@andrewlock
Copy link
Member

andrewlock commented Jan 6, 2025

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

    section CallTarget+Inlining+NGEN
    This PR (6505) - mean (979ms)  : 955, 1003
     .   : milestone, 979,
    master - mean (977ms)  : 958, 996
     .   : milestone, 977,

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

    section CallTarget+Inlining+NGEN
    This PR (6505) - mean (680ms)  : 667, 693
     .   : milestone, 680,
    master - mean (679ms)  : 662, 695
     .   : milestone, 679,

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

    section CallTarget+Inlining+NGEN
    This PR (6505) - mean (634ms)  : 612, 655
     .   : milestone, 634,
    master - mean (638ms)  : 619, 656
     .   : milestone, 638,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6505) - mean (194ms)  : 189, 198
     .   : milestone, 194,
    master - mean (194ms)  : 189, 199
     .   : milestone, 194,

    section CallTarget+Inlining+NGEN
    This PR (6505) - mean (1,106ms)  : 1075, 1137
     .   : milestone, 1106,
    master - mean (1,102ms)  : 1068, 1135
     .   : milestone, 1102,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6505) - mean (279ms)  : 274, 284
     .   : milestone, 279,
    master - mean (279ms)  : 274, 284
     .   : milestone, 279,

    section CallTarget+Inlining+NGEN
    This PR (6505) - mean (872ms)  : 849, 896
     .   : milestone, 872,
    master - mean (873ms)  : 846, 900
     .   : milestone, 873,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6505) - mean (267ms)  : 264, 270
     .   : milestone, 267,
    master - mean (267ms)  : 263, 271
     .   : milestone, 267,

    section CallTarget+Inlining+NGEN
    This PR (6505) - mean (853ms)  : 823, 883
     .   : milestone, 853,
    master - mean (850ms)  : 814, 886
     .   : milestone, 850,

Loading

@andrewlock
Copy link
Member

andrewlock commented Jan 6, 2025

Benchmarks Report for tracer 🐌

Benchmarks for #6505 compared to master:

  • 4 benchmarks are faster, with geometric mean 1.140
  • 2 benchmarks are slower, with geometric mean 1.153
  • 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 8.2μs 44.8ns 273ns 0.0156 0.00781 0 5.61 KB
master StartStopWithChild netcoreapp3.1 10.3μs 57.5ns 368ns 0.0199 0.00997 0 5.8 KB
master StartStopWithChild net472 16.6μs 45.6ns 171ns 1.06 0.32 0.109 6.21 KB
#6505 StartStopWithChild net6.0 8.24μs 45.3ns 260ns 0.0167 0.00834 0 5.61 KB
#6505 StartStopWithChild netcoreapp3.1 10.2μs 47.7ns 197ns 0.02 0.01 0 5.8 KB
#6505 StartStopWithChild net472 16.4μs 66.2ns 256ns 1.04 0.303 0.104 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 493μs 389ns 1.4μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 655μs 630ns 2.44μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 856μs 749ns 2.9μs 0.428 0 0 3.3 KB
#6505 WriteAndFlushEnrichedTraces net6.0 480μs 327ns 1.22μs 0 0 0 2.7 KB
#6505 WriteAndFlushEnrichedTraces netcoreapp3.1 659μs 608ns 2.35μs 0 0 0 2.7 KB
#6505 WriteAndFlushEnrichedTraces net472 857μs 735ns 2.75μs 0.428 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 157μs 1.02μs 10μs 0.142 0 0 14.47 KB
master SendRequest netcoreapp3.1 168μs 1.17μs 11.5μs 0.159 0 0 17.27 KB
master SendRequest net472 0.00308ns 0.000978ns 0.00366ns 0 0 0 0 b
#6505 SendRequest net6.0 157μs 1.38μs 13.6μs 0.143 0 0 14.48 KB
#6505 SendRequest netcoreapp3.1 176μs 1.51μs 14.9μs 0.166 0 0 17.27 KB
#6505 SendRequest net472 0.00256ns 0.00134ns 0.00521ns 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 585μs 3.28μs 21.3μs 0.604 0 0 41.64 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 689μs 3.78μs 27.8μs 0.368 0 0 41.81 KB
master WriteAndFlushEnrichedTraces net472 855μs 3.68μs 13.8μs 8.13 2.57 0.428 53.28 KB
#6505 WriteAndFlushEnrichedTraces net6.0 555μs 2.77μs 13.6μs 0.539 0 0 41.6 KB
#6505 WriteAndFlushEnrichedTraces netcoreapp3.1 679μs 3.68μs 30.8μs 0.361 0 0 41.71 KB
#6505 WriteAndFlushEnrichedTraces net472 871μs 4.17μs 16.1μs 8.19 2.59 0.431 53.31 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.28μs 1.45ns 5.62ns 0.014 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.77μs 2.7ns 10.4ns 0.014 0 0 1.02 KB
master ExecuteNonQuery net472 2.06μs 1.7ns 6.36ns 0.157 0.00103 0 987 B
#6505 ExecuteNonQuery net6.0 1.32μs 2.36ns 8.51ns 0.014 0 0 1.02 KB
#6505 ExecuteNonQuery netcoreapp3.1 1.86μs 1.64ns 6.34ns 0.013 0 0 1.02 KB
#6505 ExecuteNonQuery net472 2.18μs 5.48ns 21.2ns 0.156 0.00108 0 987 B
Benchmarks.Trace.ElasticsearchBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #6505

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync‑net6.0 1.133 1,200.51 1,360.07

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master CallElasticsearch net6.0 1.18μs 0.874ns 3.27ns 0.0136 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.56μs 0.606ns 2.19ns 0.0125 0 0 976 B
master CallElasticsearch net472 2.61μs 1.05ns 3.92ns 0.157 0 0 995 B
master CallElasticsearchAsync net6.0 1.2μs 0.792ns 2.96ns 0.0133 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.74μs 3.69ns 14.3ns 0.0138 0 0 1.02 KB
master CallElasticsearchAsync net472 2.52μs 1.39ns 5.37ns 0.166 0 0 1.05 KB
#6505 CallElasticsearch net6.0 1.26μs 1.02ns 3.96ns 0.0133 0 0 976 B
#6505 CallElasticsearch netcoreapp3.1 1.57μs 0.961ns 3.72ns 0.0127 0 0 976 B
#6505 CallElasticsearch net472 2.41μs 1.08ns 4.05ns 0.158 0 0 995 B
#6505 CallElasticsearchAsync net6.0 1.36μs 0.765ns 2.96ns 0.0131 0 0 952 B
#6505 CallElasticsearchAsync netcoreapp3.1 1.72μs 0.976ns 3.78ns 0.0136 0 0 1.02 KB
#6505 CallElasticsearchAsync net472 2.58μs 0.84ns 3.25ns 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.36μs 0.73ns 2.83ns 0.0132 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.65μs 0.617ns 2.31ns 0.0131 0 0 952 B
master ExecuteAsync net472 1.79μs 0.407ns 1.58ns 0.145 0 0 915 B
#6505 ExecuteAsync net6.0 1.39μs 1.22ns 4.57ns 0.0133 0 0 952 B
#6505 ExecuteAsync netcoreapp3.1 1.57μs 0.944ns 3.66ns 0.0133 0 0 952 B
#6505 ExecuteAsync net472 1.83μs 0.393ns 1.52ns 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.41μs 1.84ns 6.89ns 0.033 0 0 2.31 KB
master SendAsync netcoreapp3.1 5.31μs 2.42ns 9.36ns 0.0372 0 0 2.85 KB
master SendAsync net472 7.38μs 1.37ns 4.75ns 0.493 0 0 3.12 KB
#6505 SendAsync net6.0 4.39μs 1ns 3.6ns 0.0325 0 0 2.31 KB
#6505 SendAsync netcoreapp3.1 5.23μs 1.49ns 5.58ns 0.0367 0 0 2.85 KB
#6505 SendAsync net472 7.42μs 2.01ns 7.8ns 0.493 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.54μs 0.565ns 2.12ns 0.0233 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.2μs 0.881ns 3.3ns 0.0221 0 0 1.64 KB
master EnrichedLog net472 2.63μs 1.55ns 6ns 0.249 0 0 1.57 KB
#6505 EnrichedLog net6.0 1.47μs 0.561ns 2.1ns 0.0229 0 0 1.64 KB
#6505 EnrichedLog netcoreapp3.1 2.34μs 1.01ns 3.77ns 0.0218 0 0 1.64 KB
#6505 EnrichedLog net472 2.75μs 1.45ns 5.41ns 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 117μs 163ns 630ns 0.0587 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 122μs 246ns 953ns 0 0 0 4.28 KB
master EnrichedLog net472 150μs 196ns 760ns 0.675 0.225 0 4.46 KB
#6505 EnrichedLog net6.0 119μs 141ns 548ns 0.0598 0 0 4.28 KB
#6505 EnrichedLog netcoreapp3.1 124μs 249ns 963ns 0 0 0 4.28 KB
#6505 EnrichedLog net472 153μs 156ns 606ns 0.684 0.228 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 3.05μs 0.956ns 3.7ns 0.0304 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.24μs 1.88ns 7.29ns 0.0296 0 0 2.2 KB
master EnrichedLog net472 4.94μs 1.38ns 5.35ns 0.321 0 0 2.02 KB
#6505 EnrichedLog net6.0 2.86μs 0.944ns 3.66ns 0.0303 0 0 2.2 KB
#6505 EnrichedLog netcoreapp3.1 4.1μs 1.46ns 5.47ns 0.0286 0 0 2.2 KB
#6505 EnrichedLog net472 4.9μs 1.23ns 4.78ns 0.319 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.44μs 1.22ns 4.58ns 0.0158 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.85μs 1.22ns 4.72ns 0.0158 0 0 1.14 KB
master SendReceive net472 2.09μs 1.38ns 4.98ns 0.183 0 0 1.16 KB
#6505 SendReceive net6.0 1.36μs 0.525ns 1.96ns 0.0162 0 0 1.14 KB
#6505 SendReceive netcoreapp3.1 1.72μs 0.719ns 2.79ns 0.0149 0 0 1.14 KB
#6505 SendReceive net472 2.19μs 2.29ns 8.88ns 0.184 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.62μs 1.11ns 4.28ns 0.0224 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 4μs 9.1ns 35.3ns 0.0218 0 0 1.65 KB
master EnrichedLog net472 4.26μs 2.11ns 8.18ns 0.324 0 0 2.04 KB
#6505 EnrichedLog net6.0 2.66μs 0.674ns 2.61ns 0.0226 0 0 1.6 KB
#6505 EnrichedLog netcoreapp3.1 4.13μs 1.21ns 4.54ns 0.0208 0 0 1.65 KB
#6505 EnrichedLog net472 4.34μs 2.22ns 8.32ns 0.322 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #6505

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net6.0 1.173 392.43 460.29

Faster 🎉 in #6505

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑net6.0 1.160 555.80 479.18
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑netcoreapp3.1 1.142 766.80 671.23

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 393ns 0.297ns 1.15ns 0.00797 0 0 576 B
master StartFinishSpan netcoreapp3.1 557ns 0.325ns 1.26ns 0.00782 0 0 576 B
master StartFinishSpan net472 629ns 0.357ns 1.38ns 0.0915 0 0 578 B
master StartFinishScope net6.0 556ns 0.32ns 1.24ns 0.00976 0 0 696 B
master StartFinishScope netcoreapp3.1 767ns 0.461ns 1.79ns 0.00962 0 0 696 B
master StartFinishScope net472 873ns 0.621ns 2.41ns 0.104 0 0 658 B
#6505 StartFinishSpan net6.0 460ns 0.339ns 1.31ns 0.00813 0 0 576 B
#6505 StartFinishSpan netcoreapp3.1 599ns 0.604ns 2.34ns 0.00794 0 0 576 B
#6505 StartFinishSpan net472 663ns 0.395ns 1.53ns 0.0917 0 0 578 B
#6505 StartFinishScope net6.0 480ns 0.261ns 1.01ns 0.00984 0 0 696 B
#6505 StartFinishScope netcoreapp3.1 671ns 0.594ns 2.3ns 0.00955 0 0 696 B
#6505 StartFinishScope net472 862ns 0.856ns 3.32ns 0.104 0 0 658 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Faster 🎉 Same allocations ✔️

Faster 🎉 in #6505

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑netcoreapp3.1 1.140 966.76 847.81
Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑net6.0 1.120 669.29 597.84

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net6.0 669ns 0.258ns 0.966ns 0.00972 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 966ns 0.75ns 2.91ns 0.00924 0 0 696 B
master RunOnMethodBegin net472 1.13μs 0.458ns 1.78ns 0.104 0 0 658 B
#6505 RunOnMethodBegin net6.0 598ns 0.313ns 1.21ns 0.00994 0 0 696 B
#6505 RunOnMethodBegin netcoreapp3.1 848ns 0.516ns 2ns 0.00898 0 0 696 B
#6505 RunOnMethodBegin net472 1.09μs 0.749ns 2.9ns 0.104 0 0 658 B

@@ -154,7 +154,7 @@ internal static bool TryGetInode(string path, out long result)

try
{
var statCommand = ProcessHelpers.RunCommand(new ProcessHelpers.Command("stat", $"--printf=%i {path}"));
var statCommand = ProcessHelpers.RunCommand(new ProcessHelpers.Command("stat", $"-c %i {path}"));
Copy link
Member

Choose a reason for hiding this comment

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

We should probably add a unit tests for TryGetInode() to ContainerMetadataTests.cs. This test should fail on Alpine before this change and pass after the change.

Copy link
Member

Choose a reason for hiding this comment

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

And in other Linux distros (not Alpine), it should pass before and after this change (confirming there is not regression).

@wantsui wantsui changed the title fix: swap out --printf=%i for -c %i. fix container tagging for Alpine containers Jan 7, 2025
@github-actions github-actions bot added the area:tests unit tests, integration tests label Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:tests unit tests, integration tests area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants