dd-trace-py
dd-trace-py copied to clipboard
feat(DI): add config to create probes through a file
This pull request introduces support for loading probe definitions from a file in JSON format, enabling dynamic instrumentation via external configuration. The changes include updates to the DynamicInstrumentationConfig class, the debugger's initialization logic, and new tests to validate the functionality.
This can be configured via DD_DYNAMIC_INSTRUMENTATION_PROBE_FILE and used in combination with RC.
The JSON should be an array of probe objects in the same format as received via the RC config object, for example:
[
{
"id": "12e4866b-c2d0-4948-baf8-bd98027cd457",
"version": 0,
"type": "LOG_PROBE",
"language": "python",
"where": {
"sourceFile": "tests/submod/stuff.py",
"lines": [36],
},
"tags": [],
"template": "Hello new monitoring API",
"captureSnapshot": True,
"capture": {"maxReferenceDepth": 3},
"evaluateAt": "EXIT",
}
]
Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the library release note guidelines
- The change includes or references documentation updates if necessary
- Backport labels are set (if applicable)
Reviewer Checklist
- [ ] Reviewer has checked that all the criteria below are met
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking API changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the release branch maintenance policy
Bootstrap import analysis
Comparison of import times between this PR and base.
Summary
The average import time from this PR is: 283 ± 5 ms.
The average import time from base is: 284 ± 4 ms.
The import time difference between this PR and base is: -1.3 ± 0.2 ms.
Import time breakdown
The following import paths have grown:
ddtrace.auto
0.035 ms
(0.01%)
ddtrace.bootstrap.sitecustomize
0.035 ms
(0.01%)
ddtrace.bootstrap.preload
0.035 ms
(0.01%)
ddtrace.settings.dynamic_instrumentation
0.035 ms
(0.01%)
The following import paths have shrunk:
ddtrace.auto
1.936 ms
(0.68%)
ddtrace.bootstrap.sitecustomize
1.258 ms
(0.44%)
ddtrace.bootstrap.preload
1.258 ms
(0.44%)
ddtrace.internal.remoteconfig.client
0.629 ms
(0.22%)
ddtrace
0.677 ms
(0.24%)
ddtrace.internal._unpatched
0.032 ms
(0.01%)
json
0.032 ms
(0.01%)
json.decoder
0.032 ms
(0.01%)
re
0.032 ms
(0.01%)
enum
0.032 ms
(0.01%)
types
0.032 ms
(0.01%)
Benchmarks
Benchmark execution time: 2025-07-07 14:31:44
Comparing candidate commit 77d2c72527cacdee05da10a72a08e24dfd9e5c30 in PR branch tyler.finethy/DEBUG-4088 with baseline commit 8c8ea55e20430aa36442e2daf088081b7422832b in branch main.
Found 0 performance improvements and 0 performance regressions! Performance is the same for 428 metrics, 4 unstable metrics.
CODEOWNERS have been resolved as:
ddtrace/debugging/_debugger.py @DataDog/debugger-python
ddtrace/settings/dynamic_instrumentation.py @DataDog/debugger-python
tests/debugging/test_debugger.py @DataDog/debugger-python
tests/telemetry/test_writer.py @DataDog/apm-python