diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /vendor/tokio/src/util/trace.rs | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/tokio/src/util/trace.rs')
-rw-r--r-- | vendor/tokio/src/util/trace.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/vendor/tokio/src/util/trace.rs b/vendor/tokio/src/util/trace.rs new file mode 100644 index 000000000..c51a5a72b --- /dev/null +++ b/vendor/tokio/src/util/trace.rs @@ -0,0 +1,39 @@ +cfg_trace! { + cfg_rt! { + pub(crate) use tracing::instrument::Instrumented; + + #[inline] + #[cfg_attr(tokio_track_caller, track_caller)] + pub(crate) fn task<F>(task: F, kind: &'static str, name: Option<&str>) -> Instrumented<F> { + use tracing::instrument::Instrument; + #[cfg(tokio_track_caller)] + let location = std::panic::Location::caller(); + #[cfg(tokio_track_caller)] + let span = tracing::trace_span!( + target: "tokio::task", + "task", + %kind, + spawn.location = %format_args!("{}:{}:{}", location.file(), location.line(), location.column()), + task.name = %name.unwrap_or_default() + ); + #[cfg(not(tokio_track_caller))] + let span = tracing::trace_span!( + target: "tokio::task", + "task", + %kind, + task.name = %name.unwrap_or_default() + ); + task.instrument(span) + } + } +} + +cfg_not_trace! { + cfg_rt! { + #[inline] + pub(crate) fn task<F>(task: F, _: &'static str, _name: Option<&str>) -> F { + // nop + task + } + } +} |