chore(crashtracking): reconfigure after identity refresh - #19823
litianningdatadog wants to merge 2 commits into
Conversation
Circular import analysis
|
Dependency direction analysis
|
Codeowners resolved asResolved from the full PR diff against |
|
BenchmarksBenchmark execution time: 2026-08-25 18:04:10 Comparing candidate commit 6e3841d in PR branch Found 0 performance improvements and 10 performance regressions! Performance is the same for 608 metrics, 10 unstable metrics.
|
d59e112 to
16a5332
Compare
1176485 to
96bb152
Compare
Define web request event names in ddtrace.internal.core.event_names so integrations and lower-level runtime hooks can depend on the same event strings without duplicating literals. The MicroVM runtime hook needs WEB_REQUEST_STARTING during ddtrace bootstrap. Importing ddtrace.contrib from that path can load trace handlers that import top-level ddtrace.config before __init__ has exported it, producing a circular import in MicroVM images. Keeping the names in a core constants-only module gives both contrib and runtime a safe dependency point.
16a5332 to
8dd7e8e
Compare
96bb152 to
c760e6d
Compare
cde3045 to
a0e3c42
Compare
c760e6d to
426f6b5
Compare
There was a problem hiding this comment.
Pull request overview
This PR ensures crashtracking metadata stays in sync with refreshed runtime identity (e.g., after MicroVM restore) by adding a native “reconfigure” entrypoint and wiring crashtracking to re-run configuration when identity changes.
Changes:
- Add a new native binding
crashtracker_reconfigureand expose it to Python. - Register an identity-change callback in
ddtrace.internal.core.crashtrackingto rebuild crashtracker args/metadata on identity refresh. - Add a subprocess test asserting reconfiguration happens after
runtime.refresh_identity().
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
ddtrace/internal/core/crashtracking.py |
Registers runtime-id change callback and triggers crashtracker reconfiguration with refreshed metadata. |
ddtrace/internal/native/_native.pyi |
Adds typing stub for the new crashtracker_reconfigure native function. |
src/native/lib.rs |
Exposes crashtracker_reconfigure from the Rust extension module. |
src/native/crashtracker.rs |
Implements the new crashtracker_reconfigure pyfunction forwarding into libdd_crashtracker. |
tests/crashtracker/test_crashtracker.py |
Adds regression test validating identity refresh triggers crashtracker reconfiguration. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| def _reconfigure_for_identity_refresh(additional_tags: Optional[dict[str, str]]) -> None: | ||
| if not is_started(): | ||
| return | ||
|
|
||
| config, receiver_config, metadata = _get_args(additional_tags) | ||
| if config is None or receiver_config is None or metadata is None: | ||
| log.error("Failed to reconfigure crashtracker after identity refresh: failed to construct configuration") | ||
| return | ||
| crashtracker_reconfigure(config, receiver_config, metadata) | ||
|
|
| crashtracker_on_fork(config, receiver_config, metadata) | ||
|
|
||
| forksafe.register(crashtracker_fork_handler) | ||
| _identity_refresh_additional_tags = additional_tags |
|
|
||
| forksafe.register(crashtracker_fork_handler) | ||
| _identity_refresh_additional_tags = additional_tags | ||
| on_runtime_id_change(_on_identity_refresh) |
426f6b5 to
6e3841d
Compare
|
close it as it is out of the scope |
Stacked PRs:
Description
Split from #19780.
Crashtracking configuration includes runtime identity. Reconfigure crashtracking after runtime identity refresh so crash reports from a restored MicroVM instance use the refreshed runtime id.
Testing
scripts/lint format_check ddtrace/internal/core/crashtracking.py ddtrace/internal/native/_native.pyi tests/crashtracker/test_crashtracker.pygit diff --checkStack
Draft split branch. Stacked on #19816.