Skip to content

Commit

Permalink
fix: Don't discard spans if they match the provided log filter in pavexc
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeMathWalker committed Sep 8, 2024
1 parent 8a47ddd commit 4ab1e70
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 6 additions & 4 deletions libs/pavexc_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use tracing_subscriber::EnvFilter;

const INTROSPECTION_HEADING: &str = "Introspection";

#[derive(Parser)]
#[derive(Parser, Debug)]
#[clap(author, version = VERSION, about, long_about = None)]
struct Cli {
#[clap(long, env = "PAVEXC_COLOR", default_value_t = Color::Auto)]
Expand Down Expand Up @@ -104,7 +104,7 @@ impl FromStr for Color {
}
}

#[derive(Subcommand)]
#[derive(Subcommand, Debug)]
enum Commands {
/// Generate a server SDK crate according to an application blueprint.
Generate {
Expand Down Expand Up @@ -151,7 +151,7 @@ enum Commands {
},
}

#[derive(Subcommand)]
#[derive(Subcommand, Debug)]
pub enum SelfCommands {
Setup {
#[clap(long, env = "PAVEXC_DOCS_TOOLCHAIN", default_value = DEFAULT_DOCS_TOOLCHAIN)]
Expand Down Expand Up @@ -254,7 +254,9 @@ fn main() -> Result<ExitCode, Box<dyn std::error::Error>> {
.unwrap();

better_panic::install();
let _guard = init_telemetry(cli.log_filter, cli.color, cli.log, cli.perf_profile);
let _guard = init_telemetry(cli.log_filter.clone(), cli.color, cli.log, cli.perf_profile);

tracing::trace!(cli = ?cli, "`pavexc` CLI options and flags");
match cli.command {
Commands::Generate {
blueprint,
Expand Down
9 changes: 9 additions & 0 deletions libs/pavexc_cli/src/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ where
}
}

if !keep {
// Check if the env filter matches
if let Some(metadata) = ctx.metadata(id) {
keep = <EnvFilter as tracing_subscriber::layer::Filter<S>>::enabled(
&self.base, metadata, &ctx,
);
}
}

if !keep {
let mut visitor = FieldVisitor {
filters: &self.fields,
Expand Down

0 comments on commit 4ab1e70

Please sign in to comment.