chore(package-split): prepare dd-trace-py for moving code into packages #22018
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #22018"
general
weight: 0.35
gnufede
Description
Prepares dd-trace-py for moving code into packages released from DataDog/datadog-apm-python (plan: DataDog/datadog-apm-python#80). Every change preserves behavior. The goal is that dd-trace-py's layout already shows where each piece of code is going, and that the code being moved no longer reaches into the tracer.
Target layout
| Today in dd-trace-py | Goes to | Rule |
|---|---|---|
|
ddtrace/internal/native/(Rust_native, plus_msgpackand_threads) |ddtrace-native| compiled code only; imports no Python package || shared Python code in
ddtrace/internal/|ddtrace-internal| may importddtrace-native, neverddtrace||
ddtrace/internal/coverage/|ddtrace-coverage| ||
ddtrace/testing/|ddtrace-testing(later) | |What changes
-
envgets the supported-configurations registry (with aliases and sensitive names) fromddtrace/__init__.pyinstead of importing it.-
get_loggerlogs package code under its formerddtrace.name, so log names, handlers and_DD_<PRODUCT>_LOG_LEVELare unchanged. This also fixes order-dependent level resolution and%arguments being formatted after the exception text.- Moving modules that log through stdlib
logginguse the same normalization aslogging.getLogger(logger_name(__name__)).settings.envcan't import the logger, so it spells its name out.- The logger setup moves to
ddtrace/internal/logger_setup.py.- The generic msgpack packer moves out of
_encodingintonative/_msgpack, and_threadsmoves intonative/.- The Rust code imports the
_msgpacknext to it, so it no longer importsddtraceand_register_packbis gone.-
native/__init__.pynow only re-exports. The fork reseed hook is registered inddtrace/__init__.py, and the Python helpernative/exceptions.pymoves out tonative_exceptions.py.-
scripts/lint native-import-checkenforces this.-
ddtrace.internal._threadsstays as a temporary alias for now.ddtrace/internal/telemetry_inputs/instead of importing them. This also fixes error attribution, which would have missed_ddtrace_paths.packages.pyfinds itsthird-party.tar.gzdata from its own package instead of the hardcodedddtrace.internal.- Its tracer touchpoints go through
tracer_api.- The
ci_visibilityhelpers it used, and the coverage.py logic, move intoddtrace.testing;contrib.internal.coveragestays as a thin integration.- Importing the pytest plugin loads no tracer modules, which a test asserts.
- Test events take
library_versionfrom the version registered with telemetry, which is ddtrace's, so they're unchanged.sysconfig.internal/constants, andddtrace.constantsre-exports them unchanged.cleanup_loaded_modules()keeps_ddtrace_*modules, so bridged modules aren't imported twice.frozen-paths.txtfreezes the 33 files ported in this wave: 15 toddtrace-internal0.4.0 (DataDog/datadog-apm-python#77) and 18 toddtrace-coverage(DataDog/datadog-apm-python#82). Each package's bridge PR removes its entries.Testing
- the relocated
_msgpackand_threadsbinaries, loaded without ddtrace;- the fork reseed under
import ddtrace,ddtrace.autoandddtrace-run;- logger names and levels;
- the bootstrap cleanup;
- telemetry inputs and error attribution;
- the tracer isolation of test optimization;
- the unchanged
ddtrace.constantsnamespace.ddtrace-internal(with the shared runtime),ddtrace-coverage,ddtrace-nativeand a prototypeddtrace-testing. On Python 3.13 every suite matched the base branch by failing test ID, and pytest ran with the plugin withoutddtraceinstalled. The last four changes (logger names,native_exceptions, thepackages.pydata lookup, the test-event version) came out of it.native-import-check,supported-config-check, layers and suitespec checks pass.packband the encoders benchmark within noise.Risks
ddtrace/__init__.pynow registers the configuration registry, the reseed hook and the telemetry inputs before anything else, soforksafe,nativeandutils.versionload earlier.get_loggerorlogger_name. A plainlogging.getLogger(__name__)isn't normalized.Additional Notes
Follow-up PRs, reviewed by their owners: telemetry's AppSec inputs (asm-python), and moving the serverless tests off the
_threadsalias. No release notes: internal refactors only.