feat(trace_buffer): adopt libdatadog's TraceBuffer and SharedRuntime#226
Open
Aaalibaba42 wants to merge 5 commits into
Open
feat(trace_buffer): adopt libdatadog's TraceBuffer and SharedRuntime#226Aaalibaba42 wants to merge 5 commits into
Aaalibaba42 wants to merge 5 commits into
Conversation
|
3ba789c to
e6304ac
Compare
3fdeef4 to
167d226
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Replace the in-tree
AsyncTraceExporter(buffering, flushing, shutdown orchestration) withlibdatadog's
TraceBuffer+SharedRuntime, which is the same implementation that was upstreamedfrom this repo. The
DatadogExporteris now a thin wrapper that owns aTraceBufferand aSharedRuntimeinstead of managing its own background thread, batch queue, and condvarsynchronisation.
Why?
The trace buffer logic was moved to libdatadog so it can be shared across language tracers. Keeping
a duplicate copy here means diverging bug fixes, duplicated tests, and extra maintenance. Adopting
the libdatadog version lets us delete ~860 lines of
exporter/mod.rsand benefit from upstreamimprovements (e.g. runtime-aware shutdown) for free.
How?
Adopt
TraceBuffer+SharedRuntime— deletedexporter/mod.rsentirely; rewiredDatadogExporterinspan_exporter.rsto create aSharedRuntime, build aTraceExportervia
TraceExporterBuilder, and wrap both in aTraceBuffer. TheMapperExporterimplementsExport<SpanData>for the OTel-to-DD conversion.Fix tokio-inside-tokio panic — the buffer worker runs inside
SharedRuntime's tokioscheduler, so the old synchronous
send_trace_chunkstriggered a nestedblock_on. Switchedto
send_trace_chunks_asyncand moved the OTel-to-DD conversion inside the async block soborrows stay within the future. Also added a pre-shutdown
flush_and_waitto ensure the statsworker starts before the runtime tears down.
Add
Dropimpl forDatadogExporter— callers that forget to callshutdown()now get abest-effort teardown with a 1s timeout. The impl is idempotent: a prior explicit shutdown makes
the
Dropa no-op. Includes two regression tests exercising drop-inside-tokio anddrop-after-explicit-shutdown.
Additional Notes
jwiriath/tracebuffer-sharedruntime-rusttracerbranch;these need to be updated to
main(or pinned versions) once the libdatadog PR lands.test-utilsfeature gate exposes await_readyhook onMapperExporterso snapshot testscan wait for agent info before asserting on stats-derived metrics.