about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSimon Hauser <simon.hauser@helsinki-systems.de>2024-06-19T09·30+0200
committerSimon Hauser <simon.hauser@helsinki-systems.de>2024-06-20T10·28+0000
commitbd8d74a3eea461268c3ee089e001022c7d151c14 (patch)
tree2f32aad8ae405292eca71658f0e0a797a8ad47ef
parent1446e3be9991291367a2b0cd7daa1d3c0f86e8b7 (diff)
feat(tvix/tracing): optional progressbar r/8297
Disable the progressbar on default and provide a interface for
optionally enabling the progressbar.

Change-Id: I0e31b1957e80cf64a8dcf65c6ceb3713975b8220
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11861
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Autosubmit: Simon Hauser <simon.hauser@helsinki-systems.de>
-rw-r--r--tvix/build/src/bin/tvix-build.rs4
-rw-r--r--tvix/cli/src/main.rs1
-rw-r--r--tvix/store/src/bin/tvix-store.rs2
-rw-r--r--tvix/tracing/src/lib.rs18
4 files changed, 19 insertions, 6 deletions
diff --git a/tvix/build/src/bin/tvix-build.rs b/tvix/build/src/bin/tvix-build.rs
index c96145ebb479..26f2044af3fd 100644
--- a/tvix/build/src/bin/tvix-build.rs
+++ b/tvix/build/src/bin/tvix-build.rs
@@ -54,7 +54,9 @@ enum Commands {
 async fn main() -> Result<(), Box<dyn std::error::Error>> {
     let cli = Cli::parse();
 
-    let _ = tvix_tracing::TracingBuilder::default().level(cli.log_level);
+    let _ = tvix_tracing::TracingBuilder::default()
+        .level(cli.log_level)
+        .enable_progressbar();
 
     match cli.command {
         Commands::Daemon {
diff --git a/tvix/cli/src/main.rs b/tvix/cli/src/main.rs
index 3ec45bc37250..686513b77cc4 100644
--- a/tvix/cli/src/main.rs
+++ b/tvix/cli/src/main.rs
@@ -281,6 +281,7 @@ fn main() {
 
     let _ = tvix_tracing::TracingBuilder::default()
         .level(args.log_level)
+        .enable_progressbar()
         .build()
         .expect("unable to set up tracing subscriber");
     let tokio_runtime = tokio::runtime::Runtime::new().expect("failed to setup tokio runtime");
diff --git a/tvix/store/src/bin/tvix-store.rs b/tvix/store/src/bin/tvix-store.rs
index 2a039fbebed7..30ebca004873 100644
--- a/tvix/store/src/bin/tvix-store.rs
+++ b/tvix/store/src/bin/tvix-store.rs
@@ -506,7 +506,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
 
     let tracing_handle = {
         let mut builder = tvix_tracing::TracingBuilder::default();
-        builder = builder.level(cli.log_level);
+        builder = builder.level(cli.log_level).enable_progressbar();
         #[cfg(feature = "otlp")]
         {
             if cli.otlp {
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")]