[Code Origin] DEBUG-4998 Add code origin support for Net Framework MVC and web api#8083
[Code Origin] DEBUG-4998 Add code origin support for Net Framework MVC and web api#8083dudikeleti wants to merge 7 commits into
Conversation
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (8083) and master. ✅ No regressions detected - check the details below Full Metrics ComparisonFakeDbCommand
HttpMessageHandler
Comparison explanationExecution-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 highlighted in **red**. The following thresholds were used for comparing the execution times:
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). Duration chartsFakeDbCommand (.NET Framework 4.8)gantt
title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8083) - mean (70ms) : 68, 72
master - mean (70ms) : 67, 72
section Bailout
This PR (8083) - mean (73ms) : 72, 74
master - mean (74ms) : 72, 75
section CallTarget+Inlining+NGEN
This PR (8083) - mean (1,043ms) : 1006, 1080
master - mean (1,048ms) : 993, 1103
FakeDbCommand (.NET Core 3.1)gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8083) - mean (107ms) : 105, 110
master - mean (107ms) : 105, 110
section Bailout
This PR (8083) - mean (109ms) : 107, 110
master - mean (109ms) : 107, 110
section CallTarget+Inlining+NGEN
This PR (8083) - mean (753ms) : 713, 794
master - mean (755ms) : 714, 795
FakeDbCommand (.NET 6)gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8083) - mean (96ms) : 93, 98
master - mean (96ms) : 93, 98
section Bailout
This PR (8083) - mean (97ms) : 95, 99
master - mean (96ms) : 95, 98
section CallTarget+Inlining+NGEN
This PR (8083) - mean (728ms) : 686, 770
master - mean (725ms) : 682, 767
FakeDbCommand (.NET 8)gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8083) - mean (94ms) : 92, 97
master - mean (94ms) : 92, 96
section Bailout
This PR (8083) - mean (96ms) : 94, 98
master - mean (95ms) : 93, 98
section CallTarget+Inlining+NGEN
This PR (8083) - mean (640ms) : 624, 657
master - mean (636ms) : 623, 649
HttpMessageHandler (.NET Framework 4.8)gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8083) - mean (195ms) : 191, 199
master - mean (194ms) : 188, 200
section Bailout
This PR (8083) - mean (197ms) : 195, 200
master - mean (197ms) : 194, 201
section CallTarget+Inlining+NGEN
This PR (8083) - mean (1,153ms) : 1099, 1207
master - mean (1,152ms) : 1098, 1206
HttpMessageHandler (.NET Core 3.1)gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8083) - mean (279ms) : 274, 283
master - mean (278ms) : 271, 284
section Bailout
This PR (8083) - mean (279ms) : 275, 282
master - mean (280ms) : 273, 286
section CallTarget+Inlining+NGEN
This PR (8083) - mean (950ms) : 915, 985
master - mean (948ms) : 915, 981
HttpMessageHandler (.NET 6)gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8083) - mean (272ms) : 267, 277
master - mean (270ms) : 265, 276
section Bailout
This PR (8083) - mean (272ms) : 268, 276
master - mean (270ms) : 266, 274
section CallTarget+Inlining+NGEN
This PR (8083) - mean (935ms) : 910, 959
master - mean (938ms) : 905, 971
HttpMessageHandler (.NET 8)gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8083) - mean (272ms) : 263, 280
master - mean (270ms) : 263, 277
section Bailout
This PR (8083) - mean (271ms) : 266, 275
master - mean (270ms) : 265, 275
section CallTarget+Inlining+NGEN
This PR (8083) - mean (837ms) : 810, 863
master - mean (834ms) : 805, 863
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 962ba7063e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
962ba70 to
34ebc7e
Compare
34ebc7e to
38627f7
Compare
BenchmarksBenchmark execution time: 2026-02-11 12:25:51 Comparing candidate commit 4545956 in PR branch Found 6 performance improvements and 8 performance regressions! Performance is the same for 165 metrics, 13 unstable metrics. scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild netcoreapp3.1
scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net6.0
scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1
scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody netcoreapp3.1
scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack netcoreapp3.1
scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net472
scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net6.0
scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1
scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net472
scenario:Benchmarks.Trace.DbCommandBenchmark.ExecuteNonQuery net6.0
scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog net6.0
scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog netcoreapp3.1
scenario:Benchmarks.Trace.RedisBenchmark.SendReceive net472
|
15ff893 to
4545956
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds Code Origin for Spans support to .NET Framework MVC 4/5 and Web API 2 entry spans (aspnet.request), enabling file/line enrichment for these frameworks. Previously, only ASP.NET Core had this functionality.
Changes:
- Extended instrumentation hooks in MVC/Web API integrations to include
Tracingcategory and add code origin tags to entry spans - Updated
EndpointDetectorto recognize .NET Framework MVC/Web API controller endpoints for PDB enrichment - Added integration tests with snapshot verification for both Classic and Integrated IIS modes
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tracer/src/Datadog.Trace/Debugger/SpanCodeOrigin/EndpointDetector.cs | Extended endpoint detection to recognize .NET Framework MVC/Web API controllers |
| tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ControllerActionInvoker_InvokeAction_Integration.cs | Added code origin tagging for MVC entry spans and updated instrumentation category |
| tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ReflectedHttpActionDescriptor_ExecuteAsync_Integration.cs | Added code origin tagging for Web API entry spans and updated instrumentation category |
| tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ActionDescriptorWithMethodInfo.cs | Duck type interface for extracting MethodInfo from action descriptors |
| tracer/test/Datadog.Trace.Tests/Debugger/EndpointDetectorTests.cs | Unit tests validating detection of .NET Framework MVC/Web API endpoints |
| tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/AspNetMvc5CodeOriginTests.cs | Integration tests for MVC code origin functionality |
| tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/AspNetWebApi2CodeOriginTests.cs | Integration tests for Web API code origin functionality |
| tracer/test/snapshots/*.verified.txt | Snapshot files verifying code origin tags are present in test spans |
| tracer/test/Datadog.Trace.Security.IntegrationTests/AspNetWebApi.cs | Adjusted expected span count based on AppSec enabled state |
| tracer/build/supported_calltargets.g.json | Updated instrumentation category flags for the modified hooks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4545956 to
c659016
Compare
c659016 to
22e8dbd
Compare
Reason for change
Code Origin for Spans was already supported on ASP.NET Core entry spans, but classic ASP.NET (.NET Framework) MVC/Web API entry spans (
aspnet.request) were missing_dd.code_origin.*tags, preventing file/line enrichment and consistent “entry span origin” behavior across runtimes. There is an open customer ticket for this.Implementation details
MVC: Added code origin tagging for the entry span (
aspnet.request) inControllerActionInvoker_InvokeAction_Integration.InstrumentationCategoryto includeTracing. These hooks previously ran only under AppSec/IAST categories, but Code Origin for Spans must execute even when AppSec/IAST are disabled.Web API: Added code origin tagging for the entry span (
aspnet.request) inReflectedHttpActionDescriptor_ExecuteAsync_Integration.InstrumentationCategoryto includeTracingfor the same reason: ensure code-origin tagging runs in tracing-only scenarios.PDB enrichment support: Extended
EndpointDetectorto recognize .NET Framework MVC/Web API controller endpoints so sequence points can be loaded for file/line/column.Out of scope of this PR
This change focuses only on entry spans for .NET Framework ASP.NET MVC 4/5 and Web API 2. It does not add Code Origin for Spans support for the following:
IHttpHandler(support may be added if required)Test coverage
EndpointDetectorTeststo validate detection of .NET Framework MVC/WebApi2 endpoints.AspNetMvc5CodeOriginTests&AspNetWebApi2CodeOriginTestsEnabled code origin via env var and verified emitted span snapshots include code origin tags.