From db02c28bb0d9b916252e63eb2786c95a988ae0de Mon Sep 17 00:00:00 2001 From: Munir Date: Thu, 30 Apr 2026 01:05:48 -0400 Subject: [PATCH 1/6] feat: track process lineage for telemetry --- .cargo/config.toml | 2 + Cargo.lock | 292 ++++++++++++++++-- Cargo.toml | 24 +- datadog-opentelemetry/Cargo.toml | 5 +- .../src/core/configuration/configuration.rs | 2 + datadog-opentelemetry/src/core/mod.rs | 1 + datadog-opentelemetry/src/core/telemetry.rs | 5 + .../src/core/telemetry_session.rs | 209 +++++++++++++ datadog-opentelemetry/src/exporter/mod.rs | 18 +- datadog-opentelemetry/src/lib.rs | 5 + datadog-opentelemetry/src/span_exporter.rs | 9 +- 11 files changed, 531 insertions(+), 41 deletions(-) create mode 100644 .cargo/config.toml create mode 100644 datadog-opentelemetry/src/core/telemetry_session.rs diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..fe623106 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[registries.crates-io] +protocol = "git" diff --git a/Cargo.lock b/Cargo.lock index 82ee2973..5c5ad2ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -240,10 +240,11 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.32" +version = "1.2.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2352e5597e9c544d5e6d9c95190d5d27738ade584fa8db0a16e130e5c2b5296e" +checksum = "43c5703da9466b66a946814e1adf53ea2c90f10063b86290cc9eb67ce3478a20" dependencies = [ + "find-msvc-tools", "shlex", ] @@ -359,6 +360,16 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -476,6 +487,7 @@ dependencies = [ "hyper", "hyper-util", "libc", + "libdd-capabilities-impl", "libdd-common", "libdd-data-pipeline", "libdd-library-config", @@ -552,7 +564,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -576,6 +588,12 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + [[package]] name = "fnv" version = "1.0.7" @@ -715,8 +733,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi 0.11.1+wasi-snapshot-preview1", + "wasm-bindgen", ] [[package]] @@ -925,6 +945,23 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-rustls" +version = "0.27.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-native-certs", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + [[package]] name = "hyper-timeout" version = "0.5.2" @@ -1160,11 +1197,33 @@ version = "0.2.185" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52ff2c0fe9bc6cb6b14a0592c2ff4fa9ceb83eea9db979b0487cd054946a2b8f" +[[package]] +name = "libdd-capabilities" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +dependencies = [ + "anyhow", + "bytes", + "http", + "thiserror 1.0.69", +] + +[[package]] +name = "libdd-capabilities-impl" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +dependencies = [ + "bytes", + "http", + "http-body-util", + "libdd-capabilities", + "libdd-common", +] + [[package]] name = "libdd-common" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c779949577250487179d904508f18750070e9a01eb58dce378409ec5fa066f3b" +version = "4.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ "anyhow", "bytes", @@ -1178,15 +1237,19 @@ dependencies = [ "http-body", "http-body-util", "hyper", + "hyper-rustls", "hyper-util", "libc", "nix", "pin-project", "regex", + "rustls", + "rustls-native-certs", "serde", "static_assertions", "thiserror 1.0.69", "tokio", + "tokio-rustls", "tower-service", "windows-sys 0.52.0", ] @@ -1194,18 +1257,21 @@ dependencies = [ [[package]] name = "libdd-data-pipeline" version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "358411451d99011f13c7628acee25dc144f2bbeade87acf10fa7d5ffce1053dc" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ "anyhow", "arc-swap", + "async-trait", "bytes", "either", + "getrandom 0.2.16", "http", "http-body-util", + "libdd-capabilities", + "libdd-capabilities-impl", "libdd-common", - "libdd-ddsketch", "libdd-dogstatsd-client", + "libdd-shared-runtime", "libdd-telemetry", "libdd-tinybytes", "libdd-trace-protobuf 3.0.1", @@ -1224,8 +1290,7 @@ dependencies = [ [[package]] name = "libdd-ddsketch" version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b31b2435e2e8eaba0e35a96df3e1407b68f8ef76055383ceb2ba5a09e5a1bb5" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ "prost", ] @@ -1233,8 +1298,7 @@ dependencies = [ [[package]] name = "libdd-dogstatsd-client" version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6f8eca39d1e2ef6267cf77fc51eb7ebc7d4f44827e150b4d317c29d8c33bf87" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ "anyhow", "cadence", @@ -1262,14 +1326,29 @@ dependencies = [ "serde_yaml", ] +[[package]] +name = "libdd-shared-runtime" +version = "0.1.0" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +dependencies = [ + "async-trait", + "futures", + "libdd-capabilities", + "libdd-common", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "libdd-telemetry" version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78774ffce79da677602829d7fe27468283e5349010e974257233edf4cd12b783" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ "anyhow", + "async-trait", "base64 0.22.1", + "bytes", "futures", "hashbrown 0.15.5", "http", @@ -1277,6 +1356,7 @@ dependencies = [ "libc", "libdd-common", "libdd-ddsketch", + "libdd-shared-runtime", "serde", "serde_json", "sys-info", @@ -1290,8 +1370,7 @@ dependencies = [ [[package]] name = "libdd-tinybytes" version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e47838e12ae2665250b4cdba4e3119230b79e3c522bb9f48dd0c87346f5a8f44" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ "serde", ] @@ -1299,8 +1378,7 @@ dependencies = [ [[package]] name = "libdd-trace-normalization" version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab12e095f3589d02ceed76556e7aa8a1b5bc928a900e143b624e2331294e54b5" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ "anyhow", "libdd-trace-protobuf 3.0.1", @@ -1320,8 +1398,7 @@ dependencies = [ [[package]] name = "libdd-trace-protobuf" version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1809242895edc53ac51a21287829f42474e749dbc222ea7f414cb3f0d1f91d4e" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ "prost", "serde", @@ -1331,32 +1408,46 @@ dependencies = [ [[package]] name = "libdd-trace-stats" version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d92b882863f7c531d51e73f7bc5930c705e47829332128d9bdcad0fea3b2b942" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ + "anyhow", + "async-trait", "hashbrown 0.15.5", + "http", + "libdd-capabilities", + "libdd-capabilities-impl", + "libdd-common", "libdd-ddsketch", + "libdd-shared-runtime", "libdd-trace-protobuf 3.0.1", "libdd-trace-utils", + "rmp-serde", + "serde", + "tokio", + "tokio-util", + "tracing", ] [[package]] name = "libdd-trace-utils" version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "870506e9bb79c93ce5bbfe9d715c53c7ea393a177c7299f0bf43745c0adea0c7" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ "anyhow", + "base64 0.22.1", "bytes", "cargo-platform", "cargo_metadata", "futures", + "getrandom 0.2.16", "http", "http-body", "http-body-util", "httpmock", "hyper", "indexmap", + "libdd-capabilities", + "libdd-capabilities-impl", "libdd-common", "libdd-tinybytes", "libdd-trace-normalization", @@ -1512,6 +1603,12 @@ version = "11.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" +[[package]] +name = "openssl-probe" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" + [[package]] name = "opentelemetry" version = "0.31.0" @@ -2025,6 +2122,20 @@ dependencies = [ "web-sys", ] +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.16", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "rmp" version = "0.8.14" @@ -2092,7 +2203,53 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.59.0", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c2c118cb077cca2822033836dfb1b975355dfb784b5e8da48f7b6c5db74e60e" +dependencies = [ + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9980d917ebb0c0536119ba501e90834767bffc3d60641457fd84a1f3fd337923" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pki-types" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", ] [[package]] @@ -2116,12 +2273,44 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schannel" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" +dependencies = [ + "windows-sys 0.61.2", +] + [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "security-framework" +version = "3.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d17b898a6d6948c3a8ee4372c17cb384f90d2e6e912ef00895b14fd7ab54ec38" +dependencies = [ + "bitflags", + "core-foundation 0.10.1", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "1.0.26" @@ -2307,6 +2496,12 @@ version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b3c8667cd96245cbb600b8dec5680a7319edd719c5aa2b5d23c6bff94f39765" +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "syn" version = "2.0.105" @@ -2355,7 +2550,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ "bitflags", - "core-foundation", + "core-foundation 0.9.4", "system-configuration-sys", ] @@ -2511,6 +2706,16 @@ dependencies = [ "syn", ] +[[package]] +name = "tokio-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.17" @@ -2744,6 +2949,12 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.5.4" @@ -2961,13 +3172,19 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + [[package]] name = "windows-registry" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b8a9ed28765efc97bbc954883f4e6796c33a06546ebafacbabee9696967499e" dependencies = [ - "windows-link", + "windows-link 0.1.3", "windows-result", "windows-strings", ] @@ -2978,7 +3195,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" dependencies = [ - "windows-link", + "windows-link 0.1.3", ] [[package]] @@ -2987,7 +3204,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" dependencies = [ - "windows-link", + "windows-link 0.1.3", ] [[package]] @@ -3008,6 +3225,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link 0.2.1", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -3223,6 +3449,12 @@ dependencies = [ "synstructure", ] +[[package]] +name = "zeroize" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" + [[package]] name = "zerotrie" version = "0.2.3" diff --git a/Cargo.toml b/Cargo.toml index c4c781d7..45cc6263 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,10 +23,14 @@ authors = ["Datadog Inc. "] [workspace.dependencies] # Libdatadog dependencies - change to a stable version once we release -libdd-data-pipeline = { version = "3.0.1", default-features = false } -libdd-trace-utils = { version = "3.0.0", default-features = false } +libdd-data-pipeline = { version = "3.0.1", default-features = false, features = [ + "https", + "telemetry", +] } +libdd-trace-utils = { version = "3.0.1", default-features = false } libdd-telemetry = { version = "4.0.0", default-features = false } -libdd-common = { version = "3.0.1", default-features = false } +libdd-common = { version = "4.0.0", default-features = false } +libdd-capabilities-impl = { version = "1.0.0", default-features = false, features = ["https"] } libdd-tinybytes = { version = "1.1.0", default-features = false } libdd-library-config = { version = "1.1.0", default-features = false } opentelemetry_sdk = { version = "0.31.0", features = [ @@ -55,7 +59,6 @@ serde_json = { version = "1.0.140" } hashbrown = { version = "0.15.5" } foldhash = { version = "0.1.5" } - [profile.dev] debug = 2 # full debug info @@ -65,3 +68,16 @@ debug = false incremental = false opt-level = 3 +# Libdatadog repo tag `v32.0.0` and the `libdd-data-pipeline` 3.0.1 crate on crates.io still sit on the +# `libdd-common` 3.x stack. Git `main` has since moved `libdd-data-pipeline` to `libdd-common` 4.0.0 and +# adds trace-exporter / telemetry session headers (e.g. merged #1822). Individual crates such as +# `libdd-common` 4.0.0 and `libdd-capabilities-impl` 1.0.0 are on crates.io, but you cannot combine them +# with the published `libdd-data-pipeline` 3.0.1 without a version skew. Patch this set from `main` until +# a `libdd-data-pipeline` release targets 4.x on the registry. +[patch.crates-io] +libdd-common = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } +libdd-data-pipeline = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } +libdd-telemetry = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } +libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } +libdd-tinybytes = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } +libdd-capabilities-impl = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } diff --git a/datadog-opentelemetry/Cargo.toml b/datadog-opentelemetry/Cargo.toml index f9c007bc..29dac4fc 100644 --- a/datadog-opentelemetry/Cargo.toml +++ b/datadog-opentelemetry/Cargo.toml @@ -60,14 +60,17 @@ criterion = { version = "0.5.1", optional = true } # Libdatadog dependencies libdd-data-pipeline = { workspace = true } +libdd-capabilities-impl = { workspace = true } libdd-trace-utils = { workspace = true } libdd-telemetry = { workspace = true } libdd-common = { workspace = true } libdd-tinybytes = { workspace = true } +[target.'cfg(unix)'.dependencies] +libc = "0.2" + [target.'cfg(target_os="linux")'.dependencies] libdd-library-config = { workspace = true } -libc = "0.2" [dev-dependencies] assert_unordered = "0.3" diff --git a/datadog-opentelemetry/src/core/configuration/configuration.rs b/datadog-opentelemetry/src/core/configuration/configuration.rs index 57ed6bbc..129f1307 100644 --- a/datadog-opentelemetry/src/core/configuration/configuration.rs +++ b/datadog-opentelemetry/src/core/configuration/configuration.rs @@ -1930,6 +1930,8 @@ impl ConfigBuilder { .set_calculated(Cow::Owned(format!("http://{host}:{port}"))); } + crate::core::telemetry_session::install_tracer_lineage_env(config.runtime_id); + config } diff --git a/datadog-opentelemetry/src/core/mod.rs b/datadog-opentelemetry/src/core/mod.rs index b38404f0..44e4669a 100644 --- a/datadog-opentelemetry/src/core/mod.rs +++ b/datadog-opentelemetry/src/core/mod.rs @@ -12,6 +12,7 @@ mod error; pub mod log; pub(crate) mod telemetry; +pub mod telemetry_session; pub(crate) mod utils; #[cfg(feature = "test-utils")] diff --git a/datadog-opentelemetry/src/core/telemetry.rs b/datadog-opentelemetry/src/core/telemetry.rs index 878d3d36..8440e828 100644 --- a/datadog-opentelemetry/src/core/telemetry.rs +++ b/datadog-opentelemetry/src/core/telemetry.rs @@ -16,6 +16,7 @@ use libdd_telemetry::{ }; use super::configuration::{Config, ConfigurationProvider}; +use super::telemetry_session; use crate::{dd_debug, dd_error, dd_warn}; static TELEMETRY: TelemetryCell = OnceLock::new(); @@ -250,6 +251,10 @@ fn make_telemetry_worker( builder.config = libdd_telemetry::config::Config::from_env(); builder.config.telemetry_heartbeat_interval = Duration::from_secs_f64(config.telemetry_heartbeat_interval()); + let inst = telemetry_session::InstrumentationSessions::from_runtime_id(config.runtime_id()); + builder.config.session_id = inst.session_id; + builder.config.root_session_id = inst.root_session_id; + builder.config.parent_session_id = inst.parent_session_id; // builder.config.debug_enabled = true; builder.run().map(|handle| { diff --git a/datadog-opentelemetry/src/core/telemetry_session.rs b/datadog-opentelemetry/src/core/telemetry_session.rs new file mode 100644 index 00000000..00d020f6 --- /dev/null +++ b/datadog-opentelemetry/src/core/telemetry_session.rs @@ -0,0 +1,209 @@ +// Copyright 2025-Present Datadog, Inc. https://www.datadoghq.com/ +// SPDX-License-Identifier: Apache-2.0 + +//! Telemetry session ids for instrumentation (`dd-session-id` and related headers). +//! +//! Lineage is carried in the environment: +//! - [`ENV_ROOT_RS_SESSION_ID`]: root of the process tree for this tracer run. +//! - [`ENV_PARENT_RS_SESSION_ID`]: parent process’s tracer runtime id. +//! +//! [`install_process_lineage_env`] and [`install_tracer_lineage_env`] publish these into the +//! **current** process so plain `fork()` inherits them. For `exec` / [`std::process::Command`], use +//! [`lineage_env_for_spawn`] or [`extend_command_env_with_lineage`]. + +use std::sync::{Once, RwLock}; + +use libdd_data_pipeline::trace_exporter::TelemetryInstrumentationSessions; + +/// Environment variable: root session id for instrumentation lineage (`dd-session-id` family). +pub const ENV_ROOT_RS_SESSION_ID: &str = "_DD_ROOT_RS_SESSION_ID"; +/// Environment variable: parent process session id for instrumentation lineage. +pub const ENV_PARENT_RS_SESSION_ID: &str = "_DD_PARENT_RS_SESSION_ID"; + +static TRACER_RUNTIME_FOR_FORK: RwLock> = RwLock::new(None); +static REGISTER_PTHREAD_ATFORK: Once = Once::new(); + +/// Session ids for instrumentation telemetry HTTP headers (`dd-session-id`, etc.). +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct InstrumentationSessions { + /// Current process session id (typically the tracer runtime id). + pub session_id: Option, + /// Root process session id when distinct from `session_id`. + pub root_session_id: Option, + /// Parent process session id when distinct from `session_id`. + pub parent_session_id: Option, +} + +impl InstrumentationSessions { + /// Builds session ids from `runtime_id` and optional [`ENV_ROOT_RS_SESSION_ID`] / [`ENV_PARENT_RS_SESSION_ID`]. + #[allow(clippy::disallowed_methods)] + pub fn from_runtime_id(runtime_id: &str) -> Self { + let session_id = runtime_id.to_owned(); + let root_session_id = std::env::var(ENV_ROOT_RS_SESSION_ID) + .ok() + .filter(|r| r != &session_id); + let parent_session_id = std::env::var(ENV_PARENT_RS_SESSION_ID) + .ok() + .filter(|p| p != &session_id); + Self { + session_id: Some(session_id), + root_session_id, + parent_session_id, + } + } +} + +impl From for TelemetryInstrumentationSessions { + fn from(s: InstrumentationSessions) -> Self { + Self { + session_id: s.session_id, + root_session_id: s.root_session_id, + parent_session_id: s.parent_session_id, + } + } +} + +/// Sets [`ENV_ROOT_RS_SESSION_ID`] when unset so children inherit the lineage root (fork or `exec` of this process without clearing env). +/// +/// Does not overwrite an existing root (e.g. set by a parent process). +#[allow(clippy::disallowed_methods)] +pub fn install_process_lineage_env(runtime_id: &str) { + if std::env::var_os(ENV_ROOT_RS_SESSION_ID).is_none() { + std::env::set_var(ENV_ROOT_RS_SESSION_ID, runtime_id); + } +} + +/// Records the tracer `runtime_id` used for [`pthread_atfork`] handling and calls [`install_process_lineage_env`]. +/// +/// Call once the effective tracer runtime id for **this** process is known (typically via [`crate::configuration::Config::build`]). +/// Safe to call again after fork once the child’s tracer `runtime_id` is known (e.g. a new per-process id). +pub fn install_tracer_lineage_env(runtime_id: &'static str) { + install_process_lineage_env(runtime_id); + if let Ok(mut guard) = TRACER_RUNTIME_FOR_FORK.write() { + *guard = Some(runtime_id); + } + #[cfg(unix)] + register_fork_hooks(); +} + +/// Pairs to pass to [`std::process::Command::env`](std::process::Command::env) so a child process keeps root lineage and records this process as parent. +#[allow(clippy::disallowed_methods)] +pub fn lineage_env_for_spawn(runtime_id: &str) -> [(&'static str, String); 2] { + let root = std::env::var(ENV_ROOT_RS_SESSION_ID).unwrap_or_else(|_| runtime_id.to_string()); + [ + (ENV_ROOT_RS_SESSION_ID, root), + (ENV_PARENT_RS_SESSION_ID, runtime_id.to_string()), + ] +} + +/// Merges [`lineage_env_for_spawn`] into an existing [`Command`](std::process::Command). +pub fn extend_command_env_with_lineage(cmd: &mut std::process::Command, runtime_id: &str) { + for (key, val) in lineage_env_for_spawn(runtime_id) { + cmd.env(key, val); + } +} + +#[cfg(unix)] +fn fork_tracer_runtime_snapshot() -> Option { + TRACER_RUNTIME_FOR_FORK + .read() + .ok() + .and_then(|guard| guard.as_ref().map(|s| (*s).to_string())) +} + +#[cfg(unix)] +thread_local! { + static FORK_PARENT_RUNTIME_SNAPSHOT: std::cell::RefCell> = + const { std::cell::RefCell::new(None) }; +} + +#[cfg(unix)] +fn register_fork_hooks() { + REGISTER_PTHREAD_ATFORK.call_once(|| unsafe { + let status = libc::pthread_atfork( + Some(fork_prepare), + Some(fork_parent_after), + Some(fork_child_after), + ); + debug_assert_eq!(status, 0, "pthread_atfork: {status}"); + }); +} + +#[cfg(unix)] +unsafe extern "C" fn fork_prepare() { + if let Some(rid) = fork_tracer_runtime_snapshot() { + FORK_PARENT_RUNTIME_SNAPSHOT.with(|cell| { + *cell.borrow_mut() = Some(rid); + }); + } +} + +#[cfg(unix)] +unsafe extern "C" fn fork_parent_after() { + FORK_PARENT_RUNTIME_SNAPSHOT.with(|cell| { + *cell.borrow_mut() = None; + }); +} + +#[cfg(unix)] +unsafe extern "C" fn fork_child_after() { + FORK_PARENT_RUNTIME_SNAPSHOT.with(|cell| { + if let Some(parent_rid) = cell.borrow_mut().take() { + #[allow(clippy::disallowed_methods)] + std::env::set_var(ENV_PARENT_RS_SESSION_ID, parent_rid); + } + }); +} + +#[cfg(test)] +mod tests { + use super::*; + + use std::sync::{Mutex, OnceLock}; + + fn env_mutation_lock() -> std::sync::MutexGuard<'static, ()> { + static LOCK: OnceLock> = OnceLock::new(); + LOCK.get_or_init(|| Mutex::new(())).lock().unwrap() + } + + #[test] + fn from_runtime_id_omits_root_parent_when_missing_env() { + let _l = env_mutation_lock(); + let root_before = std::env::var_os(ENV_ROOT_RS_SESSION_ID); + let parent_before = std::env::var_os(ENV_PARENT_RS_SESSION_ID); + std::env::remove_var(ENV_ROOT_RS_SESSION_ID); + std::env::remove_var(ENV_PARENT_RS_SESSION_ID); + let s = InstrumentationSessions::from_runtime_id("rid-a"); + assert_eq!(s.session_id.as_deref(), Some("rid-a")); + assert!(s.root_session_id.is_none()); + assert!(s.parent_session_id.is_none()); + restore_env_opt(ENV_ROOT_RS_SESSION_ID, root_before); + restore_env_opt(ENV_PARENT_RS_SESSION_ID, parent_before); + } + + #[test] + fn lineage_env_parent_is_current_runtime_id() { + let env = lineage_env_for_spawn("run-1"); + assert_eq!(env[1].0, ENV_PARENT_RS_SESSION_ID); + assert_eq!(env[1].1, "run-1"); + } + + #[test] + fn install_process_lineage_env_sets_root_when_missing() { + let _l = env_mutation_lock(); + let before = std::env::var_os(ENV_ROOT_RS_SESSION_ID); + std::env::remove_var(ENV_ROOT_RS_SESSION_ID); + install_process_lineage_env("root-a"); + assert_eq!(std::env::var(ENV_ROOT_RS_SESSION_ID).unwrap(), "root-a"); + install_process_lineage_env("root-b"); + assert_eq!(std::env::var(ENV_ROOT_RS_SESSION_ID).unwrap(), "root-a"); + restore_env_opt(ENV_ROOT_RS_SESSION_ID, before); + } + + fn restore_env_opt(key: &str, before: Option) { + match before { + None => std::env::remove_var(key), + Some(v) => std::env::set_var(key, v), + } + } +} diff --git a/datadog-opentelemetry/src/exporter/mod.rs b/datadog-opentelemetry/src/exporter/mod.rs index 1f8dd3e8..899709ee 100644 --- a/datadog-opentelemetry/src/exporter/mod.rs +++ b/datadog-opentelemetry/src/exporter/mod.rs @@ -9,12 +9,16 @@ use std::{ }; use crate::{dd_debug, dd_error}; +use libdd_capabilities_impl::NativeCapabilities; use libdd_data_pipeline::trace_exporter::{ agent_response::AgentResponse, error::{self as trace_exporter_error, TraceExporterError}, - TraceExporter, TraceExporterBuilder, + TraceExporter as LibddTraceExporter, + TraceExporterBuilder, }; +pub type TraceExporter = LibddTraceExporter; + #[derive(Clone, Copy)] pub struct AsyncExporterConfig { /// Whether the async exporter waits for the trace chunks to be exported before returning from @@ -583,7 +587,7 @@ impl TraceExporterWorker { ) -> TraceExporterHandle { let handle = thread::spawn({ move || { - let trace_exporter = match builder.build() { + let trace_exporter = match builder.build::() { Ok(exporter) => exporter, Err(e) => { return Err(e); @@ -609,8 +613,14 @@ impl TraceExporterWorker { { // Wait for the agent info to be fetched to get deterministic output when deciding // to drop traces or not - self.trace_exporter - .wait_agent_info_ready(Duration::from_secs(5)) + tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .expect("tokio runtime for wait_agent_info_ready") + .block_on( + self.trace_exporter + .wait_agent_info_ready(Duration::from_secs(5)), + ) .unwrap(); } while let Ok((message, data)) = self.rx.receive(self.config.max_flush_interval) { diff --git a/datadog-opentelemetry/src/lib.rs b/datadog-opentelemetry/src/lib.rs index 380a821c..ebe61b79 100644 --- a/datadog-opentelemetry/src/lib.rs +++ b/datadog-opentelemetry/src/lib.rs @@ -245,6 +245,11 @@ pub(crate) mod core; // Public re-exports pub use core::configuration; pub use core::log; +pub use core::telemetry_session::{ + extend_command_env_with_lineage, install_process_lineage_env, install_tracer_lineage_env, + lineage_env_for_spawn, InstrumentationSessions, ENV_PARENT_RS_SESSION_ID, + ENV_ROOT_RS_SESSION_ID, +}; #[cfg(feature = "test-utils")] #[allow(missing_docs)] diff --git a/datadog-opentelemetry/src/span_exporter.rs b/datadog-opentelemetry/src/span_exporter.rs index dbacfdad..02ce9ad6 100644 --- a/datadog-opentelemetry/src/span_exporter.rs +++ b/datadog-opentelemetry/src/span_exporter.rs @@ -5,15 +5,17 @@ use std::{sync::Arc, time::Duration}; use arc_swap::ArcSwap; use libdd_data_pipeline::trace_exporter::{ - agent_response::AgentResponse, error::TraceExporterError, TelemetryConfig, TraceExporter, + agent_response::AgentResponse, error::TraceExporterError, TelemetryConfig, TraceExporterOutputFormat, }; + use opentelemetry_sdk::{trace::SpanData, Resource}; use crate::{ configuration::Config, + core::telemetry_session::InstrumentationSessions, ddtrace_transform, - exporter::{AsyncExporterError, AsyncTraceExporter, Exporter, TraceChunk}, + exporter::{AsyncExporterError, AsyncTraceExporter, Exporter, TraceChunk, TraceExporter}, mappings::CachedConfig, }; @@ -61,6 +63,9 @@ impl DatadogExporter { runtime_id: Some(config.runtime_id().to_string()), debug_enabled: false, }); + builder.set_telemetry_instrumentation_sessions( + InstrumentationSessions::from_runtime_id(config.runtime_id()).into(), + ); } DatadogExporter { exporter: AsyncTraceExporter::new( From 323eca76d5bbff050f6af74ce7beb5c79d313d4e Mon Sep 17 00:00:00 2001 From: Munir Date: Thu, 30 Apr 2026 14:38:39 -0400 Subject: [PATCH 2/6] clean up the implementation and update forking logic --- datadog-opentelemetry/Cargo.toml | 4 +- .../src/core/telemetry_session.rs | 103 +------ datadog-opentelemetry/src/exporter/mod.rs | 3 +- instrumentation/Cargo.lock | 270 ++++++++++++++++-- instrumentation/Cargo.toml | 11 + 5 files changed, 276 insertions(+), 115 deletions(-) diff --git a/datadog-opentelemetry/Cargo.toml b/datadog-opentelemetry/Cargo.toml index 29dac4fc..e59c8fe3 100644 --- a/datadog-opentelemetry/Cargo.toml +++ b/datadog-opentelemetry/Cargo.toml @@ -66,11 +66,9 @@ libdd-telemetry = { workspace = true } libdd-common = { workspace = true } libdd-tinybytes = { workspace = true } -[target.'cfg(unix)'.dependencies] -libc = "0.2" - [target.'cfg(target_os="linux")'.dependencies] libdd-library-config = { workspace = true } +libc = "0.2" [dev-dependencies] assert_unordered = "0.3" diff --git a/datadog-opentelemetry/src/core/telemetry_session.rs b/datadog-opentelemetry/src/core/telemetry_session.rs index 00d020f6..fa36a713 100644 --- a/datadog-opentelemetry/src/core/telemetry_session.rs +++ b/datadog-opentelemetry/src/core/telemetry_session.rs @@ -1,41 +1,30 @@ // Copyright 2025-Present Datadog, Inc. https://www.datadoghq.com/ // SPDX-License-Identifier: Apache-2.0 -//! Telemetry session ids for instrumentation (`dd-session-id` and related headers). -//! -//! Lineage is carried in the environment: -//! - [`ENV_ROOT_RS_SESSION_ID`]: root of the process tree for this tracer run. -//! - [`ENV_PARENT_RS_SESSION_ID`]: parent process’s tracer runtime id. -//! -//! [`install_process_lineage_env`] and [`install_tracer_lineage_env`] publish these into the -//! **current** process so plain `fork()` inherits them. For `exec` / [`std::process::Command`], use -//! [`lineage_env_for_spawn`] or [`extend_command_env_with_lineage`]. - -use std::sync::{Once, RwLock}; +//! Instrumentation session ids from env (`dd-session-id` family). +//! Here `runtime_id` is unchanged across `fork()` (unlike some Datadog SDKs); set parent for a new +//! process with [`lineage_env_for_spawn`] or [`extend_command_env_with_lineage`]. use libdd_data_pipeline::trace_exporter::TelemetryInstrumentationSessions; -/// Environment variable: root session id for instrumentation lineage (`dd-session-id` family). +/// Root lineage env key. pub const ENV_ROOT_RS_SESSION_ID: &str = "_DD_ROOT_RS_SESSION_ID"; -/// Environment variable: parent process session id for instrumentation lineage. +/// Parent lineage env key. pub const ENV_PARENT_RS_SESSION_ID: &str = "_DD_PARENT_RS_SESSION_ID"; -static TRACER_RUNTIME_FOR_FORK: RwLock> = RwLock::new(None); -static REGISTER_PTHREAD_ATFORK: Once = Once::new(); - -/// Session ids for instrumentation telemetry HTTP headers (`dd-session-id`, etc.). +/// Session ids for libdd telemetry / trace instrumentation headers. #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct InstrumentationSessions { - /// Current process session id (typically the tracer runtime id). + /// Current session id. pub session_id: Option, - /// Root process session id when distinct from `session_id`. + /// Root session id when distinct from current. pub root_session_id: Option, - /// Parent process session id when distinct from `session_id`. + /// Parent session id when distinct from current. pub parent_session_id: Option, } impl InstrumentationSessions { - /// Builds session ids from `runtime_id` and optional [`ENV_ROOT_RS_SESSION_ID`] / [`ENV_PARENT_RS_SESSION_ID`]. + /// From `runtime_id` plus env keys when set and different from current. #[allow(clippy::disallowed_methods)] pub fn from_runtime_id(runtime_id: &str) -> Self { let session_id = runtime_id.to_owned(); @@ -63,9 +52,7 @@ impl From for TelemetryInstrumentationSessions { } } -/// Sets [`ENV_ROOT_RS_SESSION_ID`] when unset so children inherit the lineage root (fork or `exec` of this process without clearing env). -/// -/// Does not overwrite an existing root (e.g. set by a parent process). +/// Sets [`ENV_ROOT_RS_SESSION_ID`] if unset (does not replace an existing value). #[allow(clippy::disallowed_methods)] pub fn install_process_lineage_env(runtime_id: &str) { if std::env::var_os(ENV_ROOT_RS_SESSION_ID).is_none() { @@ -73,20 +60,12 @@ pub fn install_process_lineage_env(runtime_id: &str) { } } -/// Records the tracer `runtime_id` used for [`pthread_atfork`] handling and calls [`install_process_lineage_env`]. -/// -/// Call once the effective tracer runtime id for **this** process is known (typically via [`crate::configuration::Config::build`]). -/// Safe to call again after fork once the child’s tracer `runtime_id` is known (e.g. a new per-process id). -pub fn install_tracer_lineage_env(runtime_id: &'static str) { +/// Same as [`install_process_lineage_env`]; call when the tracer `runtime_id` is known. +pub fn install_tracer_lineage_env(runtime_id: &str) { install_process_lineage_env(runtime_id); - if let Ok(mut guard) = TRACER_RUNTIME_FOR_FORK.write() { - *guard = Some(runtime_id); - } - #[cfg(unix)] - register_fork_hooks(); } -/// Pairs to pass to [`std::process::Command::env`](std::process::Command::env) so a child process keeps root lineage and records this process as parent. +/// Env pairs for [`std::process::Command`] (root + parent = this `runtime_id`). #[allow(clippy::disallowed_methods)] pub fn lineage_env_for_spawn(runtime_id: &str) -> [(&'static str, String); 2] { let root = std::env::var(ENV_ROOT_RS_SESSION_ID).unwrap_or_else(|_| runtime_id.to_string()); @@ -96,65 +75,13 @@ pub fn lineage_env_for_spawn(runtime_id: &str) -> [(&'static str, String); 2] { ] } -/// Merges [`lineage_env_for_spawn`] into an existing [`Command`](std::process::Command). +/// Merges [`lineage_env_for_spawn`] into `cmd`. pub fn extend_command_env_with_lineage(cmd: &mut std::process::Command, runtime_id: &str) { for (key, val) in lineage_env_for_spawn(runtime_id) { cmd.env(key, val); } } -#[cfg(unix)] -fn fork_tracer_runtime_snapshot() -> Option { - TRACER_RUNTIME_FOR_FORK - .read() - .ok() - .and_then(|guard| guard.as_ref().map(|s| (*s).to_string())) -} - -#[cfg(unix)] -thread_local! { - static FORK_PARENT_RUNTIME_SNAPSHOT: std::cell::RefCell> = - const { std::cell::RefCell::new(None) }; -} - -#[cfg(unix)] -fn register_fork_hooks() { - REGISTER_PTHREAD_ATFORK.call_once(|| unsafe { - let status = libc::pthread_atfork( - Some(fork_prepare), - Some(fork_parent_after), - Some(fork_child_after), - ); - debug_assert_eq!(status, 0, "pthread_atfork: {status}"); - }); -} - -#[cfg(unix)] -unsafe extern "C" fn fork_prepare() { - if let Some(rid) = fork_tracer_runtime_snapshot() { - FORK_PARENT_RUNTIME_SNAPSHOT.with(|cell| { - *cell.borrow_mut() = Some(rid); - }); - } -} - -#[cfg(unix)] -unsafe extern "C" fn fork_parent_after() { - FORK_PARENT_RUNTIME_SNAPSHOT.with(|cell| { - *cell.borrow_mut() = None; - }); -} - -#[cfg(unix)] -unsafe extern "C" fn fork_child_after() { - FORK_PARENT_RUNTIME_SNAPSHOT.with(|cell| { - if let Some(parent_rid) = cell.borrow_mut().take() { - #[allow(clippy::disallowed_methods)] - std::env::set_var(ENV_PARENT_RS_SESSION_ID, parent_rid); - } - }); -} - #[cfg(test)] mod tests { use super::*; diff --git a/datadog-opentelemetry/src/exporter/mod.rs b/datadog-opentelemetry/src/exporter/mod.rs index 899709ee..4226aea0 100644 --- a/datadog-opentelemetry/src/exporter/mod.rs +++ b/datadog-opentelemetry/src/exporter/mod.rs @@ -13,8 +13,7 @@ use libdd_capabilities_impl::NativeCapabilities; use libdd_data_pipeline::trace_exporter::{ agent_response::AgentResponse, error::{self as trace_exporter_error, TraceExporterError}, - TraceExporter as LibddTraceExporter, - TraceExporterBuilder, + TraceExporter as LibddTraceExporter, TraceExporterBuilder, }; pub type TraceExporter = LibddTraceExporter; diff --git a/instrumentation/Cargo.lock b/instrumentation/Cargo.lock index c21728ff..9ecd01af 100644 --- a/instrumentation/Cargo.lock +++ b/instrumentation/Cargo.lock @@ -54,6 +54,17 @@ dependencies = [ "syn", ] +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "atomic-waker" version = "1.1.2" @@ -156,6 +167,22 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "cpufeatures" version = "0.2.17" @@ -219,6 +246,7 @@ dependencies = [ "hyper", "hyper-util", "libc", + "libdd-capabilities-impl", "libdd-common", "libdd-data-pipeline", "libdd-library-config", @@ -395,8 +423,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -533,6 +563,22 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-rustls" +version = "0.27.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ca68d021ef39cf6463ab54c1d0f5daf03377b70561305bb89a8f83aab66e0f" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-native-certs", + "tokio", + "tokio-rustls", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.20" @@ -663,11 +709,33 @@ version = "0.2.185" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52ff2c0fe9bc6cb6b14a0592c2ff4fa9ceb83eea9db979b0487cd054946a2b8f" +[[package]] +name = "libdd-capabilities" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +dependencies = [ + "anyhow", + "bytes", + "http", + "thiserror 1.0.69", +] + +[[package]] +name = "libdd-capabilities-impl" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +dependencies = [ + "bytes", + "http", + "http-body-util", + "libdd-capabilities", + "libdd-common", +] + [[package]] name = "libdd-common" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c779949577250487179d904508f18750070e9a01eb58dce378409ec5fa066f3b" +version = "4.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ "anyhow", "bytes", @@ -681,15 +749,19 @@ dependencies = [ "http-body", "http-body-util", "hyper", + "hyper-rustls", "hyper-util", "libc", "nix", "pin-project", "regex", + "rustls", + "rustls-native-certs", "serde", "static_assertions", "thiserror 1.0.69", "tokio", + "tokio-rustls", "tower-service", "windows-sys 0.52.0", ] @@ -697,18 +769,21 @@ dependencies = [ [[package]] name = "libdd-data-pipeline" version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "358411451d99011f13c7628acee25dc144f2bbeade87acf10fa7d5ffce1053dc" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ "anyhow", "arc-swap", + "async-trait", "bytes", "either", + "getrandom 0.2.17", "http", "http-body-util", + "libdd-capabilities", + "libdd-capabilities-impl", "libdd-common", - "libdd-ddsketch", "libdd-dogstatsd-client", + "libdd-shared-runtime", "libdd-telemetry", "libdd-tinybytes", "libdd-trace-protobuf 3.0.1", @@ -727,8 +802,7 @@ dependencies = [ [[package]] name = "libdd-ddsketch" version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b31b2435e2e8eaba0e35a96df3e1407b68f8ef76055383ceb2ba5a09e5a1bb5" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ "prost", ] @@ -736,8 +810,7 @@ dependencies = [ [[package]] name = "libdd-dogstatsd-client" version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6f8eca39d1e2ef6267cf77fc51eb7ebc7d4f44827e150b4d317c29d8c33bf87" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ "anyhow", "cadence", @@ -765,14 +838,29 @@ dependencies = [ "serde_yaml", ] +[[package]] +name = "libdd-shared-runtime" +version = "0.1.0" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +dependencies = [ + "async-trait", + "futures", + "libdd-capabilities", + "libdd-common", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "libdd-telemetry" version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78774ffce79da677602829d7fe27468283e5349010e974257233edf4cd12b783" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ "anyhow", + "async-trait", "base64 0.22.1", + "bytes", "futures", "hashbrown 0.15.5", "http", @@ -780,6 +868,7 @@ dependencies = [ "libc", "libdd-common", "libdd-ddsketch", + "libdd-shared-runtime", "serde", "serde_json", "sys-info", @@ -793,8 +882,7 @@ dependencies = [ [[package]] name = "libdd-tinybytes" version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e47838e12ae2665250b4cdba4e3119230b79e3c522bb9f48dd0c87346f5a8f44" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ "serde", ] @@ -802,8 +890,7 @@ dependencies = [ [[package]] name = "libdd-trace-normalization" version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab12e095f3589d02ceed76556e7aa8a1b5bc928a900e143b624e2331294e54b5" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ "anyhow", "libdd-trace-protobuf 3.0.1", @@ -823,8 +910,7 @@ dependencies = [ [[package]] name = "libdd-trace-protobuf" version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1809242895edc53ac51a21287829f42474e749dbc222ea7f414cb3f0d1f91d4e" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ "prost", "serde", @@ -834,28 +920,42 @@ dependencies = [ [[package]] name = "libdd-trace-stats" version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d92b882863f7c531d51e73f7bc5930c705e47829332128d9bdcad0fea3b2b942" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ + "anyhow", + "async-trait", "hashbrown 0.15.5", + "http", + "libdd-capabilities", + "libdd-capabilities-impl", + "libdd-common", "libdd-ddsketch", + "libdd-shared-runtime", "libdd-trace-protobuf 3.0.1", "libdd-trace-utils", + "rmp-serde", + "serde", + "tokio", + "tokio-util", + "tracing", ] [[package]] name = "libdd-trace-utils" version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "870506e9bb79c93ce5bbfe9d715c53c7ea393a177c7299f0bf43745c0adea0c7" +source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" dependencies = [ "anyhow", + "base64 0.22.1", "bytes", "futures", + "getrandom 0.2.17", "http", "http-body", "http-body-util", "indexmap", + "libdd-capabilities", + "libdd-capabilities-impl", "libdd-common", "libdd-tinybytes", "libdd-trace-normalization", @@ -954,6 +1054,12 @@ version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" +[[package]] +name = "openssl-probe" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" + [[package]] name = "opentelemetry" version = "0.31.0" @@ -1182,6 +1288,20 @@ version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "rmp" version = "0.8.15" @@ -1242,6 +1362,52 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "rustls" +version = "0.23.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef86cd5876211988985292b91c96a8f2d298df24e75989a43a3c73f2d4d8168b" +dependencies = [ + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9980d917ebb0c0536119ba501e90834767bffc3d60641457fd84a1f3fd337923" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pki-types" +version = "1.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30a7197ae7eb376e574fe940d068c30fe0462554a3ddbe4eca7838e049c937a9" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.22" @@ -1254,6 +1420,38 @@ version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" +[[package]] +name = "schannel" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "1.0.28" @@ -1391,6 +1589,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "syn" version = "2.0.117" @@ -1487,6 +1691,16 @@ dependencies = [ "syn", ] +[[package]] +name = "tokio-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.18" @@ -1629,6 +1843,12 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "uuid" version = "1.23.0" @@ -2035,6 +2255,12 @@ dependencies = [ "syn", ] +[[package]] +name = "zeroize" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" + [[package]] name = "zmij" version = "1.0.21" diff --git a/instrumentation/Cargo.toml b/instrumentation/Cargo.toml index 55c9c8d7..bae78586 100644 --- a/instrumentation/Cargo.toml +++ b/instrumentation/Cargo.toml @@ -22,3 +22,14 @@ opentelemetry_sdk = { version = "0.31.0", default-features = false } opentelemetry-semantic-conventions = { version = "0.31.0", features = ["semconv_experimental"] } tracing = { version = "0.1", default-features = false } tokio = { version = "1.44.1" } + +# Same libdatadog git pins as the repo root workspace (`../Cargo.toml`). This workspace builds +# `datadog-opentelemetry` via path dependency; without these patches, Cargo resolves crates.io +# `libdd-data-pipeline` 3.0.1, which does not expose the `telemetry` feature required by the SDK. +[patch.crates-io] +libdd-common = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } +libdd-data-pipeline = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } +libdd-telemetry = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } +libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } +libdd-tinybytes = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } +libdd-capabilities-impl = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } From eedd9d2313316dd6f6a573fd6c99eb4ecb4e11cb Mon Sep 17 00:00:00 2001 From: Munir Date: Wed, 13 May 2026 15:47:20 -0400 Subject: [PATCH 3/6] update to use libdatadog v33 --- .cargo/config.toml | 2 - Cargo.lock | 96 ++++++--- Cargo.toml | 20 +- .../src/core/configuration/configuration.rs | 2 +- .../src/core/telemetry_session.rs | 37 +++- datadog-opentelemetry/src/exporter/mod.rs | 5 +- datadog-opentelemetry/src/lib.rs | 5 +- instrumentation/Cargo.lock | 182 +++++++++++++----- instrumentation/Cargo.toml | 16 +- 9 files changed, 255 insertions(+), 110 deletions(-) delete mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index fe623106..00000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,2 +0,0 @@ -[registries.crates-io] -protocol = "git" diff --git a/Cargo.lock b/Cargo.lock index dfde0836..a4b487c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -170,6 +170,12 @@ dependencies = [ "generic-array", ] +[[package]] +name = "borrow-or-share" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc0b364ead1874514c8c2855ab558056ebfeb775653e7ae45ff72f28f8f3166c" + [[package]] name = "bumpalo" version = "3.19.0" @@ -397,7 +403,7 @@ dependencies = [ "clap", "criterion-plot", "is-terminal", - "itertools 0.10.5", + "itertools", "num-traits", "once_cell", "oorandom", @@ -418,7 +424,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" dependencies = [ "cast", - "itertools 0.10.5", + "itertools", ] [[package]] @@ -595,6 +601,17 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" +[[package]] +name = "fluent-uri" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc74ac4d8359ae70623506d512209619e5cf8f347124910440dbc221714b328e" +dependencies = [ + "borrow-or-share", + "ref-cast", + "serde", +] + [[package]] name = "fnv" version = "1.0.7" @@ -1161,15 +1178,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.15" @@ -1201,7 +1209,7 @@ checksum = "52ff2c0fe9bc6cb6b14a0592c2ff4fa9ceb83eea9db979b0487cd054946a2b8f" [[package]] name = "libdd-capabilities" version = "1.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "anyhow", "bytes", @@ -1212,7 +1220,7 @@ dependencies = [ [[package]] name = "libdd-capabilities-impl" version = "1.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "bytes", "http", @@ -1224,7 +1232,7 @@ dependencies = [ [[package]] name = "libdd-common" version = "4.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "anyhow", "bytes", @@ -1258,7 +1266,7 @@ dependencies = [ [[package]] name = "libdd-data-pipeline" version = "3.0.1" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "anyhow", "arc-swap", @@ -1291,7 +1299,7 @@ dependencies = [ [[package]] name = "libdd-ddsketch" version = "1.0.1" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "prost", ] @@ -1299,7 +1307,7 @@ dependencies = [ [[package]] name = "libdd-dogstatsd-client" version = "2.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "anyhow", "cadence", @@ -1330,7 +1338,7 @@ dependencies = [ [[package]] name = "libdd-shared-runtime" version = "0.1.0" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "async-trait", "futures", @@ -1344,7 +1352,7 @@ dependencies = [ [[package]] name = "libdd-telemetry" version = "4.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "anyhow", "async-trait", @@ -1371,7 +1379,7 @@ dependencies = [ [[package]] name = "libdd-tinybytes" version = "1.1.0" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "serde", ] @@ -1379,12 +1387,28 @@ dependencies = [ [[package]] name = "libdd-trace-normalization" version = "2.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "anyhow", "libdd-trace-protobuf 3.0.1", ] +[[package]] +name = "libdd-trace-obfuscation" +version = "2.0.0" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" +dependencies = [ + "anyhow", + "fluent-uri", + "libdd-common", + "libdd-trace-protobuf 3.0.1", + "libdd-trace-utils", + "log", + "percent-encoding", + "serde", + "serde_json", +] + [[package]] name = "libdd-trace-protobuf" version = "2.0.0" @@ -1399,7 +1423,7 @@ dependencies = [ [[package]] name = "libdd-trace-protobuf" version = "3.0.1" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "prost", "serde", @@ -1409,7 +1433,7 @@ dependencies = [ [[package]] name = "libdd-trace-stats" version = "2.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "anyhow", "async-trait", @@ -1420,6 +1444,7 @@ dependencies = [ "libdd-common", "libdd-ddsketch", "libdd-shared-runtime", + "libdd-trace-obfuscation", "libdd-trace-protobuf 3.0.1", "libdd-trace-utils", "rmp-serde", @@ -1432,7 +1457,7 @@ dependencies = [ [[package]] name = "libdd-trace-utils" version = "3.0.1" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "anyhow", "base64 0.22.1", @@ -1927,7 +1952,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9120690fafc389a67ba3803df527d0ec9cbbc9cc45e4cc20b332996dfb672425" dependencies = [ "anyhow", - "itertools 0.14.0", + "itertools", "proc-macro2", "quote", "syn", @@ -2045,6 +2070,26 @@ dependencies = [ "bitflags", ] +[[package]] +name = "ref-cast" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "regex" version = "1.11.1" @@ -2356,6 +2401,7 @@ version = "1.0.142" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" dependencies = [ + "indexmap", "itoa", "memchr", "ryu", diff --git a/Cargo.toml b/Cargo.toml index 00535b55..c5ec75af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,16 +68,12 @@ debug = false incremental = false opt-level = 3 -# Libdatadog repo tag `v32.0.0` and the `libdd-data-pipeline` 3.0.1 crate on crates.io still sit on the -# `libdd-common` 3.x stack. Git `main` has since moved `libdd-data-pipeline` to `libdd-common` 4.0.0 and -# adds trace-exporter / telemetry session headers (e.g. merged #1822). Individual crates such as -# `libdd-common` 4.0.0 and `libdd-capabilities-impl` 1.0.0 are on crates.io, but you cannot combine them -# with the published `libdd-data-pipeline` 3.0.1 without a version skew. Patch this set from `main` until -# a `libdd-data-pipeline` release targets 4.x on the registry. +# crates.io `libdd-data-pipeline` 3.0.1 predates the `telemetry` feature / session headers (#1822). +# Override with libdatadog release tag v33.0.0 until the registry publishes matching crate versions. [patch.crates-io] -libdd-common = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } -libdd-data-pipeline = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } -libdd-telemetry = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } -libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } -libdd-tinybytes = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } -libdd-capabilities-impl = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } +libdd-common = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } +libdd-data-pipeline = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } +libdd-telemetry = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } +libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } +libdd-tinybytes = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } +libdd-capabilities-impl = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } diff --git a/datadog-opentelemetry/src/core/configuration/configuration.rs b/datadog-opentelemetry/src/core/configuration/configuration.rs index 6c648863..4971b8e6 100644 --- a/datadog-opentelemetry/src/core/configuration/configuration.rs +++ b/datadog-opentelemetry/src/core/configuration/configuration.rs @@ -1963,7 +1963,7 @@ impl ConfigBuilder { config.dogstatsd_agent_url.set_calculated(url); } - crate::core::telemetry_session::install_tracer_lineage_env(config.runtime_id); + crate::core::telemetry_session::install_process_lineage_env(config.runtime_id); config } diff --git a/datadog-opentelemetry/src/core/telemetry_session.rs b/datadog-opentelemetry/src/core/telemetry_session.rs index fa36a713..9efafaeb 100644 --- a/datadog-opentelemetry/src/core/telemetry_session.rs +++ b/datadog-opentelemetry/src/core/telemetry_session.rs @@ -53,6 +53,8 @@ impl From for TelemetryInstrumentationSessions { } /// Sets [`ENV_ROOT_RS_SESSION_ID`] if unset (does not replace an existing value). +/// +/// Must be called before spawning threads to avoid races on the process environment. #[allow(clippy::disallowed_methods)] pub fn install_process_lineage_env(runtime_id: &str) { if std::env::var_os(ENV_ROOT_RS_SESSION_ID).is_none() { @@ -60,11 +62,6 @@ pub fn install_process_lineage_env(runtime_id: &str) { } } -/// Same as [`install_process_lineage_env`]; call when the tracer `runtime_id` is known. -pub fn install_tracer_lineage_env(runtime_id: &str) { - install_process_lineage_env(runtime_id); -} - /// Env pairs for [`std::process::Command`] (root + parent = this `runtime_id`). #[allow(clippy::disallowed_methods)] pub fn lineage_env_for_spawn(runtime_id: &str) -> [(&'static str, String); 2] { @@ -110,9 +107,39 @@ mod tests { #[test] fn lineage_env_parent_is_current_runtime_id() { + let _l = env_mutation_lock(); + let before = std::env::var_os(ENV_ROOT_RS_SESSION_ID); + std::env::remove_var(ENV_ROOT_RS_SESSION_ID); let env = lineage_env_for_spawn("run-1"); assert_eq!(env[1].0, ENV_PARENT_RS_SESSION_ID); assert_eq!(env[1].1, "run-1"); + restore_env_opt(ENV_ROOT_RS_SESSION_ID, before); + } + + #[test] + fn lineage_env_for_spawn_preserves_existing_root() { + let _l = env_mutation_lock(); + let before = std::env::var_os(ENV_ROOT_RS_SESSION_ID); + std::env::set_var(ENV_ROOT_RS_SESSION_ID, "existing-root"); + let env = lineage_env_for_spawn("run-2"); + assert_eq!(env[0].1, "existing-root"); + assert_eq!(env[1].1, "run-2"); + restore_env_opt(ENV_ROOT_RS_SESSION_ID, before); + } + + #[test] + fn from_runtime_id_captures_env_root_and_parent() { + let _l = env_mutation_lock(); + let root_before = std::env::var_os(ENV_ROOT_RS_SESSION_ID); + let parent_before = std::env::var_os(ENV_PARENT_RS_SESSION_ID); + std::env::set_var(ENV_ROOT_RS_SESSION_ID, "root-x"); + std::env::set_var(ENV_PARENT_RS_SESSION_ID, "parent-x"); + let s = InstrumentationSessions::from_runtime_id("current"); + assert_eq!(s.session_id.as_deref(), Some("current")); + assert_eq!(s.root_session_id.as_deref(), Some("root-x")); + assert_eq!(s.parent_session_id.as_deref(), Some("parent-x")); + restore_env_opt(ENV_ROOT_RS_SESSION_ID, root_before); + restore_env_opt(ENV_PARENT_RS_SESSION_ID, parent_before); } #[test] diff --git a/datadog-opentelemetry/src/exporter/mod.rs b/datadog-opentelemetry/src/exporter/mod.rs index 4226aea0..0c341ff2 100644 --- a/datadog-opentelemetry/src/exporter/mod.rs +++ b/datadog-opentelemetry/src/exporter/mod.rs @@ -610,8 +610,9 @@ impl TraceExporterWorker { fn run(mut self) -> Result<(), TraceExporterError> { #[cfg(feature = "test-utils")] { - // Wait for the agent info to be fetched to get deterministic output when deciding - // to drop traces or not + // Wait for agent info before first export for deterministic sampling decisions. + // `wait_agent_info_ready` is async; a dedicated runtime is required because this + // runs inside a plain `thread::spawn` with no surrounding executor. tokio::runtime::Builder::new_current_thread() .enable_all() .build() diff --git a/datadog-opentelemetry/src/lib.rs b/datadog-opentelemetry/src/lib.rs index f7a694a8..9f0ad44f 100644 --- a/datadog-opentelemetry/src/lib.rs +++ b/datadog-opentelemetry/src/lib.rs @@ -246,9 +246,8 @@ pub(crate) mod core; pub use core::configuration; pub use core::log; pub use core::telemetry_session::{ - extend_command_env_with_lineage, install_process_lineage_env, install_tracer_lineage_env, - lineage_env_for_spawn, InstrumentationSessions, ENV_PARENT_RS_SESSION_ID, - ENV_ROOT_RS_SESSION_ID, + extend_command_env_with_lineage, install_process_lineage_env, lineage_env_for_spawn, + InstrumentationSessions, ENV_PARENT_RS_SESSION_ID, ENV_ROOT_RS_SESSION_ID, }; #[cfg(feature = "test-utils")] diff --git a/instrumentation/Cargo.lock b/instrumentation/Cargo.lock index 1ede8856..60f35ad2 100644 --- a/instrumentation/Cargo.lock +++ b/instrumentation/Cargo.lock @@ -104,6 +104,12 @@ dependencies = [ "generic-array", ] +[[package]] +name = "borrow-or-share" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc0b364ead1874514c8c2855ab558056ebfeb775653e7ae45ff72f28f8f3166c" + [[package]] name = "bumpalo" version = "3.20.2" @@ -127,9 +133,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.60" +version = "1.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43c5703da9466b66a946814e1adf53ea2c90f10063b86290cc9eb67ce3478a20" +checksum = "a1dce859f0832a7d088c4f1119888ab94ef4b5d6795d1ce05afb7fe159d79f98" dependencies = [ "find-msvc-tools", "shlex", @@ -149,11 +155,12 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "const_format" -version = "0.2.35" +version = "0.2.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7faa7469a93a566e9ccc1c73fe783b4a65c274c5ace346038dca9c39fe0030ad" +checksum = "4481a617ad9a412be3b97c5d403fef8ed023103368908b9c50af598ff467cc1e" dependencies = [ "const_format_proc_macros", + "konst", ] [[package]] @@ -257,7 +264,8 @@ dependencies = [ "opentelemetry", "opentelemetry-semantic-conventions", "opentelemetry_sdk", - "rand 0.8.5", + "percent-encoding", + "rand 0.8.6", "rustc_version_runtime", "serde", "serde_json", @@ -306,6 +314,17 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" +[[package]] +name = "fluent-uri" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc74ac4d8359ae70623506d512209619e5cf8f347124910440dbc221714b328e" +dependencies = [ + "borrow-or-share", + "ref-cast", + "serde", +] + [[package]] name = "foldhash" version = "0.1.5" @@ -478,9 +497,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.17.0" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" [[package]] name = "heck" @@ -612,7 +631,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" dependencies = [ "equivalent", - "hashbrown 0.17.0", + "hashbrown 0.17.1", "serde", "serde_core", ] @@ -634,14 +653,31 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "js-sys" -version = "0.3.95" +version = "0.3.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2964e92d1d9dc3364cae4d718d93f227e3abb088e747d92e0395bfdedf1c12ca" +checksum = "67df7112613f8bfd9150013a0314e196f4800d3201ae742489d999db2f979f08" dependencies = [ + "cfg-if", + "futures-util", "once_cell", "wasm-bindgen", ] +[[package]] +name = "konst" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "128133ed7824fcd73d6e7b17957c5eb7bacb885649bd8c69708b2331a10bcefb" +dependencies = [ + "konst_macro_rules", +] + +[[package]] +name = "konst_macro_rules" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4933f3f57a8e9d9da04db23fb153356ecaf00cbd14aee46279c33dc80925c37" + [[package]] name = "lambda_runtime" version = "0.13.0" @@ -705,14 +741,14 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" [[package]] name = "libc" -version = "0.2.185" +version = "0.2.186" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ff2c0fe9bc6cb6b14a0592c2ff4fa9ceb83eea9db979b0487cd054946a2b8f" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" [[package]] name = "libdd-capabilities" version = "1.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "anyhow", "bytes", @@ -723,7 +759,7 @@ dependencies = [ [[package]] name = "libdd-capabilities-impl" version = "1.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "bytes", "http", @@ -735,7 +771,7 @@ dependencies = [ [[package]] name = "libdd-common" version = "4.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "anyhow", "bytes", @@ -769,7 +805,7 @@ dependencies = [ [[package]] name = "libdd-data-pipeline" version = "3.0.1" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "anyhow", "arc-swap", @@ -802,7 +838,7 @@ dependencies = [ [[package]] name = "libdd-ddsketch" version = "1.0.1" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "prost", ] @@ -810,7 +846,7 @@ dependencies = [ [[package]] name = "libdd-dogstatsd-client" version = "2.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "anyhow", "cadence", @@ -830,7 +866,7 @@ dependencies = [ "libdd-trace-protobuf 2.0.0", "memfd", "prost", - "rand 0.8.5", + "rand 0.8.6", "rmp", "rmp-serde", "rustix", @@ -841,7 +877,7 @@ dependencies = [ [[package]] name = "libdd-shared-runtime" version = "0.1.0" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "async-trait", "futures", @@ -855,7 +891,7 @@ dependencies = [ [[package]] name = "libdd-telemetry" version = "4.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "anyhow", "async-trait", @@ -882,7 +918,7 @@ dependencies = [ [[package]] name = "libdd-tinybytes" version = "1.1.0" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "serde", ] @@ -890,12 +926,28 @@ dependencies = [ [[package]] name = "libdd-trace-normalization" version = "2.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "anyhow", "libdd-trace-protobuf 3.0.1", ] +[[package]] +name = "libdd-trace-obfuscation" +version = "2.0.0" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" +dependencies = [ + "anyhow", + "fluent-uri", + "libdd-common", + "libdd-trace-protobuf 3.0.1", + "libdd-trace-utils", + "log", + "percent-encoding", + "serde", + "serde_json", +] + [[package]] name = "libdd-trace-protobuf" version = "2.0.0" @@ -910,7 +962,7 @@ dependencies = [ [[package]] name = "libdd-trace-protobuf" version = "3.0.1" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "prost", "serde", @@ -920,7 +972,7 @@ dependencies = [ [[package]] name = "libdd-trace-stats" version = "2.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "anyhow", "async-trait", @@ -931,6 +983,7 @@ dependencies = [ "libdd-common", "libdd-ddsketch", "libdd-shared-runtime", + "libdd-trace-obfuscation", "libdd-trace-protobuf 3.0.1", "libdd-trace-utils", "rmp-serde", @@ -943,7 +996,7 @@ dependencies = [ [[package]] name = "libdd-trace-utils" version = "3.0.1" -source = "git+https://github.com/DataDog/libdatadog?rev=53c8c16f9278391801fa4fdac30f339433cb0ca9#53c8c16f9278391801fa4fdac30f339433cb0ca9" +source = "git+https://github.com/DataDog/libdatadog?tag=v33.0.0#37d17ee71ae396782242d45e1b31af2887bbbbd3" dependencies = [ "anyhow", "base64 0.22.1", @@ -961,7 +1014,7 @@ dependencies = [ "libdd-trace-normalization", "libdd-trace-protobuf 3.0.1", "prost", - "rand 0.8.5", + "rand 0.8.6", "rmp", "rmp-serde", "rmpv", @@ -1104,18 +1157,18 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "pin-project" -version = "1.1.11" +version = "1.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1749c7ed4bcaf4c3d0a3efc28538844fb29bcdd7d2b67b2be7e20ba861ff517" +checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.11" +version = "1.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b20ed30f105399776b9c883e68e536ef602a16ae6f596d2c473591d6ad64c6" +checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b" dependencies = [ "proc-macro2", "quote", @@ -1202,9 +1255,9 @@ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" [[package]] name = "rand" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a" dependencies = [ "libc", "rand_chacha 0.3.1", @@ -1259,6 +1312,26 @@ dependencies = [ "getrandom 0.3.4", ] +[[package]] +name = "ref-cast" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "regex" version = "1.12.3" @@ -1504,6 +1577,7 @@ version = "1.0.149" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" dependencies = [ + "indexmap", "itoa", "memchr", "serde", @@ -1667,9 +1741,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.51.1" +version = "1.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f66bf9585cda4b724d3e78ab34b73fb2bbaba9011b9bfdf69dc836382ea13b8c" +checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe" dependencies = [ "bytes", "libc", @@ -1821,9 +1895,9 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "typenum" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" +checksum = "40ce102ab67701b8526c123c1bab5cbe42d7040ccfd0f64af1a385808d2f43de" [[package]] name = "unicode-ident" @@ -1851,9 +1925,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "uuid" -version = "1.23.0" +version = "1.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ac8b6f42ead25368cf5b098aeb3dc8a1a2c05a3eee8a9a1a68c640edbfc79d9" +checksum = "ddd74a9687298c6858e9b88ec8935ec45d22e8fd5e6394fa1bd4e99a87789c76" dependencies = [ "getrandom 0.4.2", "js-sys", @@ -1889,11 +1963,11 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasip2" -version = "1.0.2+wasi-0.2.9" +version = "1.0.3+wasi-0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" dependencies = [ - "wit-bindgen", + "wit-bindgen 0.57.1", ] [[package]] @@ -1902,14 +1976,14 @@ version = "0.4.0+wasi-0.3.0-rc-2026-01-06" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" dependencies = [ - "wit-bindgen", + "wit-bindgen 0.51.0", ] [[package]] name = "wasm-bindgen" -version = "0.2.118" +version = "0.2.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf938a0bacb0469e83c1e148908bd7d5a6010354cf4fb73279b7447422e3a89" +checksum = "49ace1d07c165b0864824eee619580c4689389afa9dc9ed3a4c75040d82e6790" dependencies = [ "cfg-if", "once_cell", @@ -1920,9 +1994,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.118" +version = "0.2.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeff24f84126c0ec2db7a449f0c2ec963c6a49efe0698c4242929da037ca28ed" +checksum = "8e68e6f4afd367a562002c05637acb8578ff2dea1943df76afb9e83d177c8578" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1930,9 +2004,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.118" +version = "0.2.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d08065faf983b2b80a79fd87d8254c409281cf7de75fc4b773019824196c904" +checksum = "d95a9ec35c64b2a7cb35d3fead40c4238d0940c86d107136999567a4703259f2" dependencies = [ "bumpalo", "proc-macro2", @@ -1943,9 +2017,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.118" +version = "0.2.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd04d9e306f1907bd13c6361b5c6bfc7b3b3c095ed3f8a9246390f8dbdee129" +checksum = "c4e0100b01e9f0d03189a92b96772a1fb998639d981193d7dbab487302513441" dependencies = [ "unicode-ident", ] @@ -2156,6 +2230,12 @@ dependencies = [ "wit-bindgen-rust-macro", ] +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + [[package]] name = "wit-bindgen-core" version = "0.51.0" diff --git a/instrumentation/Cargo.toml b/instrumentation/Cargo.toml index bae78586..21e278e4 100644 --- a/instrumentation/Cargo.toml +++ b/instrumentation/Cargo.toml @@ -23,13 +23,11 @@ opentelemetry-semantic-conventions = { version = "0.31.0", features = ["semconv_ tracing = { version = "0.1", default-features = false } tokio = { version = "1.44.1" } -# Same libdatadog git pins as the repo root workspace (`../Cargo.toml`). This workspace builds -# `datadog-opentelemetry` via path dependency; without these patches, Cargo resolves crates.io -# `libdd-data-pipeline` 3.0.1, which does not expose the `telemetry` feature required by the SDK. +# Same libdatadog tag as the repo root (`../Cargo.toml`): v33.0.0 (see root `[patch.crates-io]` note). [patch.crates-io] -libdd-common = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } -libdd-data-pipeline = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } -libdd-telemetry = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } -libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } -libdd-tinybytes = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } -libdd-capabilities-impl = { git = "https://github.com/DataDog/libdatadog", rev = "53c8c16f9278391801fa4fdac30f339433cb0ca9" } +libdd-common = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } +libdd-data-pipeline = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } +libdd-telemetry = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } +libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } +libdd-tinybytes = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } +libdd-capabilities-impl = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } From 292f8c5034615a9605a8b1924a599b193c1ca45a Mon Sep 17 00:00:00 2001 From: Munir Date: Thu, 14 May 2026 01:00:20 -0400 Subject: [PATCH 4/6] clean up deps and fix tests --- Cargo.lock | 159 +----------------- Cargo.toml | 13 +- datadog-opentelemetry/src/core/telemetry.rs | 2 +- .../src/core/telemetry_session.rs | 57 ++----- datadog-opentelemetry/src/lib.rs | 3 +- datadog-opentelemetry/src/span_exporter.rs | 4 +- 6 files changed, 28 insertions(+), 210 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a4b487c0..2a798d78 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -366,16 +366,6 @@ dependencies = [ "libc", ] -[[package]] -name = "core-foundation" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -963,23 +953,6 @@ dependencies = [ "want", ] -[[package]] -name = "hyper-rustls" -version = "0.27.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" -dependencies = [ - "http", - "hyper", - "hyper-util", - "rustls", - "rustls-native-certs", - "rustls-pki-types", - "tokio", - "tokio-rustls", - "tower-service", -] - [[package]] name = "hyper-timeout" version = "0.5.2" @@ -1246,19 +1219,15 @@ dependencies = [ "http-body", "http-body-util", "hyper", - "hyper-rustls", "hyper-util", "libc", "nix", "pin-project", "regex", - "rustls", - "rustls-native-certs", "serde", "static_assertions", "thiserror 1.0.69", "tokio", - "tokio-rustls", "tower-service", "windows-sys 0.52.0", ] @@ -1629,12 +1598,6 @@ version = "11.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" -[[package]] -name = "openssl-probe" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" - [[package]] name = "opentelemetry" version = "0.31.0" @@ -2168,20 +2131,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "ring" -version = "0.17.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" -dependencies = [ - "cc", - "cfg-if", - "getrandom 0.2.16", - "libc", - "untrusted", - "windows-sys 0.52.0", -] - [[package]] name = "rmp" version = "0.8.14" @@ -2252,52 +2201,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "rustls" -version = "0.23.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c2c118cb077cca2822033836dfb1b975355dfb784b5e8da48f7b6c5db74e60e" -dependencies = [ - "once_cell", - "ring", - "rustls-pki-types", - "rustls-webpki", - "subtle", - "zeroize", -] - -[[package]] -name = "rustls-native-certs" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9980d917ebb0c0536119ba501e90834767bffc3d60641457fd84a1f3fd337923" -dependencies = [ - "openssl-probe", - "rustls-pki-types", - "schannel", - "security-framework", -] - -[[package]] -name = "rustls-pki-types" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd" -dependencies = [ - "zeroize", -] - -[[package]] -name = "rustls-webpki" -version = "0.103.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" -dependencies = [ - "ring", - "rustls-pki-types", - "untrusted", -] - [[package]] name = "rustversion" version = "1.0.22" @@ -2319,44 +2222,12 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "schannel" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" -dependencies = [ - "windows-sys 0.61.2", -] - [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "security-framework" -version = "3.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d17b898a6d6948c3a8ee4372c17cb384f90d2e6e912ef00895b14fd7ab54ec38" -dependencies = [ - "bitflags", - "core-foundation 0.10.1", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "semver" version = "1.0.26" @@ -2543,12 +2414,6 @@ version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b3c8667cd96245cbb600b8dec5680a7319edd719c5aa2b5d23c6bff94f39765" -[[package]] -name = "subtle" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" - [[package]] name = "syn" version = "2.0.105" @@ -2597,7 +2462,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ "bitflags", - "core-foundation 0.9.4", + "core-foundation", "system-configuration-sys", ] @@ -2753,16 +2618,6 @@ dependencies = [ "syn", ] -[[package]] -name = "tokio-rustls" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" -dependencies = [ - "rustls", - "tokio", -] - [[package]] name = "tokio-stream" version = "0.1.17" @@ -2996,12 +2851,6 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" -[[package]] -name = "untrusted" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" - [[package]] name = "url" version = "2.5.4" @@ -3496,12 +3345,6 @@ dependencies = [ "synstructure", ] -[[package]] -name = "zeroize" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" - [[package]] name = "zerotrie" version = "0.2.3" diff --git a/Cargo.toml b/Cargo.toml index c5ec75af..bfd00412 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,14 +23,11 @@ authors = ["Datadog Inc. "] [workspace.dependencies] # Libdatadog dependencies - change to a stable version once we release -libdd-data-pipeline = { version = "3.0.1", default-features = false, features = [ - "https", - "telemetry", -] } -libdd-trace-utils = { version = "3.0.1", default-features = false } +libdd-data-pipeline = { version = "3.0.1", default-features = false, features = ["telemetry"] } +libdd-trace-utils = { version = "3.0.0", default-features = false } libdd-telemetry = { version = "4.0.0", default-features = false } libdd-common = { version = "4.0.0", default-features = false } -libdd-capabilities-impl = { version = "1.0.0", default-features = false, features = ["https"] } +libdd-capabilities-impl = { version = "1.0.0", default-features = false } libdd-tinybytes = { version = "1.1.0", default-features = false } libdd-library-config = { version = "1.1.0", default-features = false } opentelemetry_sdk = { version = "0.31.0", features = [ @@ -68,8 +65,8 @@ debug = false incremental = false opt-level = 3 -# crates.io `libdd-data-pipeline` 3.0.1 predates the `telemetry` feature / session headers (#1822). -# Override with libdatadog release tag v33.0.0 until the registry publishes matching crate versions. +# crates.io `libdd-data-pipeline` 3.0.1 predates the `telemetry` feature / session headers. +# Override with libdatadog tag v33.0.0 until the registry publishes matching crate versions. [patch.crates-io] libdd-common = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } libdd-data-pipeline = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } diff --git a/datadog-opentelemetry/src/core/telemetry.rs b/datadog-opentelemetry/src/core/telemetry.rs index 75baa408..4d29dc32 100644 --- a/datadog-opentelemetry/src/core/telemetry.rs +++ b/datadog-opentelemetry/src/core/telemetry.rs @@ -250,7 +250,7 @@ fn make_telemetry_worker( builder.config = libdd_telemetry::config::Config::from_env(); builder.config.telemetry_heartbeat_interval = Duration::from_secs_f64(config.telemetry_heartbeat_interval()); - let inst = telemetry_session::InstrumentationSessions::from_runtime_id(config.runtime_id()); + let inst = telemetry_session::sessions_from_runtime_id(config.runtime_id()); builder.config.session_id = inst.session_id; builder.config.root_session_id = inst.root_session_id; builder.config.parent_session_id = inst.parent_session_id; diff --git a/datadog-opentelemetry/src/core/telemetry_session.rs b/datadog-opentelemetry/src/core/telemetry_session.rs index 9efafaeb..f037349d 100644 --- a/datadog-opentelemetry/src/core/telemetry_session.rs +++ b/datadog-opentelemetry/src/core/telemetry_session.rs @@ -5,50 +5,27 @@ //! Here `runtime_id` is unchanged across `fork()` (unlike some Datadog SDKs); set parent for a new //! process with [`lineage_env_for_spawn`] or [`extend_command_env_with_lineage`]. -use libdd_data_pipeline::trace_exporter::TelemetryInstrumentationSessions; +pub use libdd_data_pipeline::trace_exporter::TelemetryInstrumentationSessions; /// Root lineage env key. pub const ENV_ROOT_RS_SESSION_ID: &str = "_DD_ROOT_RS_SESSION_ID"; /// Parent lineage env key. pub const ENV_PARENT_RS_SESSION_ID: &str = "_DD_PARENT_RS_SESSION_ID"; -/// Session ids for libdd telemetry / trace instrumentation headers. -#[derive(Clone, Debug, Default, PartialEq, Eq)] -pub struct InstrumentationSessions { - /// Current session id. - pub session_id: Option, - /// Root session id when distinct from current. - pub root_session_id: Option, - /// Parent session id when distinct from current. - pub parent_session_id: Option, -} - -impl InstrumentationSessions { - /// From `runtime_id` plus env keys when set and different from current. - #[allow(clippy::disallowed_methods)] - pub fn from_runtime_id(runtime_id: &str) -> Self { - let session_id = runtime_id.to_owned(); - let root_session_id = std::env::var(ENV_ROOT_RS_SESSION_ID) - .ok() - .filter(|r| r != &session_id); - let parent_session_id = std::env::var(ENV_PARENT_RS_SESSION_ID) - .ok() - .filter(|p| p != &session_id); - Self { - session_id: Some(session_id), - root_session_id, - parent_session_id, - } - } -} - -impl From for TelemetryInstrumentationSessions { - fn from(s: InstrumentationSessions) -> Self { - Self { - session_id: s.session_id, - root_session_id: s.root_session_id, - parent_session_id: s.parent_session_id, - } +/// Builds [`TelemetryInstrumentationSessions`] from `runtime_id` plus lineage env keys. +#[allow(clippy::disallowed_methods)] +pub fn sessions_from_runtime_id(runtime_id: &str) -> TelemetryInstrumentationSessions { + let session_id = runtime_id.to_owned(); + let root_session_id = std::env::var(ENV_ROOT_RS_SESSION_ID) + .ok() + .filter(|r| r != &session_id); + let parent_session_id = std::env::var(ENV_PARENT_RS_SESSION_ID) + .ok() + .filter(|p| p != &session_id); + TelemetryInstrumentationSessions { + session_id: Some(session_id), + root_session_id, + parent_session_id, } } @@ -97,7 +74,7 @@ mod tests { let parent_before = std::env::var_os(ENV_PARENT_RS_SESSION_ID); std::env::remove_var(ENV_ROOT_RS_SESSION_ID); std::env::remove_var(ENV_PARENT_RS_SESSION_ID); - let s = InstrumentationSessions::from_runtime_id("rid-a"); + let s = sessions_from_runtime_id("rid-a"); assert_eq!(s.session_id.as_deref(), Some("rid-a")); assert!(s.root_session_id.is_none()); assert!(s.parent_session_id.is_none()); @@ -134,7 +111,7 @@ mod tests { let parent_before = std::env::var_os(ENV_PARENT_RS_SESSION_ID); std::env::set_var(ENV_ROOT_RS_SESSION_ID, "root-x"); std::env::set_var(ENV_PARENT_RS_SESSION_ID, "parent-x"); - let s = InstrumentationSessions::from_runtime_id("current"); + let s = sessions_from_runtime_id("current"); assert_eq!(s.session_id.as_deref(), Some("current")); assert_eq!(s.root_session_id.as_deref(), Some("root-x")); assert_eq!(s.parent_session_id.as_deref(), Some("parent-x")); diff --git a/datadog-opentelemetry/src/lib.rs b/datadog-opentelemetry/src/lib.rs index 9f0ad44f..0dd9b6d2 100644 --- a/datadog-opentelemetry/src/lib.rs +++ b/datadog-opentelemetry/src/lib.rs @@ -247,7 +247,8 @@ pub use core::configuration; pub use core::log; pub use core::telemetry_session::{ extend_command_env_with_lineage, install_process_lineage_env, lineage_env_for_spawn, - InstrumentationSessions, ENV_PARENT_RS_SESSION_ID, ENV_ROOT_RS_SESSION_ID, + sessions_from_runtime_id, TelemetryInstrumentationSessions, ENV_PARENT_RS_SESSION_ID, + ENV_ROOT_RS_SESSION_ID, }; #[cfg(feature = "test-utils")] diff --git a/datadog-opentelemetry/src/span_exporter.rs b/datadog-opentelemetry/src/span_exporter.rs index 02ce9ad6..6e739e17 100644 --- a/datadog-opentelemetry/src/span_exporter.rs +++ b/datadog-opentelemetry/src/span_exporter.rs @@ -13,7 +13,7 @@ use opentelemetry_sdk::{trace::SpanData, Resource}; use crate::{ configuration::Config, - core::telemetry_session::InstrumentationSessions, + core::telemetry_session, ddtrace_transform, exporter::{AsyncExporterError, AsyncTraceExporter, Exporter, TraceChunk, TraceExporter}, mappings::CachedConfig, @@ -64,7 +64,7 @@ impl DatadogExporter { debug_enabled: false, }); builder.set_telemetry_instrumentation_sessions( - InstrumentationSessions::from_runtime_id(config.runtime_id()).into(), + telemetry_session::sessions_from_runtime_id(config.runtime_id()), ); } DatadogExporter { From c8055d274c64c5af54e1fc99cecd3f8dd0cd6752 Mon Sep 17 00:00:00 2001 From: Munir Date: Thu, 14 May 2026 13:53:16 -0400 Subject: [PATCH 5/6] fix: regenerate instrumentation/Cargo.lock after adding [patch.crates-io] The new [patch.crates-io] section in instrumentation/Cargo.toml was not reflected in the lock file, causing `cargo build --locked` to fail in CI. Co-Authored-By: Claude Sonnet 4.6 --- instrumentation/Cargo.lock | 162 ------------------------------------- 1 file changed, 162 deletions(-) diff --git a/instrumentation/Cargo.lock b/instrumentation/Cargo.lock index 60f35ad2..d611b897 100644 --- a/instrumentation/Cargo.lock +++ b/instrumentation/Cargo.lock @@ -174,22 +174,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "core-foundation" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" - [[package]] name = "cpufeatures" version = "0.2.17" @@ -582,22 +566,6 @@ dependencies = [ "want", ] -[[package]] -name = "hyper-rustls" -version = "0.27.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ca68d021ef39cf6463ab54c1d0f5daf03377b70561305bb89a8f83aab66e0f" -dependencies = [ - "http", - "hyper", - "hyper-util", - "rustls", - "rustls-native-certs", - "tokio", - "tokio-rustls", - "tower-service", -] - [[package]] name = "hyper-util" version = "0.1.20" @@ -785,19 +753,15 @@ dependencies = [ "http-body", "http-body-util", "hyper", - "hyper-rustls", "hyper-util", "libc", "nix", "pin-project", "regex", - "rustls", - "rustls-native-certs", "serde", "static_assertions", "thiserror 1.0.69", "tokio", - "tokio-rustls", "tower-service", "windows-sys 0.52.0", ] @@ -1107,12 +1071,6 @@ version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" -[[package]] -name = "openssl-probe" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" - [[package]] name = "opentelemetry" version = "0.31.0" @@ -1361,20 +1319,6 @@ version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" -[[package]] -name = "ring" -version = "0.17.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" -dependencies = [ - "cc", - "cfg-if", - "getrandom 0.2.17", - "libc", - "untrusted", - "windows-sys 0.52.0", -] - [[package]] name = "rmp" version = "0.8.15" @@ -1435,52 +1379,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "rustls" -version = "0.23.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef86cd5876211988985292b91c96a8f2d298df24e75989a43a3c73f2d4d8168b" -dependencies = [ - "once_cell", - "ring", - "rustls-pki-types", - "rustls-webpki", - "subtle", - "zeroize", -] - -[[package]] -name = "rustls-native-certs" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9980d917ebb0c0536119ba501e90834767bffc3d60641457fd84a1f3fd337923" -dependencies = [ - "openssl-probe", - "rustls-pki-types", - "schannel", - "security-framework", -] - -[[package]] -name = "rustls-pki-types" -version = "1.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a7197ae7eb376e574fe940d068c30fe0462554a3ddbe4eca7838e049c937a9" -dependencies = [ - "zeroize", -] - -[[package]] -name = "rustls-webpki" -version = "0.103.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" -dependencies = [ - "ring", - "rustls-pki-types", - "untrusted", -] - [[package]] name = "rustversion" version = "1.0.22" @@ -1493,38 +1391,6 @@ version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" -[[package]] -name = "schannel" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" -dependencies = [ - "windows-sys 0.61.2", -] - -[[package]] -name = "security-framework" -version = "3.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "semver" version = "1.0.28" @@ -1663,12 +1529,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "subtle" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" - [[package]] name = "syn" version = "2.0.117" @@ -1765,16 +1625,6 @@ dependencies = [ "syn", ] -[[package]] -name = "tokio-rustls" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" -dependencies = [ - "rustls", - "tokio", -] - [[package]] name = "tokio-stream" version = "0.1.18" @@ -1917,12 +1767,6 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" -[[package]] -name = "untrusted" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" - [[package]] name = "uuid" version = "1.23.1" @@ -2335,12 +2179,6 @@ dependencies = [ "syn", ] -[[package]] -name = "zeroize" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" - [[package]] name = "zmij" version = "1.0.21" From 81f3b7b19ddbfe0a8277d90eecb321c7eec9a71c Mon Sep 17 00:00:00 2001 From: Munir Date: Thu, 14 May 2026 14:07:12 -0400 Subject: [PATCH 6/6] chore: update libdatadog versions and drop [patch.crates-io] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Point to the published crate versions from DataDog/libdatadog#1989: libdd-data-pipeline 3.0.1 → 3.1.0 libdd-telemetry 4.0.0 → 5.0.0 libdd-capabilities-impl 1.0.0 → 1.1.0 These versions include the APIs required for instrumentation session ID propagation (TelemetryInstrumentationSessions, NativeCapabilities, session_id fields on telemetry Config). With them published, the [patch.crates-io] git overrides are no longer needed and are removed from both Cargo.toml and instrumentation/Cargo.toml. Note: this commit will not build until libdatadog#1989 merges and the new crate versions are published to crates.io. Co-Authored-By: Claude Sonnet 4.6 --- Cargo.toml | 17 ++++------------- instrumentation/Cargo.toml | 8 -------- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bfd00412..2dcf6f2a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,12 +22,12 @@ description = "Reserved future DataDog package, contact info@datadoghq.com if yo authors = ["Datadog Inc. "] [workspace.dependencies] -# Libdatadog dependencies - change to a stable version once we release -libdd-data-pipeline = { version = "3.0.1", default-features = false, features = ["telemetry"] } +# Libdatadog dependencies +libdd-data-pipeline = { version = "3.1.0", default-features = false, features = ["telemetry"] } libdd-trace-utils = { version = "3.0.0", default-features = false } -libdd-telemetry = { version = "4.0.0", default-features = false } +libdd-telemetry = { version = "5.0.0", default-features = false } libdd-common = { version = "4.0.0", default-features = false } -libdd-capabilities-impl = { version = "1.0.0", default-features = false } +libdd-capabilities-impl = { version = "1.1.0", default-features = false } libdd-tinybytes = { version = "1.1.0", default-features = false } libdd-library-config = { version = "1.1.0", default-features = false } opentelemetry_sdk = { version = "0.31.0", features = [ @@ -65,12 +65,3 @@ debug = false incremental = false opt-level = 3 -# crates.io `libdd-data-pipeline` 3.0.1 predates the `telemetry` feature / session headers. -# Override with libdatadog tag v33.0.0 until the registry publishes matching crate versions. -[patch.crates-io] -libdd-common = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } -libdd-data-pipeline = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } -libdd-telemetry = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } -libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } -libdd-tinybytes = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } -libdd-capabilities-impl = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } diff --git a/instrumentation/Cargo.toml b/instrumentation/Cargo.toml index 21e278e4..4f49bbbd 100644 --- a/instrumentation/Cargo.toml +++ b/instrumentation/Cargo.toml @@ -23,11 +23,3 @@ opentelemetry-semantic-conventions = { version = "0.31.0", features = ["semconv_ tracing = { version = "0.1", default-features = false } tokio = { version = "1.44.1" } -# Same libdatadog tag as the repo root (`../Cargo.toml`): v33.0.0 (see root `[patch.crates-io]` note). -[patch.crates-io] -libdd-common = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } -libdd-data-pipeline = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } -libdd-telemetry = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } -libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } -libdd-tinybytes = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" } -libdd-capabilities-impl = { git = "https://github.com/DataDog/libdatadog", tag = "v33.0.0" }