Add #[track_caller] to all spawns so that tokio-console works (if enabled)

This commit is contained in:
Igor Katson 2024-08-29 01:14:30 +01:00
parent edba359400
commit d6b1c47d45
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
4 changed files with 5 additions and 0 deletions

View file

@ -12,6 +12,7 @@ impl std::fmt::Display for CancelledError {
}
/// Spawns a future with tracing instrumentation.
#[track_caller]
pub fn spawn(
span: tracing::Span,
fut: impl std::future::Future<Output = anyhow::Result<()>> + Send + 'static,
@ -49,6 +50,7 @@ pub fn spawn(
tokio::task::spawn(fut)
}
#[track_caller]
pub fn spawn_with_cancel(
span: tracing::Span,
cancellation_token: CancellationToken,