about summary refs log tree commit diff
path: root/tvix/tracing/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/tracing/src/lib.rs')
-rw-r--r--tvix/tracing/src/lib.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/tvix/tracing/src/lib.rs b/tvix/tracing/src/lib.rs
index ecf31e1eb031..68a417998a24 100644
--- a/tvix/tracing/src/lib.rs
+++ b/tvix/tracing/src/lib.rs
@@ -114,6 +114,7 @@ impl TracingHandle {
 
 pub struct TracingBuilder {
     level: Level,
+    progess_bar: bool,
 
     #[cfg(feature = "otlp")]
     service_name: Option<&'static str>,
@@ -123,6 +124,7 @@ impl Default for TracingBuilder {
     fn default() -> Self {
         TracingBuilder {
             level: Level::INFO,
+            progess_bar: false,
 
             #[cfg(feature = "otlp")]
             service_name: None,
@@ -145,6 +147,12 @@ impl TracingBuilder {
         self
     }
 
+    /// Enable progress bar layer, default is disabled
+    pub fn enable_progressbar(mut self) -> TracingBuilder {
+        self.progess_bar = true;
+        self
+    }
+
     /// This will setup tracing based on the configuration passed in.
     /// It will setup a stderr writer output layer and a EnvFilter based on the provided log
     /// level (RUST_LOG still has a higher priority over the configured value).
@@ -167,10 +175,12 @@ impl TracingBuilder {
                     .with_writer(indicatif_layer.get_stderr_writer())
                     .compact(),
             )
-            .with(indicatif_layer.with_filter(
-                // only show progress for spans with indicatif.pb_show field being set
-                IndicatifFilter::new(false),
-            ));
+            .with((self.progess_bar).then(|| {
+                indicatif_layer.with_filter(
+                    // only show progress for spans with indicatif.pb_show field being set
+                    IndicatifFilter::new(false),
+                )
+            }));
 
         // Setup otlp if a service_name is configured
         #[cfg(feature = "otlp")]