From 4223d8a36f909259f195ccbc31055979a05f0fda Mon Sep 17 00:00:00 2001 From: asonix Date: Tue, 12 Dec 2023 17:43:10 -0600 Subject: [PATCH] Add span to spawned prune task --- src/queue/cleanup.rs | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/queue/cleanup.rs b/src/queue/cleanup.rs index cf4dc40..6fccf9b 100644 --- a/src/queue/cleanup.rs +++ b/src/queue/cleanup.rs @@ -7,6 +7,7 @@ use crate::{ }; use futures_util::TryStreamExt; use reqwest_middleware::ClientWithMiddleware; +use tracing::Instrument; pub(super) fn perform<'a, R, S>( repo: &'a R, @@ -198,28 +199,34 @@ where let repo = repo.clone(); let store = store.clone(); - let res = actix_rt::spawn(async move { - let mut count = count; + let current_span = tracing::Span::current(); + let span = tracing::debug_span!(parent: current_span, "ensure details"); - if let Some(ident) = repo.identifier(hash.clone()).await? { - match store.len(&ident).await { - Err(e) if e.is_not_found() => { - super::cleanup_hash(&repo, hash).await?; + let res = actix_rt::spawn( + async move { + let mut count = count; - count += 1; + if let Some(ident) = repo.identifier(hash.clone()).await? { + match store.len(&ident).await { + Err(e) if e.is_not_found() => { + super::cleanup_hash(&repo, hash).await?; - repo.set( - "prune-missing-queued", - Vec::from(count.to_be_bytes()).into(), - ) - .await?; + count += 1; + + repo.set( + "prune-missing-queued", + Vec::from(count.to_be_bytes()).into(), + ) + .await?; + } + _ => (), } - _ => (), } - } - Ok(count) as Result - }) + Ok(count) as Result + } + .instrument(span), + ) .await; match res {