From 7d92515b1d6da0efb653d3e94b18669fda95bf6e Mon Sep 17 00:00:00 2001 From: Benjamin Lee <benjamin@computer.surgery> Date: Fri, 26 Apr 2024 18:23:02 -0700 Subject: [PATCH] add tracing_flame_filter config option The previous hardcoded filter `trace,h2=off` isn't appropriate in all cases, it's better to have this be configurable. --- src/config/mod.rs | 6 ++++++ src/main.rs | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index b1a138bd5..c842b7706 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -175,6 +175,9 @@ pub(crate) struct Config { #[serde(default)] #[cfg(feature = "perf_measurements")] pub(crate) tracing_flame: bool, + #[serde(default = "default_tracing_flame_filter")] + #[cfg(feature = "perf_measurements")] + pub(crate) tracing_flame_filter: String, #[serde(default)] pub(crate) proxy: ProxyConfig, pub(crate) jwt_secret: Option<String>, @@ -934,6 +937,9 @@ fn default_pusher_idle_timeout() -> u64 { 15 } fn default_max_fetch_prev_events() -> u16 { 100_u16 } +#[cfg(feature = "perf_measurements")] +fn default_tracing_flame_filter() -> String { "trace,h2=off".to_owned() } + fn default_trusted_servers() -> Vec<OwnedServerName> { vec![OwnedServerName::try_from("matrix.org").unwrap()] } fn default_log() -> String { diff --git a/src/main.rs b/src/main.rs index c7de0516d..ef93a5a8a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -617,7 +617,10 @@ fn init_tracing(config: &Config) -> LogLevelReloadHandles { #[cfg(feature = "perf_measurements")] let subscriber = { let flame_layer = if config.tracing_flame { - let flame_filter = EnvFilter::new("trace,h2=off"); + let flame_filter = match EnvFilter::try_new(&config.tracing_flame_filter) { + Ok(flame_filter) => flame_filter, + Err(e) => panic!("tracing_flame_filter config value is invalid: {e}"), + }; // TODO: actually preserve this guard until exit: https://docs.rs/tracing-flame/latest/tracing_flame/struct.FlameLayer.html#dropping-and-flushing let (flame_layer, _guard) = tracing_flame::FlameLayer::with_file("./tracing.folded").unwrap(); -- GitLab