preliminary tracing for tachys

This commit is contained in:
Greg Johnston 2024-05-11 16:31:04 -04:00
parent 2788d93e96
commit 5bc97654dc
3 changed files with 13 additions and 0 deletions

View file

@ -83,6 +83,7 @@ miniserde = ["leptos_reactive/miniserde"]
rkyv = ["leptos_reactive/rkyv", "server_fn/rkyv"]
tracing = [
"reactive_graph/tracing",
"tachys/tracing"
] #, "leptos_macro/tracing", "leptos_dom/tracing"]
nonce = ["base64", "leptos_dom/nonce", "rand"]
spin = ["leptos_reactive/spin", "leptos-spin-macro"]

View file

@ -155,6 +155,7 @@ send_wrapper = "0.6"
linear-map = "1.2.0"
sledgehammer_bindgen = { version = "0.4", features = ["web"], optional = true }
sledgehammer_utils = { version = "0.2", optional = true }
tracing = { version = "0.1", optional = true }
[dev-dependencies]
tokio-test = "0.4"
@ -172,3 +173,4 @@ nightly = ["reactive_graph/nightly"]
testing = ["dep:slotmap"]
reactive_graph = ["dep:reactive_graph"]
sledgehammer = ["dep:sledgehammer_bindgen", "dep:sledgehammer_utils"]
tracing = ["dep:tracing"]

View file

@ -166,7 +166,17 @@ where
}
let mut cb = self.cb.take();
#[cfg(feature = "tracing")]
let span = tracing::Span::current();
let cb = Box::new(move |ev: R::Event| {
#[cfg(all(debug_assertions, feature = "reactive_graph"))]
let _rx_guard =
reactive_graph::diagnostics::SpecialNonReactiveZone::enter();
#[cfg(feature = "tracing")]
let _tracing_guard = span.enter();
let ev = E::EventType::from(ev);
cb.invoke(ev);
}) as Box<dyn FnMut(R::Event)>;