From 7b21cd1124120b51eff9fe48960eecf554e2c83a Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Tue, 1 Mar 2022 10:35:10 +0000 Subject: [PATCH] Go back to the custom tracing subscriber, adding a filter for spammy dependencies. #11 --- src/main.rs | 6 +----- src/tracing_span_tree.rs | 6 +++++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index bdcf5d5..569e6ee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,11 +18,7 @@ const DEFAULT_CASES_PER_MSOA: usize = 5; #[tokio::main] async fn main() -> Result<()> { - let subscriber = tracing_subscriber::FmtSubscriber::builder() - .with_max_level(tracing::Level::DEBUG) - .finish(); - tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed"); - //ramp::tracing_span_tree::SpanTree::new().enable(); + ramp::tracing_span_tree::SpanTree::new().enable(); let args = Args::parse(); diff --git a/src/tracing_span_tree.rs b/src/tracing_span_tree.rs index 2574dc0..6b4451e 100644 --- a/src/tracing_span_tree.rs +++ b/src/tracing_span_tree.rs @@ -22,7 +22,11 @@ impl SpanTree { /// Set as a global subscriber pub fn enable(self) { - let subscriber = Registry::default().with(self); + // Ignore everything except our own code. hyper and reqwest are very spammy. + // TODO Filter more carefully -- anything >= INFO from other crates is probably fine + let subscriber = Registry::default().with(self.with_filter( + tracing_subscriber::filter::filter_fn(|metadata| metadata.target().starts_with("ramp")), + )); tracing::subscriber::set_global_default(subscriber) .unwrap_or_else(|_| debug!("Global subscriber is already set")); }