refactor: Add a few spans for error reporting

This commit is contained in:
Lucas Schwiderski 2022-12-28 13:14:21 +01:00
parent 1c27224221
commit 97b824176f
Signed by: lucas
GPG key ID: AA12679AAA6DF4D8

View file

@ -7,6 +7,7 @@ use color_eyre::{Help, SectionExt};
use futures::StreamExt; use futures::StreamExt;
use sdk::Bundle; use sdk::Bundle;
use tokio::sync::RwLock; use tokio::sync::RwLock;
use tracing::Instrument;
use crate::cmd::util::resolve_bundle_paths; use crate::cmd::util::resolve_bundle_paths;
@ -79,17 +80,19 @@ pub(crate) async fn run(ctx: Arc<RwLock<sdk::Context>>, matches: &ArgMatches) ->
paths paths
.for_each_concurrent(10, |p| async { .for_each_concurrent(10, |p| async {
let span = tracing::info_span!("list bundle");
let ctx = ctx.clone(); let ctx = ctx.clone();
async move { async move {
match Bundle::open(ctx, &p).await { let span = tracing::info_span!("open bundle");
Ok(bundle) => { if let Err(err) = Bundle::open(ctx, &p)
print_bundle_list(bundle, fmt); .instrument(span)
} .await
Err(err) => { .map(|bundle| print_bundle_list(bundle, fmt))
tracing::error!("Failed to open bundle '{}': {:#}", p.display(), err); {
} tracing::error!("Failed to open bundle '{}': {:?}", p.display(), err);
} }
} }
.instrument(span)
.await .await
}) })
.await; .await;