Extract Datadog.AutoInstrumentation.Generator.Core shared library#8312
Conversation
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (8312) 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 (8312) - mean (74ms) : 71, 77
master - mean (76ms) : 74, 78
section Bailout
This PR (8312) - mean (78ms) : 76, 81
master - mean (81ms) : 79, 84
section CallTarget+Inlining+NGEN
This PR (8312) - mean (1,086ms) : 1044, 1128
master - mean (1,112ms) : 1071, 1153
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 (8312) - mean (116ms) : 113, 120
master - mean (121ms) : 116, 125
section Bailout
This PR (8312) - mean (119ms) : 114, 123
master - mean (121ms) : 118, 124
section CallTarget+Inlining+NGEN
This PR (8312) - mean (797ms) : 778, 816
master - mean (815ms) : 791, 839
FakeDbCommand (.NET 6)gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8312) - mean (103ms) : 98, 107
master - mean (107ms) : 103, 110
section Bailout
This PR (8312) - mean (104ms) : 101, 107
master - mean (108ms) : 104, 112
section CallTarget+Inlining+NGEN
This PR (8312) - mean (943ms) : 901, 985
master - mean (960ms) : 914, 1007
FakeDbCommand (.NET 8)gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8312) - mean (102ms) : 98, 105
master - mean (105ms) : 101, 109
section Bailout
This PR (8312) - mean (104ms) : 101, 107
master - mean (107ms) : 104, 110
section CallTarget+Inlining+NGEN
This PR (8312) - mean (828ms) : 790, 866
master - mean (844ms) : 809, 880
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 (8312) - mean (205ms) : 200, 211
master - mean (215ms) : 210, 221
section Bailout
This PR (8312) - mean (210ms) : 205, 214
master - mean (220ms) : 216, 225
section CallTarget+Inlining+NGEN
This PR (8312) - mean (1,202ms) : 1146, 1257
master - mean (1,245ms) : 1196, 1294
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 (8312) - mean (295ms) : 287, 302
master - mean (311ms) : 304, 317
section Bailout
This PR (8312) - mean (296ms) : 290, 303
master - mean (311ms) : 305, 318
section CallTarget+Inlining+NGEN
This PR (8312) - mean (977ms) : 943, 1011
master - mean (1,019ms) : 987, 1052
HttpMessageHandler (.NET 6)gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8312) - mean (289ms) : 281, 296
master - mean (303ms) : 296, 311
section Bailout
This PR (8312) - mean (289ms) : 283, 294
master - mean (306ms) : 299, 313
section CallTarget+Inlining+NGEN
This PR (8312) - mean (1,168ms) : 1122, 1214
master - mean (1,194ms) : 1158, 1231
HttpMessageHandler (.NET 8)gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8312) - mean (287ms) : 282, 293
master - mean (303ms) : 295, 310
section Bailout
This PR (8312) - mean (288ms) : 280, 295
master - mean (302ms) : 295, 310
section CallTarget+Inlining+NGEN
This PR (8312) - mean (1,053ms) : 978, 1128
master - mean (1,141ms) : 1025, 1257
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Extract the generation engine, configuration models, and resource templates from the GUI into a standalone Core library. The GUI now delegates to Core, reducing MainViewModel.Editor.cs from ~300 lines of inline logic to ~109 lines. Co-Authored-By: Claude Opus 4.6 <[email protected]>
7af054a to
72b14d2
Compare
andrewlock
left a comment
There was a problem hiding this comment.
LGTM 👍 I made the assumption that the vast majority of the code (e.g. in InstrrunmentationGenerator.cs) was extracted as-is, so didn't review closely. And perf isn't an issue given it's an adhoc tool so all good
) ## Summary of changes Adds a new CLI tool (`dd-autoinstrumentation`) for auto-instrumentation code generation, designed for scriptable and AI-agent-driven workflows with structured JSON output. ## Reason for change Creating integrations currently requires either the GUI or manual boilerplate. A CLI with structured JSON output enables LLM agents to autonomously discover types/methods in an assembly, generate instrumentation code, and recover from errors — all without human intervention. ## Implementation details New `Datadog.AutoInstrumentation.Generator.Cli` project with two commands: **`inspect`** — assembly discovery - `--list-types`: lists all non-compiler-generated types with visibility, kind, method count - `--list-methods <type>`: lists instrumentable methods with parameters, async detection, overload index/count **`generate`** — code generation - Resolves method from assembly/type/method with overload disambiguation (`--overload-index`, `--parameter-types`) - Smart defaults auto-detect async/static/void methods (disable with `--no-auto-detect`) - Configuration via `--set key=value`, `--config '{json}'`, or `--config-file path.json` - Shortcut flags: `--no-method-begin`, `--no-method-end`, `--async-method-end` **`--json` flag** (global) — all output (success and error) as structured JSON on stdout with: - Machine-readable error codes (`FILE_NOT_FOUND`, `TYPE_NOT_FOUND`, `AMBIGUOUS_OVERLOAD`, `BAD_ASSEMBLY`, etc.) - `AMBIGUOUS_OVERLOAD` includes full overload list in response data for immediate retry - `inspect` output includes `overloadIndex`/`overloadCount` so agents know upfront if disambiguation is needed **Nuke integration** — `RunInstrumentationGeneratorCli` target with direct parameters and `--generator-args` passthrough. **Documentation:** - `docs/development/InstrumentationGenerator.md` — comprehensive reference for both GUI and CLI - `docs/development/for-ai/InstrumentationGenerator-CLI.md` — LLM-focused reference with full JSON schemas, error recovery patterns, and recommended autonomous workflow ## Test coverage No automated tests in this PR — this is a developer/AI tooling utility, not a production code path. Manual testing performed against real assemblies for all commands, error paths, and JSON output. ## Other details #8312 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <[email protected]> Co-authored-by: Raphaël Vandon <[email protected]> Co-authored-by: Andrew Lock <[email protected]>
Summary of changes
This extracts the instrumentation code generation core from the GUI
Datadog.AutoInstrumentation.Generatorinto aCorelibrary that can be re-used in an upcoming CLI (mainly for LLM consumption).Reason for change
We'd like to try and automate some of our validation logic that determines if our auto instrumentations still function with newer NuGet versions of the underlying libraries. Currently we rely upon just re-running CI against those tests, but this would allow us to build in the ability to in the future deterministically generate the code from one version to the next which will help with validating whether we are still functional.
Additionally, we'd like to help some ongoing initiatives to aid in the generation / support of auto-instrumentations via LLMs and this will set us up to be able to create a CLI that can be used by LLMs.
Implementation details
New
Datadog.AutoInstrumentation.Generator.Core, you will see the "File renamed without changes." are the extracted files.Main important changes:
AssemblyBrowser- assembly / method resolution logic that was in the MainViewModelGenerationConfigurationtakes all of the previous checkbox bool flags into a single object. Used byCreateForMethod()that handles the variousasync/static/voidlogic.GenerationResultcontains all the generated code stuffInstrumentMethodMetadata-[InstrumentMethod]attribute values.The GUI project now depends on Core and delegates all generation logic to it.
Test coverage
I re-ran the GUI and it seems all functional.
Other details
This is the base PR for another
Claude Code generated