Skip to content

Implement endpoint profiling#3015

Merged
kevingosse merged 12 commits into
masterfrom
kevin/endpoint_aggregation2
Aug 31, 2022
Merged

Implement endpoint profiling#3015
kevingosse merged 12 commits into
masterfrom
kevin/endpoint_aggregation2

Conversation

@kevingosse

@kevingosse kevingosse commented Jul 27, 2022

Copy link
Copy Markdown
Contributor

This PR depends on DataDog/libdatadog#33

Summary of changes

Decorate the profiler samples with the endpoint of the active trace, if any.

Implementation details

The tracer sends the resource name to the profiler when closing a root span of type web. When that happens, the profiler calls libdatadog to associate the id of root span to the given resource name.

Test coverage

Unit test on the tracer side to make sure the p/invoke is called when a root web span is closed.
Integration test on the profiler side to make sure everything works properly.

@kevingosse kevingosse added area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) area:profiler Issues related to the continous-profiler labels Jul 27, 2022
@andrewlock

This comment has been minimized.

@andrewlock

This comment has been minimized.

@andrewlock

This comment has been minimized.

@kevingosse
kevingosse force-pushed the kevin/endpoint_aggregation2 branch 2 times, most recently from d43987a to b329aa3 Compare August 26, 2022 12:19
@andrewlock

This comment has been minimized.

@kevingosse
kevingosse marked this pull request as ready for review August 26, 2022 13:53
@kevingosse
kevingosse requested review from a team as code owners August 26, 2022 13:53
@andrewlock

This comment has been minimized.

@andrewlock

This comment has been minimized.

Comment thread profiler/src/ProfilerEngine/Datadog.Profiler.Native/IExporter.h Outdated

@dromanol dromanol left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM as far as I can reach (that is not much).

@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.

I only looked at the c# part, a few small questions

Comment thread profiler/src/ProfilerEngine/Datadog.Profiler.Native/PInvoke.cpp
Comment thread tracer/src/Datadog.Trace/AsyncLocalScopeManager.cs Outdated
Comment thread tracer/src/Datadog.Trace/ContinuousProfiler/ContextTracker.cs
Comment thread tracer/src/Datadog.Trace/ContinuousProfiler/Profiler.cs Outdated
Comment thread profiler/src/ProfilerEngine/Datadog.Profiler.Native/PInvoke.cpp Outdated
Comment thread tracer/src/Datadog.Trace/AsyncLocalScopeManager.cs Outdated
Comment thread tracer/src/Datadog.Trace/ContinuousProfiler/ContextTracker.cs

@chrisnas chrisnas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@andrewlock

This comment has been minimized.

Comment thread profiler/src/ProfilerEngine/Datadog.Profiler.Native/Configuration.h Outdated
Comment thread tracer/test/Datadog.Trace.Tests/ContinuousProfiler/ContextTrackerTests.cs Outdated
@andrewlock

This comment has been minimized.

@kevingosse
kevingosse force-pushed the kevin/endpoint_aggregation2 branch from 520872d to 617c637 Compare August 30, 2022 18:29
@andrewlock

This comment has been minimized.

@andrewlock

This comment has been minimized.

@kevingosse
kevingosse force-pushed the kevin/endpoint_aggregation2 branch from 67afcdb to 4db93d7 Compare August 31, 2022 08:53
@andrewlock

Copy link
Copy Markdown
Member

Benchmarks Report 🐌

Benchmarks for #3015 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 712μs 241ns 932ns 0.374 0 0 3.18 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 451μs 177ns 662ns 0 0 0 2.58 KB
#3015 WriteAndFlushEnrichedTraces net472 716μs 452ns 1.75μs 0.355 0 0 3.18 KB
#3015 WriteAndFlushEnrichedTraces netcoreapp3.1 460μs 180ns 673ns 0 0 0 2.58 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 198ns 0.881ns 3.41ns 0.0675 0 0 425 B
master AllCycleSimpleBody netcoreapp3.1 248ns 0.762ns 2.95ns 0.0058 0 0 424 B
master AllCycleMoreComplexBody net472 193ns 0.788ns 3.05ns 0.0637 0 0 401 B
master AllCycleMoreComplexBody netcoreapp3.1 241ns 0.848ns 3.29ns 0.00539 0 0 400 B
master BodyExtractorSimpleBody net472 274ns 1.26ns 4.89ns 0.0574 0 0 361 B
master BodyExtractorSimpleBody netcoreapp3.1 242ns 0.776ns 3.01ns 0.00366 0 0 272 B
master BodyExtractorMoreComplexBody net472 14.7μs 53.5ns 207ns 1.2 0.0219 0 7.62 KB
master BodyExtractorMoreComplexBody netcoreapp3.1 12.6μs 55.6ns 215ns 0.0923 0 0 6.75 KB
#3015 AllCycleSimpleBody net472 187ns 0.592ns 2.29ns 0.0675 0 0 425 B
#3015 AllCycleSimpleBody netcoreapp3.1 244ns 0.725ns 2.81ns 0.00585 0 0 424 B
#3015 AllCycleMoreComplexBody net472 191ns 0.624ns 2.34ns 0.0637 0 0 401 B
#3015 AllCycleMoreComplexBody netcoreapp3.1 240ns 0.614ns 2.3ns 0.00545 0 0 400 B
#3015 BodyExtractorSimpleBody net472 265ns 0.982ns 3.8ns 0.0574 0 0 361 B
#3015 BodyExtractorSimpleBody netcoreapp3.1 236ns 0.766ns 2.97ns 0.00371 0 0 272 B
#3015 BodyExtractorMoreComplexBody net472 15.3μs 55.7ns 216ns 1.21 0.0152 0 7.62 KB
#3015 BodyExtractorMoreComplexBody netcoreapp3.1 12.9μs 46.9ns 181ns 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 181μs 182ns 705ns 0.271 0 0 20.57 KB
#3015 SendRequest net472 0ns 0ns 0ns 0 0 0 0 b
#3015 SendRequest netcoreapp3.1 182μs 152ns 570ns 0.273 0 0 20.57 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.83μs 0.401ns 1.5ns 0.15 0.000916 0 947 B
master ExecuteNonQuery netcoreapp3.1 1.45μs 0.768ns 2.98ns 0.0123 0 0 936 B
#3015 ExecuteNonQuery net472 1.91μs 0.831ns 3.22ns 0.15 0.000957 0 947 B
#3015 ExecuteNonQuery netcoreapp3.1 1.47μs 0.715ns 2.58ns 0.0121 0 0 936 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.49μs 1.05ns 3.94ns 0.184 0 0 1.16 KB
master CallElasticsearch netcoreapp3.1 1.49μs 0.428ns 1.6ns 0.0149 0 0 1.1 KB
master CallElasticsearchAsync net472 2.67μs 0.832ns 3.22ns 0.205 0 0 1.29 KB
master CallElasticsearchAsync netcoreapp3.1 1.62μs 0.442ns 1.65ns 0.0162 0 0 1.22 KB
#3015 CallElasticsearch net472 2.52μs 1.12ns 4.2ns 0.183 0 0 1.16 KB
#3015 CallElasticsearch netcoreapp3.1 1.6μs 0.556ns 2.15ns 0.0144 0 0 1.1 KB
#3015 CallElasticsearchAsync net472 2.63μs 0.697ns 2.7ns 0.205 0 0 1.29 KB
#3015 CallElasticsearchAsync netcoreapp3.1 1.6μs 0.505ns 1.95ns 0.016 0 0 1.22 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.65μs 4.98ns 19.3ns 0.224 0 0 1.41 KB
master ExecuteAsync netcoreapp3.1 1.62μs 2.5ns 9.67ns 0.0181 0 0 1.34 KB
#3015 ExecuteAsync net472 2.67μs 7ns 27.1ns 0.224 0 0 1.41 KB
#3015 ExecuteAsync netcoreapp3.1 1.69μs 4ns 15.5ns 0.0183 0 0 1.34 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.66μs 8.67ns 32.4ns 0.439 0 0 2.77 KB
master SendAsync netcoreapp3.1 3.57μs 7.69ns 29.8ns 0.0348 0 0 2.6 KB
#3015 SendAsync net472 5.85μs 22.5ns 87.2ns 0.437 0 0 2.77 KB
#3015 SendAsync netcoreapp3.1 3.78μs 8.65ns 32.4ns 0.0348 0 0 2.6 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.21μs 2.06ns 7.72ns 0.287 0 0 1.81 KB
master EnrichedLog netcoreapp3.1 2.46μs 1.34ns 4.83ns 0.0245 0 0 1.85 KB
#3015 EnrichedLog net472 3.16μs 1.4ns 5.42ns 0.287 0 0 1.81 KB
#3015 EnrichedLog netcoreapp3.1 2.71μs 0.707ns 2.55ns 0.0244 0 0 1.85 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 149μs 91.4ns 354ns 0.671 0.224 0 4.65 KB
master EnrichedLog netcoreapp3.1 115μs 124ns 481ns 0 0 0 4.49 KB
#3015 EnrichedLog net472 149μs 64.9ns 243ns 0.678 0.226 0 4.65 KB
#3015 EnrichedLog netcoreapp3.1 116μs 137ns 531ns 0.0577 0 0 4.49 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.6μs 12.4ns 47.9ns 0.569 0.00279 0 3.59 KB
master EnrichedLog netcoreapp3.1 4.37μs 12.8ns 49.6ns 0.0541 0 0 3.91 KB
#3015 EnrichedLog net472 5.5μs 13.6ns 52.6ns 0.568 0.00273 0 3.59 KB
#3015 EnrichedLog netcoreapp3.1 4.54μs 12.9ns 48.2ns 0.0539 0 0 3.91 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.31μs 1.13ns 4.21ns 0.218 0 0 1.37 KB
master SendReceive netcoreapp3.1 1.82μs 0.519ns 1.94ns 0.0182 0 0 1.32 KB
#3015 SendReceive net472 2.27μs 0.997ns 3.86ns 0.218 0 0 1.37 KB
#3015 SendReceive netcoreapp3.1 1.83μs 0.681ns 2.55ns 0.0175 0 0 1.32 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.04μs 1.76ns 6.83ns 0.353 0 0 2.23 KB
master EnrichedLog netcoreapp3.1 4.28μs 1.83ns 6.83ns 0.0234 0 0 1.8 KB
#3015 EnrichedLog net472 4.93μs 1.4ns 5.06ns 0.354 0 0 2.23 KB
#3015 EnrichedLog netcoreapp3.1 4.33μs 1.58ns 6.13ns 0.0239 0 0 1.8 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.11μs 0.332ns 1.28ns 0.128 0 0 810 B
master StartFinishSpan netcoreapp3.1 893ns 0.371ns 1.39ns 0.0103 0 0 760 B
master StartFinishScope net472 1.35μs 0.91ns 3.4ns 0.141 0 0 891 B
master StartFinishScope netcoreapp3.1 1.06μs 1.13ns 4.39ns 0.0121 0 0 880 B
#3015 StartFinishSpan net472 1.26μs 6.15ns 43.9ns 0.129 0 0 810 B
#3015 StartFinishSpan netcoreapp3.1 951ns 0.427ns 1.6ns 0.0105 0 0 760 B
#3015 StartFinishScope net472 1.49μs 0.384ns 1.44ns 0.141 0 0 891 B
#3015 StartFinishScope netcoreapp3.1 1.11μs 0.937ns 3.63ns 0.0117 0 0 880 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.48μs 0.658ns 2.55ns 0.141 0 0 891 B
master RunOnMethodBegin netcoreapp3.1 1.17μs 0.726ns 2.72ns 0.0118 0 0 880 B
#3015 RunOnMethodBegin net472 1.51μs 0.729ns 2.82ns 0.141 0 0 891 B
#3015 RunOnMethodBegin netcoreapp3.1 1.21μs 1.37ns 5.3ns 0.0115 0 0 880 B

@andrewlock

Copy link
Copy Markdown
Member

Code Coverage Report 📊

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

master #3015 Change
Lines 17259 / 23585 17284 / 23601
Lines % 73% 73% 0% ✔️
Branches 10242 / 14548 10258 / 14564
Branches % 70% 70% 0% ✔️
Complexity 15670 15687 17

View the full report for further details:

Datadog.Trace Breakdown ✔️

master #3015 Change
Lines % 73% 73% 0% ✔️
Branches % 70% 70% 0% ✔️
Complexity 15670 15687 17

The following classes have significant coverage changes.

File Line coverage change Branch coverage change Complexity change
Datadog.Trace.Debugger.ProbeStatuses.ProbeStatusPoller 0% ✔️ -6% 0 ✔️
Datadog.Trace.Ci.CIVisibility 5% ✔️ 6% ✔️ 0 ✔️
Datadog.Trace.ContinuousProfiler.ContextTracker 7% ✔️ 8% ✔️ 12

View the full reports for further details:

@kevingosse
kevingosse merged commit 992f39e into master Aug 31, 2022
@kevingosse
kevingosse deleted the kevin/endpoint_aggregation2 branch August 31, 2022 11:30
@github-actions github-actions Bot added this to the vNext milestone Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:profiler Issues related to the continous-profiler 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.

6 participants