Skip to content

feat(data-pipeline): move the async boundary up#2064

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
mainfrom
jwiritah/move-async-up
Jun 2, 2026
Merged

feat(data-pipeline): move the async boundary up#2064
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
mainfrom
jwiritah/move-async-up

Conversation

@Aaalibaba42
Copy link
Copy Markdown
Contributor

Summary

Today SharedRuntime::block_on is buried deep inside the data pipeline (in
check_agent_info, stop_stats_computation, telemetry start-up and send_deser).
That forces every internal path to block on a runtime even when the caller is
already async, and makes it impossible for an async host to drive libdatadog
without nested-runtime hazards.

This PR pushes the async/sync boundary up to the top-level public entry
points. The internals are now async all the way down, and the synchronous
methods are thin block_on facades over their _async counterparts. This is a
prerequisite for letting async consumers (e.g. a Rust service embedding
dd-trace-rs) call the _async API directly.

The change is self-contained to libdd-data-pipeline and does not touch
libdd-shared-runtime; the sync facades keep using the existing owned-mode
SharedRuntime::block_on.

What changed

trace_exporter/mod.rs

  • send, send_trace_chunks, shutdown are now thin block_on facades over
    send_async, send_trace_chunks_async and the new shutdown_async.
  • check_agent_info is now async (native + wasm); it awaits the stats path
    and takes an owned status snapshot via load_full() to avoid holding a
    !Send ArcSwap guard across .await.
  • Removed send_deser — its deserialize-and-send logic already lives in
    send_async.

trace_exporter/builder.rs

  • Added build_async (the real builder body); build is now a block_on
    facade that materializes the SharedRuntime up front so both share a single
    instance.
  • Telemetry start-up is awaited directly (client_tel.start().await) instead of
    block_on.
  • The !Send Handle::enter() guard is scoped to a block so it drops before any
    .await, keeping the future Send.

trace_exporter/stats.rs

  • stop_stats_computation and handle_stats_enabled are now async and await
    the stats-worker shutdown directly instead of routing through block_on.

Notes / compatibility

  • Public sync signatures (send, send_trace_chunks, shutdown, build) are
    unchanged, so FFI callers are unaffected.
  • The sync build facade is gated to native (#[cfg(not(target_arch = "wasm32"))]),
    matching the existing convention where send/send_trace_chunks are
    native-only and wasm consumers use the _async variants (block_on does not
    exist on wasm). build_async is cross-platform.

@Aaalibaba42 Aaalibaba42 requested a review from a team as a code owner May 29, 2026 16:34
@github-actions
Copy link
Copy Markdown
Contributor

Clippy Allow Annotation Report

Comparing clippy allow annotations between branches:

  • Base Branch: origin/main
  • PR Branch: origin/jwiritah/move-async-up

Summary by Rule

Rule Base Branch PR Branch Change
unwrap_used 2 2 No change (0%)
Total 2 2 No change (0%)

Annotation Counts by File

File Base Branch PR Branch Change
libdd-data-pipeline/src/trace_exporter/mod.rs 2 2 No change (0%)

Annotation Stats by Crate

Crate Base Branch PR Branch Change
clippy-annotation-reporter 5 5 No change (0%)
datadog-ffe-ffi 1 1 No change (0%)
datadog-ipc 21 21 No change (0%)
datadog-live-debugger 6 6 No change (0%)
datadog-live-debugger-ffi 10 10 No change (0%)
datadog-profiling-replayer 4 4 No change (0%)
datadog-remote-config 3 3 No change (0%)
datadog-sidecar 57 57 No change (0%)
libdd-common 13 13 No change (0%)
libdd-common-ffi 12 12 No change (0%)
libdd-data-pipeline 5 5 No change (0%)
libdd-ddsketch 2 2 No change (0%)
libdd-dogstatsd-client 1 1 No change (0%)
libdd-profiling 13 13 No change (0%)
libdd-telemetry 20 20 No change (0%)
libdd-tinybytes 4 4 No change (0%)
libdd-trace-normalization 2 2 No change (0%)
libdd-trace-obfuscation 3 3 No change (0%)
libdd-trace-stats 1 1 No change (0%)
libdd-trace-utils 13 13 No change (0%)
Total 196 196 No change (0%)

About This Report

This report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality.

@datadog-official
Copy link
Copy Markdown

datadog-official Bot commented May 29, 2026

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 71.01%
Overall Coverage: 73.43% (+0.03%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 4c79a65 | Docs | Datadog PR Page | Give us feedback!

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 29, 2026

Codecov Report

❌ Patch coverage is 71.01449% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.43%. Comparing base (a84923e) to head (4c79a65).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2064      +/-   ##
==========================================
+ Coverage   73.40%   73.43%   +0.02%     
==========================================
  Files         464      464              
  Lines       77970    77934      -36     
==========================================
- Hits        57236    57230       -6     
+ Misses      20734    20704      -30     
Components Coverage Δ
libdd-crashtracker 65.46% <ø> (ø)
libdd-crashtracker-ffi 37.68% <ø> (ø)
libdd-alloc 98.77% <ø> (ø)
libdd-data-pipeline 87.13% <71.01%> (+0.65%) ⬆️
libdd-data-pipeline-ffi 77.03% <ø> (ø)
libdd-common 79.89% <ø> (ø)
libdd-common-ffi 74.41% <ø> (ø)
libdd-telemetry 73.34% <ø> (-0.03%) ⬇️
libdd-telemetry-ffi 31.36% <ø> (ø)
libdd-dogstatsd-client 82.64% <ø> (ø)
datadog-ipc 76.22% <ø> (ø)
libdd-profiling 81.69% <ø> (-0.02%) ⬇️
libdd-profiling-ffi 64.79% <ø> (ø)
libdd-sampling 97.41% <ø> (ø)
datadog-sidecar 34.60% <ø> (-0.05%) ⬇️
datdog-sidecar-ffi 8.61% <ø> (ø)
spawn-worker 48.86% <ø> (ø)
libdd-tinybytes 93.80% <ø> (ø)
libdd-trace-normalization 81.71% <ø> (ø)
libdd-trace-obfuscation 87.30% <ø> (ø)
libdd-trace-protobuf 68.25% <ø> (ø)
libdd-trace-utils 89.21% <ø> (ø)
libdd-tracer-flare 86.88% <ø> (ø)
libdd-log 74.83% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 29, 2026

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 7.63 MB 7.63 MB -0% (-24 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 82.98 MB 82.91 MB --.08% (-69.52 KB) 💪
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.26 MB 10.26 MB +0% (+632 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 94.05 MB 93.99 MB --.06% (-65.79 KB) 💪
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 24.57 MB 24.54 MB --.12% (-30.50 KB) 💪
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 83.96 KB 83.96 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 178.35 MB 178.18 MB --.09% (-176.00 KB) 💪
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 915.73 MB 913.88 MB --.20% (-1.84 MB) 💪
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 8.03 MB 8.03 MB --.04% (-3.50 KB) 💪
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 83.96 KB 83.96 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 23.78 MB 23.77 MB --.03% (-8.00 KB) 💪
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 47.44 MB 47.42 MB --.03% (-17.99 KB) 💪
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 21.28 MB 21.26 MB --.12% (-28.00 KB) 💪
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 85.29 KB 85.29 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 182.30 MB 182.13 MB --.08% (-168.00 KB) 💪
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 908.33 MB 906.50 MB --.20% (-1.83 MB) 💪
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 6.20 MB 6.20 MB --.04% (-3.00 KB) 💪
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 85.29 KB 85.29 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 25.49 MB 25.48 MB --.03% (-8.00 KB) 💪
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 45.09 MB 45.07 MB --.03% (-16.40 KB) 💪
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 73.98 MB 73.94 MB --.06% (-47.67 KB) 💪
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.53 MB 8.53 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 89.38 MB 89.34 MB --.05% (-47.54 KB) 💪
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.37 MB 10.37 MB +.01% (+1.35 KB) 🔍

Comment thread libdd-data-pipeline/src/trace_exporter/builder.rs Outdated
Comment thread libdd-data-pipeline/src/trace_exporter/stats.rs Outdated
@Aaalibaba42
Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented Jun 1, 2026

View all feedbacks in Devflow UI.

2026-06-01 16:27:31 UTC ℹ️ Start processing command /merge


2026-06-01 16:27:37 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-06-01 16:57:12 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in main is approximately 46m (p90).


2026-06-01 17:51:13 UTCMergeQueue: The checks failed on this merge request

Tests failed on this commit 5d789af:

What to do next?

  • Investigate the failures and when ready, re-add your pull request to the queue!
  • If your PR checks are green, try to rebase/merge. It might be because the CI run is a bit old.
  • Any question, go check the FAQ.

@Aaalibaba42 Aaalibaba42 force-pushed the jwiritah/move-async-up branch from c0c430d to 4c79a65 Compare June 2, 2026 10:13
@Aaalibaba42
Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented Jun 2, 2026

View all feedbacks in Devflow UI.

2026-06-02 10:31:42 UTC ℹ️ Start processing command /merge


2026-06-02 10:31:49 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-06-02 10:53:12 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in main is approximately 47m (p90).


2026-06-02 11:43:58 UTCMergeQueue: The checks failed on this merge request

Tests failed on this commit f2bb5f4:

What to do next?

  • Investigate the failures and when ready, re-add your pull request to the queue!
  • If your PR checks are green, try to rebase/merge. It might be because the CI run is a bit old.
  • Any question, go check the FAQ.

@Aaalibaba42
Copy link
Copy Markdown
Contributor Author

#test Windows latest is too slow for all_checks so failing merge queue :c

@Aaalibaba42
Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented Jun 2, 2026

View all feedbacks in Devflow UI.

2026-06-02 12:26:41 UTC ℹ️ Start processing command /merge


2026-06-02 12:26:46 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 47m (p90).


2026-06-02 13:44:30 UTC ℹ️ MergeQueue: Readding this merge request to the queue because another merge request processed with yours failed. No action is needed from your side.


2026-06-02 15:44:28 UTC ℹ️ MergeQueue: Readding this merge request to the queue because another merge request processed with yours failed. No action is needed from your side.


2026-06-02 16:28:30 UTC ℹ️ MergeQueue: This merge request was merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants