diff --git a/src/layer.rs b/src/layer.rs index 43d2193..8ed2832 100644 --- a/src/layer.rs +++ b/src/layer.rs @@ -7,7 +7,7 @@ use opentelemetry::{ use std::fmt; use std::marker; use std::thread; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"))))] use std::time::Instant; use std::{any::TypeId, borrow::Cow}; use tracing_core::span::{self, Attributes, Id, Record}; @@ -17,7 +17,7 @@ use tracing_log::NormalizeEvent; use tracing_subscriber::layer::Context; use tracing_subscriber::registry::LookupSpan; use tracing_subscriber::Layer; -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use web_time::Instant; const SPAN_NAME_FIELD: &str = "otel.name"; diff --git a/src/lib.rs b/src/lib.rs index 233d0fc..debed0b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -154,12 +154,12 @@ pub struct OtelData { pub(crate) mod time { use std::time::SystemTime; - #[cfg(not(target_arch = "wasm32"))] + #[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"))))] pub(crate) fn now() -> SystemTime { SystemTime::now() } - #[cfg(target_arch = "wasm32")] + #[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] pub(crate) fn now() -> SystemTime { SystemTime::UNIX_EPOCH + std::time::Duration::from_millis(js_sys::Date::now() as u64) }