timeout-tracing 0.1.2

Returns stack and span trace when the future hits a timeout
Documentation
2025-07-28T10:22:31.404876Z  INFO tracing_timeout::tests: got timeout
1 traces:
async trace #0:
   0: tracing_timeout::tests::sqlx::exec_query
           with sql="select pg_sleep(2)"
             at src/tests/sqlx.rs:45
   1: tracing_timeout::tests::sqlx::do_sqlx
             at src/tests/sqlx.rs:36
stack trace #0:
   0: tracing_timeout::trace::Trace::capture
             at ./src/trace.rs:16:26
   1: tracing_timeout::waker::TracingTimeoutWaker::raw_clone
             at ./src/waker.rs:53:21
   2: <core::task::wake::Waker as core::clone::Clone>::clone
             at /home/dvk/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/task/wake.rs:596:29
   3: <core::task::wake::Waker as core::clone::Clone>::clone_from
             at /home/dvk/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/task/wake.rs:639:28
   4: tokio::runtime::io::scheduled_io::ScheduledIo::poll_readiness
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/io/scheduled_io.rs:326:32
   5: tokio::runtime::io::registration::Registration::poll_ready
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/io/registration.rs:152:25
   6: tokio::runtime::io::registration::Registration::poll_read_ready
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/io/registration.rs:110:9
   7: tokio::net::tcp::stream::TcpStream::poll_read_ready
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/net/tcp/stream.rs:555:9
   8: sqlx_core::rt::rt_tokio::socket::<impl sqlx_core::net::socket::Socket for tokio::net::tcp::stream::TcpStream>::poll_read_ready
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sqlx-core-0.8.6/src/rt/rt_tokio/socket.rs:22:9
   9: <alloc::boxed::Box<S> as sqlx_core::net::socket::Socket>::poll_read_ready
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sqlx-core-0.8.6/src/net/socket/mod.rs:171:9
  10: <sqlx_core::net::socket::Read<S,B> as core::future::future::Future>::poll
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sqlx-core-0.8.6/src/net/socket/mod.rs:78:28
  11: sqlx_core::net::socket::buffered::ReadBuffer::read::{{closure}}
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sqlx-core-0.8.6/src/net/socket/buffered.rs:284:57
  12: sqlx_core::net::socket::buffered::BufferedSocket<S>::try_read::{{closure}}
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sqlx-core-0.8.6/src/net/socket/buffered.rs:79:60
  13: sqlx_postgres::connection::stream::PgStream::recv_unchecked::{{closure}}
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sqlx-postgres-0.8.6/src/connection/stream.rs:118:14
  14: sqlx_postgres::connection::stream::PgStream::recv::{{closure}}
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sqlx-postgres-0.8.6/src/connection/stream.rs:125:49
  15: sqlx_postgres::connection::executor::<impl sqlx_postgres::connection::PgConnection>::run::{{closure}}::{{closure}}::{{closure}}
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sqlx-postgres-0.8.6/src/connection/executor.rs:296:56
  16: <tracing::instrument::Instrumented<T> as core::future::future::Future>::poll
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.41/src/instrument.rs:321:9
  17: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /home/dvk/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/future.rs:124:9
  18: <futures_util::future::future::fuse::Fuse<Fut> as core::future::future::Future>::poll
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/future/future/fuse.rs:84:26
  19: futures_util::future::future::FutureExt::poll_unpin
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/future/future/mod.rs:558:9
  20: <sqlx_core::ext::async_stream::TryAsyncStream<T> as futures_core::stream::Stream>::poll_next
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sqlx-core-0.8.6/src/ext/async_stream.rs:106:15
  21: <core::pin::Pin<P> as futures_core::stream::Stream>::poll_next
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-core-0.3.31/src/stream.rs:130:9
  22: <S as futures_core::stream::TryStream>::try_poll_next
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-core-0.3.31/src/stream.rs:206:9
  23: futures_util::stream::try_stream::TryStreamExt::try_poll_next_unpin
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/stream/try_stream/mod.rs:1131:9
  24: <futures_util::stream::try_stream::try_next::TryNext<St> as core::future::future::Future>::poll
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/stream/try_stream/try_next.rs:32:9
  25: sqlx_postgres::connection::executor::<impl sqlx_core::executor::Executor for &mut sqlx_postgres::connection::PgConnection>::fetch_many::{{closure}}::{{closure}}
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sqlx-postgres-0.8.6/src/connection/executor.rs:404:46
  26: <tracing::instrument::Instrumented<T> as core::future::future::Future>::poll
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.41/src/instrument.rs:321:9
  27: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /home/dvk/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/future.rs:124:9
  28: <futures_util::future::future::fuse::Fuse<Fut> as core::future::future::Future>::poll
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/future/future/fuse.rs:84:26
  29: futures_util::future::future::FutureExt::poll_unpin
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/future/future/mod.rs:558:9
  30: <sqlx_core::ext::async_stream::TryAsyncStream<T> as futures_core::stream::Stream>::poll_next
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sqlx-core-0.8.6/src/ext/async_stream.rs:106:15
  31: <core::pin::Pin<P> as futures_core::stream::Stream>::poll_next
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-core-0.3.31/src/stream.rs:130:9
  32: <futures_util::stream::stream::map::Map<St,F> as futures_core::stream::Stream>::poll_next
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/stream/stream/map.rs:58:26
  33: <core::pin::Pin<P> as futures_core::stream::Stream>::poll_next
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-core-0.3.31/src/stream.rs:130:9
  34: <S as futures_core::stream::TryStream>::try_poll_next
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-core-0.3.31/src/stream.rs:206:9
  35: <futures_util::stream::try_stream::try_filter_map::TryFilterMap<St,Fut,F> as futures_core::stream::Stream>::poll_next
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/stream/try_stream/try_filter_map.rs:76:47
  36: <core::pin::Pin<P> as futures_core::stream::Stream>::poll_next
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-core-0.3.31/src/stream.rs:130:9
  37: <S as futures_core::stream::TryStream>::try_poll_next
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-core-0.3.31/src/stream.rs:206:9
  38: <futures_util::stream::try_stream::try_collect::TryCollect<St,C> as core::future::future::Future>::poll
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/stream/try_stream/try_collect.rs:46:26
  39: sqlx_core::query_as::QueryAs<DB,O,A>::fetch_all::{{closure}}
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/sqlx-core-0.8.6/src/query_as.rs:145:44
  40: tracing_timeout::tests::sqlx::exec_query::{{closure}}::{{closure}}
             at ./src/tests/sqlx.rs:47:65
  41: <tracing::instrument::Instrumented<T> as core::future::future::Future>::poll
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.41/src/instrument.rs:321:9
  42: tracing_timeout::tests::sqlx::exec_query::{{closure}}
             at ./src/tests/sqlx.rs:45:1
  43: tracing_timeout::tests::sqlx::do_sqlx::{{closure}}::{{closure}}
             at ./src/tests/sqlx.rs:42:49
  44: <tracing::instrument::Instrumented<T> as core::future::future::Future>::poll
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.41/src/instrument.rs:321:9
  45: tracing_timeout::tests::sqlx::do_sqlx::{{closure}}
             at ./src/tests/sqlx.rs:36:1
  46: <tracing_timeout::TimeoutFuture<Fut> as core::future::future::Future>::poll
             at ./src/lib.rs:56:23
  47: tracing_timeout::tests::run_with_tracing::{{closure}}
             at ./src/tests/mod.rs:49:46
  48: tracing_timeout::tests::sqlx::with_sqlx::{{closure}}::{{closure}}
             at ./src/tests/sqlx.rs:12:83
  49: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /home/dvk/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/future.rs:124:9
  50: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /home/dvk/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/future.rs:124:9
  51: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::{{closure}}
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/scheduler/current_thread/mod.rs:742:54
  52: tokio::task::coop::with_budget
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/task/coop/mod.rs:167:5
  53: tokio::task::coop::budget
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/task/coop/mod.rs:133:5
  54: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/scheduler/current_thread/mod.rs:742:25
  55: tokio::runtime::scheduler::current_thread::Context::enter
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/scheduler/current_thread/mod.rs:432:19
  56: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/scheduler/current_thread/mod.rs:741:36
  57: tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}}
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/scheduler/current_thread/mod.rs:829:68
  58: tokio::runtime::context::scoped::Scoped<T>::set
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/context/scoped.rs:40:9
  59: tokio::runtime::context::set_scheduler::{{closure}}
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/context.rs:176:26
  60: std::thread::local::LocalKey<T>::try_with
             at /home/dvk/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:315:12
  61: std::thread::local::LocalKey<T>::with
             at /home/dvk/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:279:15
  62: tokio::runtime::context::set_scheduler
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/context.rs:176:9
  63: tokio::runtime::scheduler::current_thread::CoreGuard::enter
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/scheduler/current_thread/mod.rs:829:27
  64: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/scheduler/current_thread/mod.rs:729:19
  65: tokio::runtime::scheduler::current_thread::CurrentThread::block_on::{{closure}}
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/scheduler/current_thread/mod.rs:200:28
  66: tokio::runtime::context::runtime::enter_runtime
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/context/runtime.rs:65:16
  67: tokio::runtime::scheduler::current_thread::CurrentThread::block_on
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/scheduler/current_thread/mod.rs:188:9
  68: tokio::runtime::runtime::Runtime::block_on_inner
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/runtime.rs:356:47
  69: tokio::runtime::runtime::Runtime::block_on
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.46.1/src/runtime/runtime.rs:330:13
  70: tracing_timeout::tests::sqlx::with_sqlx::{{closure}}
             at ./src/tests/sqlx.rs:16:5
  71: core::ops::function::FnOnce::call_once
             at /home/dvk/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
  72: serial_test::serial_code_lock::local_serial_core
             at /home/dvk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/serial_test-3.2.0/src/serial_code_lock.rs:36:5
  73: tracing_timeout::tests::sqlx::with_sqlx
             at ./src/tests/sqlx.rs:10:1
  74: tracing_timeout::tests::sqlx::with_sqlx::{{closure}}
             at ./src/tests/sqlx.rs:10:10
  75: core::ops::function::FnOnce::call_once
             at /home/dvk/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
  76: core::ops::function::FnOnce::call_once
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/core/src/ops/function.rs:250:5
  77: test::__rust_begin_short_backtrace
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/test/src/lib.rs:648:18
  78: test::run_test_in_process::{{closure}}
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/test/src/lib.rs:671:60
  79: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/core/src/panic/unwind_safe.rs:272:9
  80: std::panicking::try::do_call
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/panicking.rs:589:40
  81: std::panicking::try
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/panicking.rs:552:19
  82: std::panic::catch_unwind
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/panic.rs:359:14
  83: test::run_test_in_process
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/test/src/lib.rs:671:27
  84: test::run_test::{{closure}}
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/test/src/lib.rs:592:43
  85: test::run_test::{{closure}}
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/test/src/lib.rs:622:41
  86: std::sys::backtrace::__rust_begin_short_backtrace
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/sys/backtrace.rs:152:18
  87: std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/thread/mod.rs:559:17
  88: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/core/src/panic/unwind_safe.rs:272:9
  89: std::panicking::try::do_call
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/panicking.rs:589:40
  90: std::panicking::try
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/panicking.rs:552:19
  91: std::panic::catch_unwind
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/panic.rs:359:14
  92: std::thread::Builder::spawn_unchecked_::{{closure}}
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/thread/mod.rs:557:30
  93: core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/core/src/ops/function.rs:250:5
  94: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/alloc/src/boxed.rs:1966:9
  95: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/alloc/src/boxed.rs:1966:9
  96: std::sys::pal::unix::thread::Thread::new::thread_start
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/sys/pal/unix/thread.rs:97:17
  97: <unknown>
  98: <unknown>