about summary refs log tree commit diff
path: root/tvix/tracing/src/lib.rs
diff options
context:
space:
mode:
authorSimon Hauser <simon.hauser@helsinki-systems.de>2024-06-14T09·59+0200
committerclbot <clbot@tvl.fyi>2024-06-14T10·18+0000
commita857a2b978379ff0df66319a1eb6e1c1933cf11e (patch)
tree9a9b7c1c7027fecd7a6d86d609759d5faad6bc26 /tvix/tracing/src/lib.rs
parentfa7ed39bf480fd50c488ce54daad7322ced73aab (diff)
feat(tvix/tracing): apply EnvFilter to all layers r/8272
Currently we apply the EnvFilter only to the stderr output writer.
This didn't affect any other layer, like the otlp layer, causing spans
from `h2`, `tokio_util` or other third party crate dependencies to be
always sent out via OTLP.

This changes that behaviour, applying EnvFilter to all exports, leading
to a lot less spans being exported.

Change-Id: I9f3a7233e9d0aeaa81fe08914579f0b3c80d134e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11813
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Autosubmit: Simon Hauser <simon.hauser@helsinki-systems.de>
Diffstat (limited to 'tvix/tracing/src/lib.rs')
-rw-r--r--tvix/tracing/src/lib.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/tvix/tracing/src/lib.rs b/tvix/tracing/src/lib.rs
index 312c9a5a9a62..9cfe5afa52d2 100644
--- a/tvix/tracing/src/lib.rs
+++ b/tvix/tracing/src/lib.rs
@@ -125,7 +125,8 @@ impl Default for TracingBuilder {
 }
 
 impl TracingBuilder {
-    /// Set the log level of the stderr writer, RUST_LOG still has a higher priority over this
+    /// Set the log level for all layers: stderr und otlp if configured. RUST_LOG still has a
+    /// higher priority over this value.
     pub fn level(mut self, level: Level) -> TracingBuilder {
         self.level = level;
         self
@@ -139,8 +140,9 @@ impl TracingBuilder {
     }
 
     /// This will setup tracing based on the configuration passed in.
-    /// It will setup a stderr writer with the provided log level as filter (RUST_LOG still has a
-    /// higher priority over the configured value)
+    /// 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).
+    /// The EnvFilter will be applied to all configured layers, also otlp.
     ///
     /// It will also configure otlp if the feature is enabled and a service_name was provided. It
     /// will then correctly setup a channel which is later used for flushing the provider.
@@ -149,15 +151,15 @@ impl TracingBuilder {
         let indicatif_layer = IndicatifLayer::new().with_progress_style(PB_SPINNER_STYLE.clone());
         let subscriber = tracing_subscriber::registry()
             .with(
+                EnvFilter::builder()
+                    .with_default_directive(self.level.into())
+                    .from_env()
+                    .expect("invalid RUST_LOG"),
+            )
+            .with(
                 tracing_subscriber::fmt::Layer::new()
                     .with_writer(indicatif_layer.get_stderr_writer())
-                    .compact()
-                    .with_filter(
-                        EnvFilter::builder()
-                            .with_default_directive(self.level.into())
-                            .from_env()
-                            .expect("invalid RUST_LOG"),
-                    ),
+                    .compact(),
             )
             .with(indicatif_layer.with_filter(
                 // only show progress for spans with indicatif.pb_show field being set