runtime: add tracing span for block_on futures (#4094)

This commit is contained in:
Sean McArthur 2021-09-09 08:58:21 -07:00 committed by GitHub
parent 7e51b44a20
commit 6ebd0575e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -296,7 +296,11 @@ impl Handle {
/// [`tokio::fs`]: crate::fs
/// [`tokio::net`]: crate::net
/// [`tokio::time`]: crate::time
#[cfg_attr(tokio_track_caller, track_caller)]
pub fn block_on<F: Future>(&self, future: F) -> F::Output {
#[cfg(all(tokio_unstable, feature = "tracing"))]
let future = crate::util::trace::task(future, "block_on", None);
// Enter the **runtime** context. This configures spawning, the current I/O driver, ...
let _rt_enter = self.enter();

View File

@ -450,7 +450,11 @@ cfg_rt! {
/// ```
///
/// [handle]: fn@Handle::block_on
#[cfg_attr(tokio_track_caller, track_caller)]
pub fn block_on<F: Future>(&self, future: F) -> F::Output {
#[cfg(all(tokio_unstable, feature = "tracing"))]
let future = crate::util::trace::task(future, "block_on", None);
let _enter = self.enter();
match &self.kind {