Skip to content

Commit f2ce897

Browse files
committed
fix(tracing): propagate span context
The tracing span context set in consumers of the `TokioExecutor` was sometimes lost (if the task was run in a different thread). This adds a call to `in_current_span()` to preserve it.
1 parent 46826ea commit f2ce897

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ service = ["dep:tower-service"]
6969
http1 = ["hyper/http1"]
7070
http2 = ["hyper/http2"]
7171

72-
tokio = ["dep:tokio", "tokio/net", "tokio/rt", "tokio/time"]
72+
tokio = ["dep:tokio", "tokio/net", "tokio/rt", "tokio/time", "dep:tracing"]
7373

7474
# internal features used in CI
7575
__internal_happy_eyeballs_tests = []

src/rt/tokio.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::{
99

1010
use hyper::rt::{Executor, Sleep, Timer};
1111
use pin_project_lite::pin_project;
12+
use tracing::instrument::Instrument;
1213

1314
/// Future executor that utilises `tokio` threads.
1415
#[non_exhaustive]
@@ -49,7 +50,7 @@ where
4950
Fut::Output: Send + 'static,
5051
{
5152
fn execute(&self, fut: Fut) {
52-
tokio::spawn(fut);
53+
tokio::spawn(fut.in_current_span());
5354
}
5455
}
5556

0 commit comments

Comments
 (0)