Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
0e6fc77
feat(worker): Add trigger to worker trait
VianneyRuhlmann Feb 11, 2026
305b853
feat(data_pipeline): add SharedRuntime
VianneyRuhlmann Feb 11, 2026
66e9e06
feat(worker): add initial trigger
VianneyRuhlmann Feb 13, 2026
b672262
feat(agent_info): use initial trigger
VianneyRuhlmann Feb 13, 2026
23022a6
feat(stats): implement stats worker
VianneyRuhlmann Feb 13, 2026
6c9c7f3
fix(shared_runtime): fix compile error
VianneyRuhlmann Feb 13, 2026
acc69ae
data-pipeline: pause all workers before joining in before_fork
VianneyRuhlmann Feb 13, 2026
17a9bb8
feat(exporter): use shared runtime in trace exporter
VianneyRuhlmann Feb 16, 2026
238a430
feat(shared_runtime): add worker handle
VianneyRuhlmann Feb 18, 2026
592c24c
refactor(worker): remove stopped status
VianneyRuhlmann Feb 18, 2026
ff6448c
chore(telemetry): move telemetry shutdown to worker
VianneyRuhlmann Feb 20, 2026
0dbce86
chore(shared-runtime): update error types
VianneyRuhlmann Feb 23, 2026
58bff21
chore(shared-runtime): return detailed errors in before_fork
VianneyRuhlmann Feb 26, 2026
16ab63b
chore(runtime): doc
VianneyRuhlmann Feb 27, 2026
3625c0a
test(telemetry): use shared runtime in tests
VianneyRuhlmann Mar 2, 2026
f86890a
test(telemetry): use client builder
VianneyRuhlmann Mar 2, 2026
3d285ae
chore(runtime): fix nit
VianneyRuhlmann Mar 4, 2026
1f8c0cf
refactor(runtime): move shutdown to runtime
VianneyRuhlmann Mar 5, 2026
62a63d6
test(telemetry): Add sleep after send
VianneyRuhlmann Mar 5, 2026
c1270f1
test(telemetry): fix deadlocks in telemetry tests
VianneyRuhlmann Mar 6, 2026
608556e
refactor(runtime): skip shutdown when runtime is None
VianneyRuhlmann Mar 9, 2026
34ec7d9
feat(runtime): add runtime to builder
VianneyRuhlmann Mar 9, 2026
a02eec6
chore(telemetry): remove macro
VianneyRuhlmann Mar 9, 2026
de8bce5
Merge branch 'main' into vianney/implement-shared-runtime
VianneyRuhlmann Mar 9, 2026
3119d5f
docs(runtime): add warnings
VianneyRuhlmann Mar 9, 2026
74425ba
feat(shared_runtime): add shared runtime ffi
VianneyRuhlmann Mar 10, 2026
2869d39
feat(trace_exporter): add shutdown method
VianneyRuhlmann Mar 10, 2026
4b1d0b6
fix(shared_runtime): add on_pause hook to release waker in info fetcher
VianneyRuhlmann Mar 10, 2026
0e74cad
fix(telemetry): add reset hook to telemetry
VianneyRuhlmann Mar 10, 2026
544b840
fix(telemetry): fix spawn and run loop for telemetry
VianneyRuhlmann Mar 10, 2026
a3e2c38
docs(info_fetcher): update doc for running the fetcher
VianneyRuhlmann Mar 10, 2026
67fcf2a
feat(runtime-ffi): remove redundant allocation of Box
VianneyRuhlmann Mar 11, 2026
018028f
Merge branch 'main' into vianney/implement-shared-runtime
VianneyRuhlmann Mar 11, 2026
6420f28
format
VianneyRuhlmann Mar 11, 2026
72f61f6
feat(runtime-ffi): use new handle in trace exporter builder
VianneyRuhlmann Mar 11, 2026
7bac719
chore: catch panics on ffi
VianneyRuhlmann Mar 13, 2026
fc1c81b
feat(telemetry): add check for existing action
VianneyRuhlmann Mar 16, 2026
57de7d4
refactor: move shared runtime to a separate crate
VianneyRuhlmann Mar 20, 2026
fb187ce
chore: apply suggestions
VianneyRuhlmann Mar 23, 2026
0f91bb3
chore(codeowners): add libdd-shared-runtime to codeowners
VianneyRuhlmann Mar 23, 2026
f12131f
docs(shared-runtime-ffi): add comment to error msg
VianneyRuhlmann Mar 23, 2026
1943f13
test: use thread::sleep instead of tokio
VianneyRuhlmann Mar 23, 2026
f1c8ea9
chore: rename join to wait_for_pause
VianneyRuhlmann Mar 23, 2026
16c20b6
docs: update after_fork_child doc
VianneyRuhlmann Mar 23, 2026
366dff5
refactor(shared-runtime): move shared runtime to a module
VianneyRuhlmann Mar 24, 2026
0a2cac4
chore: add debug logs
VianneyRuhlmann Mar 24, 2026
040ccdd
feat(shared_runtime): add block_on method to runtime
VianneyRuhlmann Mar 26, 2026
92e5ddc
chore: undo catch panic change
VianneyRuhlmann Mar 26, 2026
64b9bd2
chore: remove async trait from ddcommon
VianneyRuhlmann Mar 26, 2026
37b8105
refactor: use option to handle null pointer
VianneyRuhlmann Mar 26, 2026
febf920
docs: add comment to telemetry unused action
VianneyRuhlmann Mar 26, 2026
fc45ce9
feat: use futures unordered instead of JoinSet
VianneyRuhlmann Mar 26, 2026
c0c7b2e
fix(telemetry): clear items in telemetry store
VianneyRuhlmann Mar 27, 2026
ec6fbec
feat: use biased select to reduce time-to-pause
VianneyRuhlmann Mar 27, 2026
a523c1d
chore(shared-runtime): address mutex lock order concerns
VianneyRuhlmann Mar 27, 2026
21402c2
style: clippy and fmt
VianneyRuhlmann Mar 27, 2026
f6d69c1
chore: update 3rd party
VianneyRuhlmann Mar 27, 2026
8fdbd73
Merge branch 'main' into vianney/implement-shared-runtime
VianneyRuhlmann Mar 27, 2026
35d34c0
chore: fix conflicts
VianneyRuhlmann Mar 30, 2026
b1b5f9b
chore: remove legacy test
VianneyRuhlmann Mar 30, 2026
15c9352
Merge branch 'main' into vianney/implement-shared-runtime
VianneyRuhlmann Mar 30, 2026
da9ce1e
chore: bump libdd-common version
VianneyRuhlmann Mar 30, 2026
b9fe72e
chore: set shared runtime version
VianneyRuhlmann Mar 30, 2026
264d956
chore: update 3rd party license files
VianneyRuhlmann Mar 30, 2026
41bff26
test: update test to shared runtime
VianneyRuhlmann Mar 30, 2026
a0047b4
feat!: bump libdd-data-pipeline to major version
VianneyRuhlmann Mar 31, 2026
40dc0ad
Merge branch 'main' into vianney/implement-shared-runtime
VianneyRuhlmann Apr 1, 2026
39d0920
feat(trace-exporter): remove exporter block on method
VianneyRuhlmann Apr 2, 2026
b6a2b95
doc(shared-runtime): Add warnings to doc
VianneyRuhlmann Apr 2, 2026
a0932f8
fix(shared-runtime): fix race-condition between spawn_worker and
VianneyRuhlmann Apr 2, 2026
27801f1
chore: fix formating
VianneyRuhlmann Apr 2, 2026
9807d94
chore: use MaybeSend
VianneyRuhlmann Apr 2, 2026
75ad0d6
Merge branch 'main' into vianney/implement-shared-runtime
VianneyRuhlmann Apr 2, 2026
a0ec79c
chore(shared-runtime): fix build on wasm-32
VianneyRuhlmann Apr 3, 2026
8ee44b6
chore(data-pipeline): revert version bump
VianneyRuhlmann Apr 3, 2026
0aa1cf9
docs(telemetry): fix reset docs
VianneyRuhlmann Apr 3, 2026
a14fb04
docs(trace-exporter): add warning for send_async
VianneyRuhlmann Apr 3, 2026
1e124a1
fix(info-fetcher): skip drain if the channel is not empty
VianneyRuhlmann Apr 3, 2026
3ddce4a
fix(shared-runtime-ffi): use Option to handle null poniters
VianneyRuhlmann Apr 7, 2026
fd1903f
test(shared-runtime): improve tests
VianneyRuhlmann Apr 7, 2026
664a8be
test(shared-runtime-ffi): add transmute annotations
VianneyRuhlmann Apr 7, 2026
ec1ccf4
test(info_fetcher): remove needless assert
VianneyRuhlmann Apr 7, 2026
a171916
test(telemetry): increase sleep time
VianneyRuhlmann Apr 7, 2026
ad747d4
test(telemetry): increase sleep
VianneyRuhlmann Apr 8, 2026
d4916fc
test(telemetry): spawn worker outside of the block_on
VianneyRuhlmann Apr 8, 2026
22687bb
test(telemetry): use poll_for_mock_hits
VianneyRuhlmann Apr 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ libdd-library-config*/ @DataDog/apm-sdk-capabilities-rust
libdd-libunwind*/ @DataDog/libdatadog-profiling
libdd-log*/ @DataDog/apm-common-components-core
libdd-profiling*/ @DataDog/libdatadog-profiling
libdd-shared-runtime*/ @DataDog/apm-common-components-core
libdd-telemetry*/ @DataDog/apm-common-components-core
libdd-tinybytes @DataDog/apm-common-components-core
libdd-trace-normalization @DataDog/serverless @DataDog/libdatadog-apm
Expand Down
27 changes: 27 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ members = [
"spawn_worker",
"tests/spawn_from_lib",
"bin_tests",
"libdd-shared-runtime",
"libdd-shared-runtime-ffi",
"libdd-data-pipeline",
"libdd-data-pipeline-ffi",
"libdd-ddsketch",
Expand Down
1 change: 0 additions & 1 deletion libdd-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ pub mod threading;
#[cfg(not(target_arch = "wasm32"))]
pub mod timeout;
pub mod unix_utils;
pub mod worker;

/// Extension trait for `Mutex` to provide a method that acquires a lock, panicking if the lock is
/// poisoned.
Expand Down
1 change: 1 addition & 0 deletions libdd-data-pipeline-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ libdd-trace-utils = { path = "../libdd-trace-utils" }
[dependencies]
libdd-capabilities-impl = { version = "0.1.0", path = "../libdd-capabilities-impl" }
libdd-data-pipeline = { path = "../libdd-data-pipeline" }
libdd-shared-runtime = { version = "1.0.0", path = "../libdd-shared-runtime" }
libdd-common-ffi = { path = "../libdd-common-ffi", default-features = false }
libdd-tinybytes = { path = "../libdd-tinybytes" }
tracing = { version = "0.1", default-features = false }
2 changes: 1 addition & 1 deletion libdd-data-pipeline-ffi/cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ must_use = "DDOG_CHECK_RETURN"

[parse]
parse_deps = true
include = ["libdd-common", "libdd-common-ffi", "libdd-data-pipeline"]
include = ["libdd-common", "libdd-common-ffi", "libdd-shared-runtime", "libdd-data-pipeline"]
39 changes: 37 additions & 2 deletions libdd-data-pipeline-ffi/src/trace_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ use libdd_common_ffi::{
CharSlice,
{slice::AsBytes, slice::ByteSlice},
};

use libdd_data_pipeline::trace_exporter::{
TelemetryConfig, TraceExporter as GenericTraceExporter, TraceExporterInputFormat,
TraceExporterOutputFormat,
};

type TraceExporter = GenericTraceExporter<NativeCapabilities>;

use std::{ptr::NonNull, time::Duration};
use libdd_shared_runtime::SharedRuntime;
use std::{ptr::NonNull, sync::Arc, time::Duration};
use tracing::debug;

#[inline]
Expand Down Expand Up @@ -73,6 +73,7 @@ pub struct TraceExporterConfig {
process_tags: Option<String>,
test_session_token: Option<String>,
connection_timeout: Option<u64>,
shared_runtime: Option<Arc<SharedRuntime>>,
otlp_endpoint: Option<String>,
}

Expand Down Expand Up @@ -420,6 +421,36 @@ pub unsafe extern "C" fn ddog_trace_exporter_config_set_connection_timeout(
)
}

/// Sets a shared runtime for the TraceExporter to use for background workers.
///
/// `handle` must have been initialized with [`ddog_shared_runtime_new`].
///
/// When set, the exporter will use the provided runtime instead of creating its own.
/// This allows multiple exporters (or other components) to share a single runtime.
/// The config holds a clone of the `Arc` (increments the strong count), so the
/// original handle remains valid and must still be freed with
/// [`ddog_shared_runtime_free`].
#[no_mangle]
pub unsafe extern "C" fn ddog_trace_exporter_config_set_shared_runtime(
config: Option<&mut TraceExporterConfig>,
handle: Option<NonNull<SharedRuntime>>,
) -> Option<Box<ExporterError>> {
catch_panic!(
match (config, handle) {
(Some(config), Some(handle)) => {
// SAFETY: handle was produced by Arc::into_raw and the Arc is still alive.
// Increment the strong count before reconstructing so the config's Arc
// is independent from the caller's handle.
Arc::increment_strong_count(handle.as_ptr());
config.shared_runtime = Some(Arc::from_raw(handle.as_ptr()));
None
}
_ => gen_error!(ErrorCode::InvalidArgument),
},
gen_error!(ErrorCode::Panic)
)
}

/// Enables OTLP HTTP/JSON export and sets the endpoint URL.
///
/// When set, traces are sent to this URL in OTLP HTTP/JSON format instead of the Datadog
Expand Down Expand Up @@ -502,6 +533,10 @@ pub unsafe extern "C" fn ddog_trace_exporter_new(
builder.enable_health_metrics();
}

if let Some(runtime) = config.shared_runtime.clone() {
builder.set_shared_runtime(runtime);
}

if let Some(ref url) = config.otlp_endpoint {
builder.set_otlp_endpoint(url);
}
Expand Down
4 changes: 3 additions & 1 deletion libdd-data-pipeline/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ autobenches = false
[dependencies]
anyhow = { version = "1.0" }
arc-swap = "1.7.1"
async-trait = "0.1"
http = "1"
http-body-util = "0.1"
tracing = { version = "0.1", default-features = false }
Expand All @@ -30,7 +31,8 @@ uuid = { version = "1.10.0", features = ["v4"] }
tokio-util = "0.7.11"
libdd-capabilities = { path = "../libdd-capabilities", version = "0.1.0" }
libdd-common = { version = "3.0.2", path = "../libdd-common", default-features = false }
libdd-telemetry = { version = "4.0.0", path = "../libdd-telemetry", default-features = false, optional = true }
libdd-shared-runtime = { version = "1.0.0", path = "../libdd-shared-runtime" }
libdd-telemetry = { version = "4.0.0", path = "../libdd-telemetry", default-features = false, optional = true}
libdd-trace-protobuf = { version = "3.0.1", path = "../libdd-trace-protobuf" }
libdd-trace-stats = { version = "2.0.0", path = "../libdd-trace-stats" }
libdd-trace-utils = { version = "3.0.1", path = "../libdd-trace-utils", default-features = false }
Expand Down
9 changes: 7 additions & 2 deletions libdd-data-pipeline/examples/send-traces-with-stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ use libdd_data_pipeline::trace_exporter::{
use libdd_log::logger::{
logger_configure_std, logger_set_log_level, LogEventLevel, StdConfig, StdTarget,
};
use libdd_shared_runtime::SharedRuntime;
use libdd_trace_protobuf::pb;
use std::{
collections::HashMap,
sync::Arc,
time::{Duration, UNIX_EPOCH},
};

Expand Down Expand Up @@ -54,6 +56,8 @@ fn main() {
.expect("Failed to configure logger");
logger_set_log_level(LogEventLevel::Debug).expect("Failed to set log level");

let shared_runtime = Arc::new(SharedRuntime::new().expect("Failed to create runtime"));

let args = Args::parse();
let telemetry_cfg = TelemetryConfig::default();
let mut builder = TraceExporter::<NativeCapabilities>::builder();
Expand All @@ -68,6 +72,7 @@ fn main() {
.set_language_version(env!("CARGO_PKG_RUST_VERSION"))
.set_input_format(TraceExporterInputFormat::V04)
.set_output_format(TraceExporterOutputFormat::V04)
.set_shared_runtime(shared_runtime.clone())
.enable_telemetry(telemetry_cfg)
.enable_stats(Duration::from_secs(10));
let exporter = builder
Expand All @@ -89,7 +94,7 @@ fn main() {
let data = rmp_serde::to_vec_named(&traces).expect("Failed to serialize traces");

exporter.send(data.as_ref()).expect("Failed to send traces");
exporter
shared_runtime
.shutdown(None)
.expect("Failed to shutdown exporter");
.expect("Failed to shutdown runtime");
}
Loading
Loading