diff --git a/opentelemetry-api/src/lib.rs b/opentelemetry-api/src/lib.rs index 2a07884bc8..e19182726f 100644 --- a/opentelemetry-api/src/lib.rs +++ b/opentelemetry-api/src/lib.rs @@ -73,13 +73,16 @@ pub mod time { use std::time::SystemTime; #[doc(hidden)] - #[cfg(not(target_arch = "wasm32"))] + #[cfg(any( + not(target_arch = "wasm32"), + all(target_arch = "wasm32", target_os = "wasi") + ))] pub fn now() -> SystemTime { SystemTime::now() } #[doc(hidden)] - #[cfg(target_arch = "wasm32")] + #[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] pub fn now() -> SystemTime { SystemTime::UNIX_EPOCH + std::time::Duration::from_millis(js_sys::Date::now() as u64) }