DioxusLabs / DioxusLabs/dioxus

Tokio / OTEL Trace continuation / Propagation across suspense boundaries

Open
#5,304 0 comments 0 reactions 0 assignees View on GitHub
enhancement fullstack
Dominant language
Rust
Stars
39.1k
Forks
1.9k
Avg merge
4d 10h
Merged PRs (30d)
4

Description

## Feature Request

Hopefully it is not a setup issue on my side. ~~Claude tells me it isn't~~ I was trying to setup tracing on my project and noticed the traces do not seem to propagate to inside the server actions, during SSR.
I dunno if this is related to the suspense boundary... to the use_action hook... but given the following example, (in the context of a custom Axum router setup with `.layer(TraceLayer::new_for_http())` and a working tracing subscriber setup)
```rust
#[component]
pub fn ComponentThatSuspends() -> Element {
let stuff = use_loader(|| async { get_value().await });
let mut do_stuff = use_action(|| async { get_value().await });
rsx! {
div { "Stuff is {stuff}"}
button { onclick: move |_| do_stuff.call(), "click me" }
}
}

#[get("/api/stuff", db: crate::Connection)]
async fn get_value() -> Result> {
tracing::info!("Fetching events..."); // <------- This log message here
// [...]
}
```

The highlighted message:
1. Do not have a trace ID from tower-http::TraceLayer during SSR
- does have a TRACE level trace.id from dixous: VirtualDom::rebuild which is too verbose and does not provide the level of grouping per route as I'd like.
1. Although the highlighted message does not have the trace.id of `tower-http::TraceLayer` it does exist and is just "empty" with no correlation to dioxus traces... e.g. `VirtualDom::rebuild`
1. `tower-http::TraceLayer` trace id does got preserved have when called part of a normal endpoint execution (e.g. from the button)

## Implement Suggestion

I'd imagine this is a question of just adding some continuation / with-context code? I dunno if maybe dioxus spawns threads manually outside of tokio to do suspense... then if or how context needs to be propagated manually to these threads I have no idea...

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.