fix(tracing): discard native buffers on MicroVM identity refresh - #20150
Conversation
Codeowners resolved asResolved from the full PR diff against |
Circular import analysis
|
Dependency direction analysis
|
|
There was a problem hiding this comment.
🔵 Needs a closer look
It changes native lifecycle semantics and updates Rust/libdatadog dependencies, which warrants final human review despite the added targeted tests.
Pull request overview
This PR extends the Lambda MicroVM runtime-identity refresh reset path by introducing discard-without-flush lifecycle hooks for libdatadog-backed native trace exporter buffers and the native telemetry worker, and by tightening SpanAggregator reset ordering to prevent pre-refresh traces from being written across the refresh boundary.
Changes:
- Add native discard/shutdown-without-flush hooks (Rust/PyO3) for telemetry workers and trace exporters, and invoke them during identity refresh / buffer drop paths.
- Make SpanAggregator reset keep writer replacement and trace-buffer invalidation atomic under the same lock when dropping buffered traces.
- Update tests to assert discard semantics and ordering guarantees; bump libdatadog git rev to a pinned commit (Cargo.toml/Cargo.lock).
File summaries
| File | Description |
|---|---|
| tests/tracer/test_writer.py | Verifies native writer buffer drops do not flush and that exporter discard is invoked. |
| tests/tracer/test_processors.py | Adds a concurrency test ensuring reset buffer invalidation and writer recreation remain atomic during identity refresh. |
| tests/telemetry/test_writer.py | Updates MicroVM identity refresh telemetry test to assert worker discard (not stop/flush). |
| tests/telemetry/test_telemetry.py | Adds subprocess test validating native telemetry worker discard unregisters the worker idempotently. |
| ddtrace/internal/writer/writer.py | Calls native exporter shutdown_without_flush() from NativeWriter.drop_buffered_traces(). |
| ddtrace/_trace/processor/init.py | Moves trace-buffer invalidation into the writer-replacement critical section for the identity-refresh discard path. |
| ddtrace/internal/telemetry/writer.py | Switches runtime identity refresh teardown from stop(send_app_closing=False) to discard(). |
| src/native/data_pipeline/mod.rs | Exposes shutdown_without_flush on the PyO3 TraceExporter wrapper. |
| src/native/telemetry.rs | Adds PyO3 TelemetryWorkerPy.discard() to discard pending telemetry without flushing and stop the worker. |
| src/native/Cargo.toml | Pins libdatadog dependencies to a specific commit rev and updates live-debugger package mapping. |
| src/native/Cargo.lock | Updates the resolved dependency graph for the new libdatadog rev (including new transitive crates). |
Review details
- Files reviewed: 10/11 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
BenchmarksBenchmark execution time: 2026-09-09 17:26:13 Comparing candidate commit 181f65c in PR branch Found 0 performance improvements and 7 performance regressions! Performance is the same for 574 metrics, 10 unstable metrics, 1 known flaky benchmarks, 17 flaky benchmarks without significant changes.
|
d41721f to
181f65c
Compare
Description
Builds on the MicroVM identity-refresh reset path by using discard-only native lifecycle hooks for libdatadog-backed trace and telemetry buffers. Native trace exporter buffers now shut down without flushing during identity refresh, and the native telemetry worker is discarded instead of stopped/flushed before it is rebuilt with the refreshed runtime ID.
The span aggregator keeps writer replacement and active trace invalidation under the same lock so pre-refresh traces cannot be written through the replacement writer during the refresh boundary.
Testing
Tested it with the expected libdatadog change (PR 2478) and the logs show the reset is invoked upon MicroVM receives
/run/event.Risks
The intended behavior drops pre-refresh native trace/telemetry buffers during Lambda MicroVM identity refresh. Rust/native dependency changes may need the native benchmark/build jobs before this leaves draft.
Additional Notes
Stacked draft PR on top of #20149. The MicroVM identity-refresh release note is already covered earlier in the stack; this PR should use the changelog/no-changelog label.