chore(runtime): add explicit identity refresh - #19778
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
Conversation
Circular import analysis
|
Codeowners resolved asResolved from the full PR diff against No remaining files require a CODEOWNERS review. |
Dependency direction analysis
|
|
✅ All CI checks and tests passed. 🎉 All green!🧪 All tests passed 🔗 Commit SHA: a444344 | Docs | View more details | Give us feedback! |
BenchmarksBenchmark execution time: 2026-09-25 22:05:56 Comparing candidate commit a444344 in PR branch Found 0 performance improvements and 6 performance regressions! Performance is the same for 350 metrics, 9 unstable metrics, 4 known flaky benchmarks, 4 flaky benchmarks without significant changes.
|
There was a problem hiding this comment.
Pull request overview
Adds an explicit, non-fork “process identity refresh” pathway for runtimes that can resume from snapshots without an OS-level fork, along with a weakly-referenced subscriber mechanism so long-lived components can rebuild identity-bound state without leaking instances.
Changes:
- Introduces
ddtrace.internal.runtime.refresh_identity()to rotate the runtime id without recording fork lineage and to notify registered subscribers. - Refactors
on_runtime_id_change()to store subscribers via weak references and isolates subscriber exceptions during notification. - Expands runtime-id test coverage for refresh semantics, lineage invariants, subscriber notification, exception isolation, and weakref cleanup.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
ddtrace/internal/runtime/__init__.py |
Adds refresh_identity(), weakref-based subscriber registry, and subscriber notification isolation; keeps fork behavior on the forksafe hook without subscriber notification. |
tests/tracer/runtime/test_runtime_id.py |
Adds subprocess-based tests for refresh behavior and subscriber semantics; updates imports for runtime module usage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
aac2ec3 to
2fa8088
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2fa8088e77
ℹ️ 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".
brettlangdon
left a comment
There was a problem hiding this comment.
This feels very over-engineered, I don't feel like it is clear why we are moving everything to be weakrefs? it adds a ton of machinery that isn't clear the value we are getting from it.
I am also surprised that removing notifications from _set_runtime_id doesn't break a bunch of things, or how it wouldn't break a bunch of things.
d4a3faa to
1cbc151
Compare
b6d2990 to
1d76905
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Callback failures can leave explicit-refresh consumers with stale identity-dependent state.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (1)
tests/tracer/runtime/test_runtime_id.py:81
- This only verifies that the fork itself does not invoke the refresh callback. It would still pass if the child lost the callback registry entirely, so it does not cover the stated guarantee that refresh subscribers remain registered after a fork. Invoke
refresh_identity()in the child and assert that the inherited subscriber receives the new ID.
child = os.fork()
if child == 0:
assert seen == []
os._exit(42)
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
1d76905 to
cf61847
Compare
3d6fc0f to
fca3bcb
Compare
a9aa117 to
1b30f8f
Compare
|
/merge |
|
View all feedbacks in Devflow UI.
It will be processed automatically as soon as GitHub reports it as mergeable. View in MergeQueue UI.
devflow unqueued this merge request: It did not become mergeable within the expected time |
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
This PR is rejected because it was updated |
976f653 to
b06e5c0
Compare
Signed-off-by: Tianning Li <tianning.li@datadoghq.com>
b06e5c0 to
a444344
Compare
Stacked PRs:
Description
Adds
ddtrace.internal.runtime.refresh_identity()for runtimes that need a fresh runtime ID without going through an OS fork.This introduces
on_runtime_identity_refresh(), a dedicated callback registry for consumers that should react only to explicit identity refreshes. Existingon_runtime_id_change()behavior remains available for fork-related and general runtime-ID change handling.refresh_identity()rotates the runtime ID without recording parent or ancestor lineage because a resumed MicroVM run is not a real fork. Existing fork behavior and lineage tracking remain unchanged.Refresh callbacks are isolated by default so one failed consumer does not block others. Callers coordinating a refresh transaction can opt into error propagation with
raise_on_error=Trueand retry the same identity refresh when a rebuild fails.Reference
Testing
Added coverage for:
refresh_identity()raise_on_error=TrueValidation:
scripts/run-tests -s --venv 190fcc7 -- -q tests/tracer/runtime/test_runtime_id.py— 21 passedscripts/lint checks— passedRisks
Low. The new path is opt-in and is not wired to traffic in this PR. Existing fork behavior is preserved.