feat(telemetry)!: make telemetry worker wasm-compatible for the TraceExporter#2172
feat(telemetry)!: make telemetry worker wasm-compatible for the TraceExporter#2172Aaalibaba42 wants to merge 13 commits into
Conversation
1624706 to
9042d85
Compare
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: b3aef55 | Docs | Datadog PR Page | Give us feedback! |
📚 Documentation Check Results📦
|
Clippy Allow Annotation ReportComparing clippy allow annotations between branches:
Summary by Rule
Annotation Counts by File
Annotation Stats by Crate
About This ReportThis report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality. |
🔒 Cargo Deny Results📦
|
9042d85 to
6743d39
Compare
0d19b82 to
ca34406
Compare
ca34406 to
800823d
Compare
VianneyRuhlmann
left a comment
There was a problem hiding this comment.
The change in shutdown_worker really needs to be discussed further as it can negatively impact shutdown time. Also a lot of comment are very verbose and at wasm specific explanation on public methods doc that shouldn't be cluttered with implementation details.
We can always have the previous native implementation as is in a |
# What? Client-side stats span concentrator, stats exporter, and all surrounding state management is now compiled and active on `wasm32` targets. # Why? Previously, most of the stats code was gated behind `#[cfg(not(target_arch = "wasm32"))]`, so wasm builds silently skipped stats computation. As we expand wasm support, CSS should work the same as on native. # How? The root blocker was `std::time::SystemTime`, which panics on `wasm32-unknown-unknown`. Replacing it with `web_time::SystemTime` (which delegates to `Date.now()` in a browser/WASI context) unblocks compilation. Once that was fixed, the `cfg` guards on stats functions, structs, and module re-exports were no longer needed and were removed. ## Additional Notes `Duration` is left as `std::time::Duration` — it's purely arithmetic and has no platform dependency. Only `SystemTime`/`UNIX_EPOCH` needed to be swapped.
What?
Port the telemetry stack (
libdd-telemetry,libdd-data-pipeline) to compile and run onwasm32-unknown-unknown.TelemetryWorker,TelemetryWorkerHandle, andTelemetryClientbecome generic over a capability bundleC: HttpClientCapability + SleepCapability; native call sites pin toNativeCapabilities.Why?
Telemetry was previously hard-gated behind
#[cfg(not(target_arch = "wasm32"))]and was a no-op on that target for theTraceExporter.How?
tokio::timecall (sleep, timeout) is replaced by atokio::select!race against<C as SleepCapability>::new().sleep(…), which resolves tosetTimeouton wasm.std::timereplaced byweb-time(Performance.now()/Date.now()on wasm, re-exportsstd::timeon native).tokio::sync::Notify-based async path alongside the existing nativeCondvarsync path.MockClient/file-endpoint logic inhttp_client.rsis deleted and ported toNativeCapabilitiesinlibdd-capabilities-impl.Additional Notes
TelemetryClientBuilder::buildnow returnsResult(was panicking on missing fields) — Rust API break.TelemetryClient::startis now sync viatry_send_msg— Rust API break.typealias pinned toNativeCapabilities.