refactor: move helpers out of ddtrace.internal.runtime.__init__ - #19812
refactor: move helpers out of ddtrace.internal.runtime.__init__#19812emmettbutler wants to merge 2 commits into
Conversation
…yering violations
🎉 All green!🧪 All tests passed 🔗 Commit SHA: 7cf365a | Docs | View more details | Give us feedback! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 640d257ccc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| from .. import forksafe | ||
| from ddtrace.internal._runtime_id import get_ancestor_runtime_id | ||
| from ddtrace.internal._runtime_id import get_parent_runtime_id | ||
| from ddtrace.internal._runtime_id import get_process_role |
There was a problem hiding this comment.
Update process-role mocks to patch the moved state
When the profiling suite runs test_uwsgi_postfork_worker_role_via_mock or test_uwsgi_main_role_via_mock, tests/profiling/test_process_role.py still calls monkeypatch.setattr(ddtrace.internal.runtime, "_PARENT_RUNTIME_ID", ...). This wrapper no longer defines that attribute, so both tests raise AttributeError before reaching their assertions; update those mocks to patch ddtrace.internal._runtime_id (where get_process_role now reads the state), or preserve compatible forwarding.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The move removes _PARENT_RUNTIME_ID from ddtrace.internal.runtime. Two profiling tests still patch that name, so they fail with AttributeError before their assertions.
🤖 Datadog Autotest · Commit 640d257 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
| from .. import forksafe | ||
| from ddtrace.internal._runtime_id import get_ancestor_runtime_id | ||
| from ddtrace.internal._runtime_id import get_parent_runtime_id | ||
| from ddtrace.internal._runtime_id import get_process_role |
There was a problem hiding this comment.
Retarget process-role state mocks after the move
The profiling test suite fails, so the PR cannot complete required validation.
Assertion details
- Input: Run test_uwsgi_postfork_worker_role_via_mock or test_uwsgi_main_role_via_mock in tests/profiling/test_process_role.py.
- Expected:
The profiling tests must patch _PARENT_RUNTIME_ID in ddtrace.internal._runtime_id, where the state now exists. - Actual:
Both monkeypatch.setattr calls raise AttributeError because ddtrace.internal.runtime no longer has _PARENT_RUNTIME_ID. The tests stop before their assertions.
Was this helpful? React 👍 or 👎
🤖 Datadog Autotest · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
Codeowners resolved asResolved from the full PR diff against |
Circular import analysis
|
Dependency direction analysis
|
BenchmarksBenchmark execution time: 2026-08-21 19:14:31 Comparing candidate commit 7cf365a in PR branch Found 0 performance improvements and 10 performance regressions! Performance is the same for 605 metrics, 10 unstable metrics.
|
This change eliminates layering violations dependent on
ddtrace.internal.runtimeby moving the non-product-specific helper functions out of that module.