Skip to content

feat(shared-runtime)!: SharedRuntime Borrowed & Owned mode#2061

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 16 commits into
mainfrom
jwiriath/shared-runtime-mods
Jun 24, 2026
Merged

feat(shared-runtime)!: SharedRuntime Borrowed & Owned mode#2061
gh-worker-dd-mergequeue-cf854d[bot] merged 16 commits into
mainfrom
jwiriath/shared-runtime-mods

Conversation

@Aaalibaba42

@Aaalibaba42 Aaalibaba42 commented May 29, 2026

Copy link
Copy Markdown
Contributor

What ?

Split SharedRuntime into a trait with three implementations:

  • ForkSafeRuntime (native only): owns a multi-thread tokio runtime, supports fork
    hooks (before_fork / after_fork_parent / after_fork_child) and synchronous
    shutdown.
  • BasicRuntime (native only): wraps a library-built or caller-provided
    Arc<tokio::runtime::Runtime>, no fork hooks, no synchronous shutdown.
  • LocalRuntime (wasm32 only): single-threaded executor that spawns workers via
    wasm_bindgen_futures::spawn_local, no fork protocol, async-only.

BlockingRuntime (native only) is a sub-trait of SharedRuntime that adds
block_on; implemented by ForkSafeRuntime and BasicRuntime. Sync facades on the
trace exporter (send / shutdown / build) bound their runtime parameter on it.

TraceExporter is generic over the runtime — TraceExporter<C, R: SharedRuntime>
— so callers pick ForkSafeRuntime, BasicRuntime, or LocalRuntime explicitly. The
FFI pins R = ForkSafeRuntime for ABI stability.

Why ?

Some callers already have a tokio runtime they want to reuse instead of letting
libdatadog create its own. The previous SharedRuntime only supported the
fork-safe owned case. Splitting into distinct types makes the lifecycle and
fork-safety contract explicit and lets callers pick the model that matches their
environment.

The wasm32 target previously shared a file with the native implementation behind
#[cfg] walls; it is now a dedicated module with a clean separation.

How ?

  • Introduce a SharedRuntime trait (new, spawn_worker, shutdown_async).
  • Add a native-only BlockingRuntime: SharedRuntime sub-trait with block_on.
  • Move the existing owned-runtime logic into ForkSafeRuntime; fork hooks and sync
    shutdown are inherent methods (not part of the trait).
  • Add BasicRuntime::with_worker_threads (library-built) and
    BasicRuntime::from_handle(Arc<Runtime>) (caller-provided).
  • Extract the wasm32 spawn_local path from fork_safe.rs into its own
    local.rs module as LocalRuntime.
  • Make TraceExporter<C, R> and TraceExporterBuilder<R> generic over the runtime;
    sync entry points additionally require R: BlockingRuntime. Default for the
    builder is impl'd only for R = ForkSafeRuntime on native so
    TraceExporterBuilder::default() resolves unambiguously.
  • restart_on_fork = true is silently ignored (with a warn!) on BasicRuntime
    and LocalRuntime since they do not implement a fork protocol.
  • Update FFI to pin R = ForkSafeRuntime in its TraceExporter type alias.

Additional Notes

  • Breaking change for Rust callers of libdd_shared_runtime: SharedRuntime is
    now a trait; use ForkSafeRuntime::with_worker_threads(1) (or the trait method
    SharedRuntime::new() with the trait in scope) instead of SharedRuntime::new().
  • FFI handle type changes from SharedRuntime to ForkSafeRuntime.

@Aaalibaba42
Aaalibaba42 requested a review from a team as a code owner May 29, 2026 14:03
@Aaalibaba42
Aaalibaba42 force-pushed the jwiriath/shared-runtime-mods branch from b0f4da8 to 50536ba Compare May 29, 2026 14:06

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 13d5a971de

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread libdd-shared-runtime/src/shared_runtime/borrowed.rs Outdated
@github-actions

github-actions Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

Clippy Allow Annotation Report

Comparing clippy allow annotations between branches:

  • Base Branch: origin/main
  • PR Branch: origin/jwiriath/shared-runtime-mods

Summary by Rule

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

Annotation Counts by File

File Base Branch PR Branch Change
libdd-data-pipeline/src/telemetry/mod.rs 1 1 No change (0%)
libdd-data-pipeline/src/trace_buffer/mod.rs 1 1 No change (0%)
libdd-data-pipeline/src/trace_exporter/mod.rs 2 2 No change (0%)
libdd-telemetry/src/worker/mod.rs 14 14 No change (0%)
libdd-trace-stats/src/stats_exporter.rs 1 1 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 22 22 No change (0%)
datadog-live-debugger 4 4 No change (0%)
datadog-live-debugger-ffi 10 10 No change (0%)
datadog-profiling-replayer 4 4 No change (0%)
datadog-sidecar 45 45 No change (0%)
libdd-common 13 13 No change (0%)
libdd-common-ffi 12 12 No change (0%)
libdd-data-pipeline 6 6 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-remote-config 3 3 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 11 11 No change (0%)
Total 182 182 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-prod-us1-5

datadog-prod-us1-5 Bot commented May 29, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 94.05%
Overall Coverage: 74.03% (+0.07%)

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

@Aaalibaba42
Aaalibaba42 force-pushed the jwiriath/shared-runtime-mods branch 2 times, most recently from 64603e7 to 4e49301 Compare May 29, 2026 14:22
@Aaalibaba42

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4e49301fa3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread libdd-shared-runtime/src/shared_runtime/borrowed.rs Outdated
@codecov-commenter

codecov-commenter commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.95085% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.57%. Comparing base (a76412c) to head (61fbe96).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2061      +/-   ##
==========================================
+ Coverage   73.47%   73.57%   +0.09%     
==========================================
  Files         475      477       +2     
  Lines       78999    79219     +220     
==========================================
+ Hits        58048    58283     +235     
+ Misses      20951    20936      -15     
Components Coverage Δ
libdd-crashtracker 65.34% <ø> (ø)
libdd-crashtracker-ffi 37.68% <ø> (ø)
libdd-agent-client 83.79% <ø> (ø)
libdd-alloc 98.77% <ø> (ø)
libdd-data-pipeline 86.07% <96.55%> (-0.02%) ⬇️
libdd-data-pipeline-ffi 73.02% <0.00%> (ø)
libdd-common 79.93% <ø> (ø)
libdd-common-ffi 74.41% <ø> (ø)
libdd-telemetry 73.37% <100.00%> (+0.02%) ⬆️
libdd-telemetry-ffi 31.36% <ø> (ø)
libdd-dogstatsd-client 82.64% <ø> (ø)
datadog-ipc 76.36% <ø> (ø)
libdd-profiling 81.70% <ø> (-0.02%) ⬇️
libdd-profiling-ffi 64.79% <ø> (ø)
libdd-sampling 97.41% <ø> (ø)
datadog-sidecar 36.14% <ø> (-0.02%) ⬇️
datdog-sidecar-ffi 10.31% <ø> (ø)
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.30% <ø> (ø)
libdd-tracer-flare 86.57% <ø> (ø)
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

dd-octo-sts Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 7.82 MB 7.82 MB -0% (-24 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 84.81 MB 84.87 MB +.06% (+59.10 KB) 🔍
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.44 MB 10.44 MB +.01% (+1.83 KB) 🔍
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 95.94 MB 96.00 MB +.05% (+57.03 KB) 🔍
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 25.05 MB 25.05 MB +0% (+512 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 87.68 KB 87.68 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 182.45 MB 182.81 MB +.19% (+368.00 KB) 🔍
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 934.80 MB 936.10 MB +.13% (+1.30 MB) 🔍
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 8.20 MB 8.20 MB +0% (+512 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 87.68 KB 87.68 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 24.22 MB 24.23 MB +.03% (+8.00 KB) 🔍
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 48.32 MB 48.34 MB +.04% (+21.21 KB) 🔍
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 21.71 MB 21.71 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 89.06 KB 89.06 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 186.44 MB 186.78 MB +.18% (+344.00 KB) 🔍
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 923.52 MB 924.73 MB +.13% (+1.20 MB) 🔍
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 6.32 MB 6.33 MB +.02% (+1.50 KB) 🔍
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 89.06 KB 89.06 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 25.98 MB 25.99 MB +.03% (+8.00 KB) 🔍
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 45.94 MB 45.96 MB +.04% (+22.35 KB) 🔍
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 75.58 MB 75.64 MB +.07% (+58.32 KB) 🔍
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.68 MB 8.68 MB -0% (-32 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 91.04 MB 91.09 MB +.06% (+57.12 KB) 🔍
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.56 MB 10.57 MB +.01% (+1.77 KB) 🔍

@VianneyRuhlmann

Copy link
Copy Markdown
Contributor

It looks like the description is a bit off mentioning fixes and bugs that seem to be coming from previous commits of the branch and not from the current state of the feature

@Aaalibaba42

Copy link
Copy Markdown
Contributor Author

It looks like the description is a bit off mentioning fixes and bugs that seem to be coming from previous commits of the branch and not from the current state of the feature

I tried letting a cheap AI read the commits and make a description, I don't think it's too valuable and can even be detrimental, as it were.

@Aaalibaba42

Copy link
Copy Markdown
Contributor Author

I rewrote it cleaner and straighter to the point

@yannham yannham left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code LGTM overall, but I'm not entirely sure to fully grasp in which context (sync or async) is this API supposed to be consumed. In particular we use standard sync thread mechanisms (condvars, mutexes) in an async context, which could be problematic (even in a multi-thread context, a condvar will block the current executor thread, which is not ideal).

On a different front, I remember @paullegranddc said he would rather spawn our own shared runtime in a separate thread than hooking in the client's runtime. I don't have a strong opinion myself, but I wonder if this discussion had a conclusion.

Comment thread libdd-shared-runtime/src/shared_runtime/borrowed.rs Outdated
Comment thread libdd-shared-runtime/src/shared_runtime/borrowed.rs Outdated
Comment thread libdd-shared-runtime/src/shared_runtime/borrowed.rs Outdated
Comment thread libdd-shared-runtime/src/shared_runtime/borrowed.rs Outdated
@Aaalibaba42
Aaalibaba42 force-pushed the jwiriath/shared-runtime-mods branch from df92857 to 9d305e7 Compare June 5, 2026 11:00
@Aaalibaba42
Aaalibaba42 requested a review from a team as a code owner June 5, 2026 11:00
@Aaalibaba42 Aaalibaba42 changed the title feat(shared-runtime)!: add BorrowedRuntime for caller-owned tokio runtimes feat(shared-runtime)!: SharedRuntime Borrowed & Owned mode Jun 5, 2026
@Aaalibaba42
Aaalibaba42 force-pushed the jwiriath/shared-runtime-mods branch from 9d305e7 to 6b5b4db Compare June 5, 2026 11:35
Comment thread libdd-shared-runtime/src/shared_runtime/fork_safe.rs
@Aaalibaba42
Aaalibaba42 force-pushed the jwiriath/shared-runtime-mods branch from 6b5b4db to 5b21367 Compare June 5, 2026 11:56
@Aaalibaba42

Copy link
Copy Markdown
Contributor Author

Since the implementation was overhauled, I'll just resolve past conversations here, as they don't fit the current implementation.

@yannham yannham left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few remarks but otherwise looks good (only skimmed through the native implementation, as I suppose it's just the original shared runtime moved)👍

Comment thread libdd-shared-runtime/src/shared_runtime/basic.rs
Comment thread libdd-shared-runtime/src/shared_runtime/borrowed.rs Outdated
Comment thread libdd-shared-runtime/src/shared_runtime/mod.rs Outdated
Comment thread libdd-shared-runtime/src/shared_runtime/fork_safe.rs
Comment thread libdd-shared-runtime/src/shared_runtime/owned.rs Outdated
@Aaalibaba42
Aaalibaba42 force-pushed the jwiriath/shared-runtime-mods branch from ff3c135 to eb913a1 Compare June 8, 2026 11:25

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9fffdcbe44

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread libdd-shared-runtime/src/shared_runtime/basic.rs Outdated
@Aaalibaba42
Aaalibaba42 force-pushed the jwiriath/shared-runtime-mods branch from f292e28 to 10554e2 Compare June 17, 2026 12:35
@Aaalibaba42
Aaalibaba42 force-pushed the jwiriath/shared-runtime-mods branch from 890b2ff to a91e5c7 Compare June 19, 2026 11:35

@Eldolfin Eldolfin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits

Comment thread libdd-data-pipeline/src/trace_buffer/mod.rs
Comment thread libdd-shared-runtime/src/shared_runtime/basic.rs
Comment thread libdd-shared-runtime/src/lib.rs

@VianneyRuhlmann VianneyRuhlmann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments regarding the doc but LGTM.
I think this is a real improvement for the sahred runtime semantics, thanks for doing this

Comment thread libdd-data-pipeline/src/trace_exporter/builder.rs Outdated
Comment thread libdd-shared-runtime/src/shared_runtime/fork_safe.rs Outdated
Comment thread libdd-data-pipeline/src/telemetry/mod.rs
Comment thread libdd-data-pipeline/src/trace_exporter/builder.rs Outdated
Comment thread libdd-data-pipeline/src/trace_exporter/mod.rs Outdated
Comment thread libdd-shared-runtime/src/shared_runtime/basic.rs
Comment thread libdd-shared-runtime/src/shared_runtime/basic.rs Outdated
Comment thread libdd-shared-runtime/src/shared_runtime/mod.rs Outdated
Comment thread libdd-shared-runtime/src/shared_runtime/mod.rs Outdated
@Aaalibaba42
Aaalibaba42 force-pushed the jwiriath/shared-runtime-mods branch from dddc831 to 7fc9f4c Compare June 24, 2026 14:04
@Aaalibaba42

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

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

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-06-24 14:36:17 UTC ℹ️ Start processing command /merge


2026-06-24 14:36:25 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-24 15:13:15 UTC ℹ️ MergeQueue: merge request added to the queue

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


2026-06-24 16:25:22 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 4b79b7e into main Jun 24, 2026
110 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the jwiriath/shared-runtime-mods branch June 24, 2026 16:25
iunanua added a commit that referenced this pull request Jul 7, 2026
…ibdd-data-pipeline, libdd-li... (#2201)

# Release proposal for libdd-capabilities-impl, libdd-common,
libdd-data-pipeline, libdd-library-config, libdd-remote-config,
libdd-sampling, libdd-telemetry, libdd-tinybytes, libdd-trace-utils and
their dependencies

This PR contains version bumps based on public API changes and commits
since last release.

## libdd-capabilities
**Next version:** `2.1.0`
**Semver bump:** `minor`
**Tag:** `libdd-capabilities-v2.1.0`

### Commits

- feat(data-pipeline)!: add stdout log trace exporter (#2074)

## libdd-common
**Next version:** `5.1.0`
**Semver bump:** `minor`
**Tag:** `libdd-common-v5.1.0`

### Commits

- refactor(clippy): prefer core and alloc imports (#2196)
- fix: update rustls-webpki to 0.103.13 (#2187)
- fix: update anyhow for unsoundness (#2186)
- feat(machine id): Add helpers in ddcommon to fetch the machine UUID l…
(#2163)

## libdd-ddsketch
**Next version:** `1.1.0`
**Semver bump:** `minor`
**Tag:** `libdd-ddsketch-v1.1.0`

### Commits

- feat(data-pipeline)!: export client-computed span stats as OTLP trace
metrics (#2067)
- test(ddsketch): add microbenchmarks for add/encode/collapse (#2125)

## libdd-trace-protobuf
**Next version:** `4.0.0`
**Semver bump:** `major`
**Tag:** `libdd-trace-protobuf-v4.0.0`

### Commits

- chore!: update protobufs to be in sync with datadog-agent (#2180)
- feat(stats)!: add whole key cardinality limit (#2158)
- feat(remote-config)!: use the proto file from the agent (#2165)
- feat(data-pipeline): OTLP HTTP/protobuf trace export (#2115)

## libdd-capabilities-impl
**Next version:** `3.0.0`
**Semver bump:** `major`
**Tag:** `libdd-capabilities-impl-v3.0.0`

### ⚠️ major bump forced due to:

- `libdd-common`: ^4.1.0 → ^5.1.0

### Commits

- feat(data-pipeline)!: add stdout log trace exporter (#2074)

## libdd-library-config
**Next version:** `3.0.0`
**Semver bump:** `major`
**Tag:** `libdd-library-config-v3.0.0`

### ⚠️ major bump forced due to:

- `libdd-trace-protobuf`: ^3.0.2 → ^4.0.0

### Commits

- refactor(clippy): prefer core and alloc imports (#2196)
- feat(library-config)!: caller-supplied threadlocal schema and extra
process-context attributes (#2162)
- fix(otel-thread-ctx): put the threadlocal attributes at the right
place in the context (#2167)

## libdd-remote-config
**Next version:** `2.0.0`
**Semver bump:** `major`
**Tag:** `libdd-remote-config-v2.0.0`

### ⚠️ major bump forced due to:

- `libdd-trace-protobuf`: ^3.0.2 → ^4.0.0

### Commits

- refactor(libdd-remote-config)!: hide Target inner properties so they
are not leaked (#2182)
- feat(remote-config)!: use the proto file from the agent (#2165)
- refactor(rc): reexport Endpoint and Tag common types (#2147)

## libdd-trace-normalization
**Next version:** `3.0.0`
**Semver bump:** `major`
**Tag:** `libdd-trace-normalization-v3.0.0`

### ⚠️ major bump forced due to:

- `libdd-trace-protobuf`: ^3.0.1 → ^4.0.0

### Commits

- feat(data-pipeline)!: CSS Trace Filters (#1985)

## libdd-shared-runtime
**Next version:** `2.0.0`
**Semver bump:** `major`
**Tag:** `libdd-shared-runtime-v2.0.0`

### ⚠️ major bump forced due to:

- `libdd-common`: ^4.1.0 → ^5.1.0

### Commits

- feat(shared-runtime)!: SharedRuntime Borrowed & Owned mode (#2061)
- feat(shared-runtime)!: use weak waker in trigger [APMSP-3371] (#2050)

## libdd-trace-utils
**Next version:** `9.0.0`
**Semver bump:** `major`
**Tag:** `libdd-trace-utils-v9.0.0`

### ⚠️ major bump forced due to:

- `libdd-common`: ^4.2.0 → ^5.1.0
- `libdd-trace-protobuf`: ^3.0.2 → ^4.0.0

### Commits

- ci(miri): skip slow miri tests (#2188)
- chore!: update protobufs to be in sync with datadog-agent (#2180)
- feat(data-pipeline): add agentless export (#2081)
- feat(data-pipeline)!: add stdout log trace exporter (#2074)
- feat(data-pipeline): OTLP HTTP/protobuf trace export (#2115)
- feat(otlp)!: Export OTLP spans with attribute-level OTel compatibility
(#2091)
- test(trace-utils): add V05 msgpack decode microbenchmark (#2127)
- feat(data-pipeline)!: export client-computed span stats as OTLP trace
metrics (#2067)
- test(trace-utils): add VecMap microbenchmarks (#2126)
- chore(stats)!: submit p0 telemetry in stats (#2130)
- refactor(change-buffer)!: replace slot index with span_id, fix segment
isolation (#2105)
- feat(data-pipeline)!: CSS Trace Filters (#1985)
- feat(trace-exporter): add v1 span and its encoder (#2039)
- fix(trace-utils): mark decoded span maps as deduped (#2110)
- feat(trace-utils)!: change buffer implementation (#2055)
- feat(native-spans)!: change buffer foundation (#2046)
- refactor(span)!: use VecMap for `meta`, `metrics` and `meta_struct`
for v04 spans (#2043)
- test: fix timeouts on heavily contended scenarios (#2093)

## libdd-telemetry
**Next version:** `6.0.0`
**Semver bump:** `major`
**Tag:** `libdd-telemetry-v6.0.0`

### ⚠️ major bump forced due to:

- `libdd-common`: ^4.2.0 → ^5.1.0
- `libdd-shared-runtime`: ^1.0.0 → ^2.0.0

### Commits

- ci(miri): skip slow miri tests (#2188)
- refactor(libdd-telemetry)!: avoid leaking libdd-common types in the
public API (#2152)
- feat(shared-runtime)!: SharedRuntime Borrowed & Owned mode (#2061)

## libdd-trace-obfuscation
**Next version:** `5.0.0`
**Semver bump:** `major`
**Tag:** `libdd-trace-obfuscation-v5.0.0`

### ⚠️ major bump forced due to:

- `libdd-common`: ^4.2.0 → ^5.1.0
- `libdd-trace-protobuf`: ^3.0.2 → ^4.0.0
- `libdd-trace-utils`: ^8.0.0 → ^9.0.0

### Commits

- refactor(clippy): prefer core and alloc imports (#2196)
- ci(miri): skip slow miri tests (#2188)
- fix: update anyhow for unsoundness (#2186)

## libdd-trace-stats
**Next version:** `6.0.0`
**Semver bump:** `major`
**Tag:** `libdd-trace-stats-v6.0.0`

### ⚠️ major bump forced due to:

- `libdd-common`: ^4.2.0 → ^5.1.0
- `libdd-shared-runtime`: ^1.0.0 → ^2.0.0
- `libdd-trace-protobuf`: ^3.0.2 → ^4.0.0
- `libdd-trace-utils`: ^8.0.0 → ^9.0.0

### Commits

- chore!: update protobufs to be in sync with datadog-agent (#2180)
- feat(stats)!: send telemetry for cardinality limits (#2159)
- feat(stats)!: add whole key cardinality limit (#2158)
- fix(trace-stats)!: add grpc_method to aggregation key (#2151)
- feat(shared-runtime)!: SharedRuntime Borrowed & Owned mode (#2061)
- feat(data-pipeline)!: export client-computed span stats as OTLP trace
metrics (#2067)
- refactor(span)!: use VecMap for `meta`, `metrics` and `meta_struct`
for v04 spans (#2043)

## libdd-data-pipeline
**Next version:** `7.0.0`
**Semver bump:** `major`
**Tag:** `libdd-data-pipeline-v7.0.0`

### ⚠️ major bump forced due to:

- `libdd-common`: ^4.2.0 → ^5.1.0
- `libdd-shared-runtime`: ^1.0.0 → ^2.0.0
- `libdd-telemetry`: ^5.0.1 → ^6.0.0
- `libdd-trace-protobuf`: ^3.0.2 → ^4.0.0
- `libdd-trace-stats`: ^5.0.0 → ^6.0.0
- `libdd-trace-utils`: ^8.0.0 → ^9.0.0

### Commits

- feat(trace_exporter): enable telemetry in stats exporter (#2160)
- refactor(libdd-telemetry)!: avoid leaking libdd-common types in the
public API (#2152)
- feat(stats): emit canonical gRPC status name for OTLP
rpc.response.status_code (#2183)
- feat(data-pipeline): add agentless export (#2081)
- feat(stats)!: send telemetry for cardinality limits (#2159)
- feat(stats)!: add whole key cardinality limit (#2158)
- fix(trace-stats)!: add grpc_method to aggregation key (#2151)
- feat(data-pipeline)!: add stdout log trace exporter (#2074)
- feat(shared-runtime)!: SharedRuntime Borrowed & Owned mode (#2061)
- feat(data-pipeline): OTLP HTTP/protobuf trace export (#2115)
- feat(otlp)!: Export OTLP spans with attribute-level OTel compatibility
(#2091)
- feat(data-pipeline)!: export client-computed span stats as OTLP trace
metrics (#2067)
- chore(stats)!: submit p0 telemetry in stats (#2130)
- feat(data-pipeline)!: CSS Trace Filters (#1985)
- feat(shared-runtime)!: use weak waker in trigger [APMSP-3371] (#2050)
- refactor(span)!: use VecMap for `meta`, `metrics` and `meta_struct`
for v04 spans (#2043)
- feat(stats)!: add endpoint gating to client-side stats [APMSP-3361]
(#2040)

## libdd-dogstatsd-client
**Next version:** `4.0.0`
**Semver bump:** `major`
**Tag:** `libdd-dogstatsd-client-v4.0.0`

### ⚠️ major bump forced due to:

- `libdd-common`: ^4.1.0 → ^5.1.0


## libdd-sampling
**Next version:** `5.0.0`
**Semver bump:** `major`
**Tag:** `libdd-sampling-v5.0.0`

### ⚠️ major bump forced due to:

- `libdd-common`: ^4.2.0 → ^5.1.0
- `libdd-trace-utils`: ^8.0.0 → ^9.0.0


[APMSP-3371]:
https://datadoghq.atlassian.net/browse/APMSP-3371?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: iunanua <[email protected]>
taegyunkim pushed a commit that referenced this pull request Jul 8, 2026
# What ?

Split `SharedRuntime` into a trait with three implementations:

- `ForkSafeRuntime` *(native only)*: owns a multi-thread tokio runtime, supports fork
  hooks (`before_fork` / `after_fork_parent` / `after_fork_child`) and synchronous
  `shutdown`.
- `BasicRuntime` *(native only)*: wraps a library-built or caller-provided
  `Arc<tokio::runtime::Runtime>`, no fork hooks, no synchronous shutdown.
- `LocalRuntime` *(wasm32 only)*: single-threaded executor that spawns workers via
  `wasm_bindgen_futures::spawn_local`, no fork protocol, async-only.

`BlockingRuntime` *(native only)* is a sub-trait of `SharedRuntime` that adds
`block_on`; implemented by `ForkSafeRuntime` and `BasicRuntime`. Sync facades on the
trace exporter (`send` / `shutdown` / `build`) bound their runtime parameter on it.

`TraceExporter` is generic over the runtime — `TraceExporter<C, R: SharedRuntime>`
— so callers pick `ForkSafeRuntime`, `BasicRuntime`, or `LocalRuntime` explicitly. The
FFI pins `R = ForkSafeRuntime` for ABI stability.

# Why ?

Some callers already have a tokio runtime they want to reuse instead of letting
libdatadog create its own. The previous `SharedRuntime` only supported the
fork-safe owned case. Splitting into distinct types makes the lifecycle and
fork-safety contract explicit and lets callers pick the model that matches their
environment.

The wasm32 target previously shared a file with the native implementation behind
`#[cfg]` walls; it is now a dedicated module with a clean separation.

# How ?

- Introduce a `SharedRuntime` trait (`new`, `spawn_worker`, `shutdown_async`).
- Add a native-only `BlockingRuntime: SharedRuntime` sub-trait with `block_on`.
- Move the existing owned-runtime logic into `ForkSafeRuntime`; fork hooks and sync
  `shutdown` are inherent methods (not part of the trait).
- Add `BasicRuntime::with_worker_threads` (library-built) and
  `BasicRuntime::from_handle(Arc<Runtime>)` (caller-provided).
- Extract the wasm32 `spawn_local` path from `fork_safe.rs` into its own
  `local.rs` module as `LocalRuntime`.
- Make `TraceExporter<C, R>` and `TraceExporterBuilder<R>` generic over the runtime;
  sync entry points additionally require `R: BlockingRuntime`. `Default` for the
  builder is impl'd only for `R = ForkSafeRuntime` on native so
  `TraceExporterBuilder::default()` resolves unambiguously.
- `restart_on_fork = true` is silently ignored (with a `warn!`) on `BasicRuntime`
  and `LocalRuntime` since they do not implement a fork protocol.
- Update FFI to pin `R = ForkSafeRuntime` in its `TraceExporter` type alias.

# Additional Notes

- Breaking change for Rust callers of `libdd_shared_runtime`: `SharedRuntime` is
  now a trait; use `ForkSafeRuntime::with_worker_threads(1)` (or the trait method
  `SharedRuntime::new()` with the trait in scope) instead of `SharedRuntime::new()`.
- FFI handle type changes from `SharedRuntime` to `ForkSafeRuntime`.

Co-authored-by: jules.wiriath <[email protected]>
Signed-off-by: Taegyun Kim <[email protected]>
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.

6 participants