Skip to content

Make cgroup ContainerMetadata parsing more lenient#3354

Merged
andrewlock merged 1 commit into
masterfrom
andrew/fix-cgroup
Oct 14, 2022
Merged

Make cgroup ContainerMetadata parsing more lenient#3354
andrewlock merged 1 commit into
masterfrom
andrew/fix-cgroup

Conversation

@andrewlock

@andrewlock andrewlock commented Oct 13, 2022

Copy link
Copy Markdown
Member

Summary of changes

Relaxes the Regex used for containerid extraction

Reason for change

We were failing to extract the containerID from cgroup in an EKS1.23 nodegroup with Amazon Linux, due to the regex we use for extraction.

Implementation details

This PR relaxes the Regex somewhat. Instead of matching the start of the line, we only try to match the end of the line, and match either the task, uuid, or containerID regex. Also, the .scope suffix is allowed for all three containerID types, instead of only task

Test coverage

Added a test case, confirmed existing cases still pass

Other details

Fixes #3351

We were failing to extract the containerID from cgroup in an EKS1.23 nodegroup with Amazon Linux, due to the regex we use for extraction.

This relaxes the Regex somewhat. Instead of matching the start of the line, we only try to match the end of the line, and match either the task, uuid, or containerID regex.
@andrewlock andrewlock added type:bug area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) labels Oct 13, 2022
@andrewlock
andrewlock requested a review from a team as a code owner October 13, 2022 15:33
@andrewlock

Copy link
Copy Markdown
Member Author

Benchmarks Report 🐌

Benchmarks for #3354 compared to master:

  • All benchmarks have the same speed
  • 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.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net472 784μs 331ns 1.28μs 0.393 0 0 3.22 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 536μs 205ns 739ns 0 0 0 2.63 KB
#3354 WriteAndFlushEnrichedTraces net472 785μs 180ns 648ns 0.393 0 0 3.22 KB
#3354 WriteAndFlushEnrichedTraces netcoreapp3.1 511μs 296ns 1.11μs 0 0 0 2.63 KB
Benchmarks.Trace.AppSecBodyBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master AllCycleSimpleBody net472 196ns 0.0741ns 0.277ns 0.0726 0 0 457 B
master AllCycleSimpleBody netcoreapp3.1 254ns 0.0941ns 0.339ns 0.00627 0 0 456 B
master AllCycleMoreComplexBody net472 197ns 0.108ns 0.42ns 0.0688 0 0 433 B
master AllCycleMoreComplexBody netcoreapp3.1 255ns 0.121ns 0.452ns 0.00592 0 0 432 B
master BodyExtractorSimpleBody net472 294ns 0.39ns 1.46ns 0.0573 0 0 361 B
master BodyExtractorSimpleBody netcoreapp3.1 222ns 0.162ns 0.584ns 0.00371 0 0 272 B
master BodyExtractorMoreComplexBody net472 15.7μs 14.7ns 57ns 1.21 0.0158 0 7.62 KB
master BodyExtractorMoreComplexBody netcoreapp3.1 13.1μs 6.05ns 22.6ns 0.0911 0 0 6.75 KB
#3354 AllCycleSimpleBody net472 199ns 0.0756ns 0.283ns 0.0726 0 0 457 B
#3354 AllCycleSimpleBody netcoreapp3.1 253ns 0.215ns 0.833ns 0.00625 0 0 456 B
#3354 AllCycleMoreComplexBody net472 194ns 0.0558ns 0.209ns 0.0688 0 0 433 B
#3354 AllCycleMoreComplexBody netcoreapp3.1 252ns 0.0492ns 0.17ns 0.00598 0 0 432 B
#3354 BodyExtractorSimpleBody net472 293ns 0.418ns 1.62ns 0.0573 0 0 361 B
#3354 BodyExtractorSimpleBody netcoreapp3.1 241ns 0.119ns 0.429ns 0.00377 0 0 272 B
#3354 BodyExtractorMoreComplexBody net472 15.6μs 12.9ns 48.3ns 1.21 0.0157 0 7.62 KB
#3354 BodyExtractorMoreComplexBody netcoreapp3.1 13μs 5.54ns 20.7ns 0.0908 0 0 6.75 KB
Benchmarks.Trace.AspNetCoreBenchmark - Unknown 🤷 Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendRequest net472 0ns 0ns 0ns 0 0 0 0 b
master SendRequest netcoreapp3.1 180μs 315ns 1.22μs 0.269 0 0 20.68 KB
#3354 SendRequest net472 0ns 0ns 0ns 0 0 0 0 b
#3354 SendRequest netcoreapp3.1 182μs 335ns 1.3μs 0.182 0 0 20.68 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 net472 1.9μs 0.45ns 1.74ns 0.155 0.000948 0 979 B
master ExecuteNonQuery netcoreapp3.1 1.4μs 0.546ns 2.04ns 0.0134 0 0 968 B
#3354 ExecuteNonQuery net472 1.89μs 0.449ns 1.62ns 0.156 0.000943 0 979 B
#3354 ExecuteNonQuery netcoreapp3.1 1.45μs 0.478ns 1.72ns 0.0131 0 0 968 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 net472 2.53μs 0.757ns 2.83ns 0.188 0 0 1.19 KB
master CallElasticsearch netcoreapp3.1 1.56μs 1.12ns 4.2ns 0.0153 0 0 1.13 KB
master CallElasticsearchAsync net472 2.68μs 0.861ns 3.22ns 0.21 0 0 1.32 KB
master CallElasticsearchAsync netcoreapp3.1 1.7μs 0.493ns 1.78ns 0.0169 0 0 1.25 KB
#3354 CallElasticsearch net472 2.51μs 0.548ns 2.12ns 0.188 0 0 1.19 KB
#3354 CallElasticsearch netcoreapp3.1 1.58μs 0.536ns 2ns 0.0149 0 0 1.13 KB
#3354 CallElasticsearchAsync net472 2.75μs 1.21ns 4.7ns 0.21 0 0 1.32 KB
#3354 CallElasticsearchAsync netcoreapp3.1 1.59μs 0.604ns 2.26ns 0.0167 0 0 1.25 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 net472 2.71μs 1.03ns 3.71ns 0.23 0 0 1.45 KB
master ExecuteAsync netcoreapp3.1 1.78μs 1.26ns 4.9ns 0.0187 0 0 1.38 KB
#3354 ExecuteAsync net472 2.72μs 0.96ns 3.72ns 0.23 0 0 1.45 KB
#3354 ExecuteAsync netcoreapp3.1 1.75μs 0.57ns 2.21ns 0.0186 0 0 1.38 KB
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendAsync net472 5.87μs 2.25ns 8.43ns 0.443 0 0 2.8 KB
master SendAsync netcoreapp3.1 3.71μs 1.41ns 5.28ns 0.0353 0 0 2.63 KB
#3354 SendAsync net472 5.91μs 2.45ns 9.48ns 0.444 0 0 2.8 KB
#3354 SendAsync netcoreapp3.1 3.63μs 1.14ns 4.11ns 0.0347 0 0 2.63 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 net472 3.25μs 2.45ns 9.47ns 0.298 0 0 1.88 KB
master EnrichedLog netcoreapp3.1 2.51μs 2.14ns 7.99ns 0.0262 0 0 1.91 KB
#3354 EnrichedLog net472 3.19μs 5.61ns 21.7ns 0.297 0 0 1.88 KB
#3354 EnrichedLog netcoreapp3.1 2.6μs 1.8ns 6.74ns 0.0259 0 0 1.91 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 net472 152μs 136ns 528ns 0.691 0.23 0 4.72 KB
master EnrichedLog netcoreapp3.1 122μs 145ns 561ns 0.0606 0 0 4.55 KB
#3354 EnrichedLog net472 153μs 128ns 462ns 0.682 0.227 0 4.72 KB
#3354 EnrichedLog netcoreapp3.1 121μs 121ns 435ns 0.0604 0 0 4.55 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 net472 5.78μs 3.18ns 11.9ns 0.578 0.00289 0 3.65 KB
master EnrichedLog netcoreapp3.1 4.45μs 2.65ns 9.57ns 0.0534 0 0 3.98 KB
#3354 EnrichedLog net472 5.77μs 3.41ns 12.8ns 0.579 0.00288 0 3.65 KB
#3354 EnrichedLog netcoreapp3.1 4.4μs 1.69ns 6.3ns 0.0549 0 0 3.98 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 net472 2.42μs 2.77ns 10.7ns 0.222 0 0 1.4 KB
master SendReceive netcoreapp3.1 1.85μs 1.47ns 5.7ns 0.0184 0 0 1.35 KB
#3354 SendReceive net472 2.27μs 1.98ns 7.4ns 0.222 0 0 1.4 KB
#3354 SendReceive netcoreapp3.1 1.85μs 0.736ns 2.65ns 0.0186 0 0 1.35 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 net472 5.12μs 3.29ns 12.7ns 0.363 0 0 2.3 KB
master EnrichedLog netcoreapp3.1 4.39μs 5.25ns 19.7ns 0.0242 0 0 1.86 KB
#3354 EnrichedLog net472 5.07μs 1.7ns 6.11ns 0.363 0 0 2.3 KB
#3354 EnrichedLog netcoreapp3.1 4.4μs 1.03ns 3.98ns 0.0242 0 0 1.86 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 net472 1.18μs 0.279ns 1.08ns 0.134 0 0 842 B
master StartFinishSpan netcoreapp3.1 924ns 0.284ns 1.03ns 0.0107 0 0 792 B
master StartFinishScope net472 1.42μs 0.28ns 1.05ns 0.147 0 0 923 B
master StartFinishScope netcoreapp3.1 1.09μs 0.438ns 1.64ns 0.0121 0 0 912 B
#3354 StartFinishSpan net472 1.18μs 0.446ns 1.67ns 0.133 0 0 842 B
#3354 StartFinishSpan netcoreapp3.1 981ns 0.428ns 1.6ns 0.0105 0 0 792 B
#3354 StartFinishScope net472 1.36μs 0.54ns 1.87ns 0.146 0 0 923 B
#3354 StartFinishScope netcoreapp3.1 1.13μs 0.285ns 1.03ns 0.0123 0 0 912 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net472 1.61μs 0.602ns 2.33ns 0.146 0 0 923 B
master RunOnMethodBegin netcoreapp3.1 1.2μs 0.41ns 1.59ns 0.0126 0 0 912 B
#3354 RunOnMethodBegin net472 1.51μs 0.375ns 1.4ns 0.146 0 0 923 B
#3354 RunOnMethodBegin netcoreapp3.1 1.18μs 0.341ns 1.23ns 0.0118 0 0 912 B

@andrewlock

Copy link
Copy Markdown
Member Author

Code Coverage Report 📊

✔️ Merging #3354 into master will not change line coverage
✔️ Merging #3354 into master will not change branch coverage
⛔ Merging #3354 into master will will increase complexity by 4

master #3354 Change
Lines 19534 / 26924 19521 / 26930
Lines % 73% 72% 0% ✔️
Branches 11607 / 16747 11600 / 16747
Branches % 69% 69% 0% ✔️
Complexity 18113 18117 4

View the full report for further details:

Datadog.Trace Breakdown ✔️

master #3354 Change
Lines % 73% 72% 0% ✔️
Branches % 69% 69% 0% ✔️
Complexity 18113 18117 4

The following classes have significant coverage changes.

File Line coverage change Branch coverage change Complexity change
Datadog.Trace.Propagators.SpanContextPropagator 8% ✔️ 6% ✔️ 0 ✔️

The following classes were added in #3354:

File Line coverage Branch coverage Complexity
Datadog.Trace.Sampling.SpanRateLimiter 0% 100% 4

View the full reports for further details:

@andrewlock
andrewlock merged commit aeb255c into master Oct 14, 2022
@andrewlock
andrewlock deleted the andrew/fix-cgroup branch October 14, 2022 10:15
@github-actions github-actions Bot added this to the vNext milestone Oct 14, 2022
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:bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tracer not sending container ID to agent when using containerd on Amazon Linux

3 participants