Skip to content

Commit b90ff7d

Browse files
authored
feat(rt): add tracing feature that will propagate span context in TokioExecutor (#166)
1 parent 46826ea commit b90ff7d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ full = [
5555
"http1",
5656
"http2",
5757
"tokio",
58+
"tracing",
5859
]
5960

6061
client = ["hyper/client", "dep:tracing", "dep:futures-channel", "dep:tower-service"]
@@ -71,6 +72,8 @@ http2 = ["hyper/http2"]
7172

7273
tokio = ["dep:tokio", "tokio/net", "tokio/rt", "tokio/time"]
7374

75+
tracing = ["dep:tracing"]
76+
7477
# internal features used in CI
7578
__internal_happy_eyeballs_tests = []
7679

src/rt/tokio.rs

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ use std::{
1010
use hyper::rt::{Executor, Sleep, Timer};
1111
use pin_project_lite::pin_project;
1212

13+
#[cfg(feature = "tracing")]
14+
use tracing::instrument::Instrument;
15+
1316
/// Future executor that utilises `tokio` threads.
1417
#[non_exhaustive]
1518
#[derive(Default, Debug, Clone)]
@@ -49,6 +52,10 @@ where
4952
Fut::Output: Send + 'static,
5053
{
5154
fn execute(&self, fut: Fut) {
55+
#[cfg(feature = "tracing")]
56+
tokio::spawn(fut.in_current_span());
57+
58+
#[cfg(not(feature = "tracing"))]
5259
tokio::spawn(fut);
5360
}
5461
}

0 commit comments

Comments
 (0)