summaryrefslogtreecommitdiffstats
path: root/tokio/src/task
diff options
context:
space:
mode:
Diffstat (limited to 'tokio/src/task')
-rw-r--r--tokio/src/task/blocking.rs13
-rw-r--r--tokio/src/task/local.rs2
-rw-r--r--tokio/src/task/spawn.rs1
3 files changed, 16 insertions, 0 deletions
diff --git a/tokio/src/task/blocking.rs b/tokio/src/task/blocking.rs
index 4dab333e..ed60f4c4 100644
--- a/tokio/src/task/blocking.rs
+++ b/tokio/src/task/blocking.rs
@@ -114,6 +114,19 @@ cfg_blocking! {
F: FnOnce() -> R + Send + 'static,
R: Send + 'static,
{
+ #[cfg(feature = "tracing")]
+ let f = {
+ let span = tracing::trace_span!(
+ target: "tokio::task",
+ "task",
+ kind = %"blocking",
+ function = %std::any::type_name::<F>(),
+ );
+ move || {
+ let _g = span.enter();
+ f()
+ }
+ };
crate::runtime::spawn_blocking(f)
}
}
diff --git a/tokio/src/task/local.rs b/tokio/src/task/local.rs
index 2a3a7e1e..3c409edf 100644
--- a/tokio/src/task/local.rs
+++ b/tokio/src/task/local.rs
@@ -195,6 +195,7 @@ cfg_rt_util! {
F: Future + 'static,
F::Output: 'static,
{
+ let future = crate::util::trace::task(future, "local");
CURRENT.with(|maybe_cx| {
let cx = maybe_cx
.expect("`spawn_local` called from outside of a `task::LocalSet`");
@@ -277,6 +278,7 @@ impl LocalSet {
F: Future + 'static,
F::Output: 'static,
{
+ let future = crate::util::trace::task(future, "local");
let (task, handle) = unsafe { task::joinable_local(future) };
self.context.tasks.borrow_mut().queue.push_back(task);
handle
diff --git a/tokio/src/task/spawn.rs b/tokio/src/task/spawn.rs
index fa5ff13b..d6e77118 100644
--- a/tokio/src/task/spawn.rs
+++ b/tokio/src/task/spawn.rs
@@ -129,6 +129,7 @@ doc_rt_core! {
{
let spawn_handle = runtime::context::spawn_handle()
.expect("must be called from the context of Tokio runtime configured with either `basic_scheduler` or `threaded_scheduler`");
+ let task = crate::util::trace::task(task, "task");
spawn_handle.spawn(task)
}
}