Skip to content

Commit

Permalink
fix: use env filter properly
Browse files Browse the repository at this point in the history
Apparently if we pass env filter in an array with the other layers
it won't be executed first (to act as a filter). This change fixes
that by explicitly adding it before.
  • Loading branch information
ali-bahjati committed Jul 23, 2024
1 parent 38c45bb commit afb398d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/bin/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ async fn main() -> Result<()> {
.with_ansi(std::io::stderr().is_terminal());

let mut layers = Vec::new();
layers.push(env_filter.boxed());

// Set up OpenTelemetry only if it's configured
if let Some(opentelemetry_config) = &config.opentelemetry {
Expand Down Expand Up @@ -91,7 +90,7 @@ async fn main() -> Result<()> {
layers.push(fmt_layer.json().boxed());
}

tracing_subscriber::registry().with(layers).init();
tracing_subscriber::registry().with(env_filter).with(layers).init();

// Launch the application. If it fails, print the full backtrace and exit. RUST_BACKTRACE
// should be set to 1 for this otherwise it will only print the top-level error.
Expand Down

0 comments on commit afb398d

Please sign in to comment.