fix: propagate current tracing'span to server function (#4900)
FIX #4896
This commit is contained in:
1 parent
71e01d5be6
commit
6f0c647c5a
1 file changed
+5
-1
@@ -70,6 +70,8 @@ impl ServerFunction {
|
|||||||
.try_into()
|
.try_into()
|
||||||
.expect("MethodFilter only supports standard HTTP methods"),
|
.expect("MethodFilter only supports standard HTTP methods"),
|
||||||
move |state: State<FullstackState>, request: Request| async move {
|
move |state: State<FullstackState>, request: Request| async move {
|
||||||
|
use tracing::Instrument;
|
||||||
|
let current_span = tracing::Span::current();
|
||||||
// Allow !Send futures by running in the render handlers pinned local pool
|
// Allow !Send futures by running in the render handlers pinned local pool
|
||||||
let result = state.rt.spawn_pinned(move || async move {
|
let result = state.rt.spawn_pinned(move || async move {
|
||||||
use dioxus_fullstack_core::FullstackContext;
|
use dioxus_fullstack_core::FullstackContext;
|
||||||
@@ -97,7 +99,9 @@ impl ServerFunction {
|
|||||||
.clone()
|
.clone()
|
||||||
.scope(async move {
|
.scope(async move {
|
||||||
// Run the next middleware / handler inside the server context
|
// Run the next middleware / handler inside the server context
|
||||||
let mut response = handler(State(server_context), request).await;
|
let mut response = handler(State(server_context), request)
|
||||||
|
.instrument(current_span)
|
||||||
|
.await;
|
||||||
|
|
||||||
let server_context = FullstackContext::current().expect(
|
let server_context = FullstackContext::current().expect(
|
||||||
"Server context should be available inside the server context scope",
|
"Server context should be available inside the server context scope",
|
||||||
|
|||||||
Reference in new issue
Block a user