mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
parse configured EnvFilter once
This allows the error handling to be done upfront instead of for each use. In particular, the `toml` error now points to the span of text in the config file where the misconfigured EnvFilter value is. This is much better than the previous error that did not indicate what was actually causing it to happen.
This commit is contained in:
parent
6b819d6f2d
commit
c46eaed0e0
4 changed files with 54 additions and 11 deletions
|
|
@ -82,8 +82,6 @@ pub(crate) enum FoundIn {
|
|||
|
||||
/// Initialize observability
|
||||
pub(crate) fn init(config: &Config) -> Result<Guard, error::Observability> {
|
||||
let config_filter_layer = || EnvFilter::try_new(&config.log);
|
||||
|
||||
let jaeger_layer = config
|
||||
.allow_jaeger
|
||||
.then(|| {
|
||||
|
|
@ -101,7 +99,7 @@ pub(crate) fn init(config: &Config) -> Result<Guard, error::Observability> {
|
|||
let telemetry = tracing_opentelemetry::layer().with_tracer(tracer);
|
||||
|
||||
Ok::<_, error::Observability>(
|
||||
telemetry.with_filter(config_filter_layer()?),
|
||||
telemetry.with_filter(EnvFilter::from(&config.log)),
|
||||
)
|
||||
})
|
||||
.transpose()?;
|
||||
|
|
@ -114,7 +112,7 @@ pub(crate) fn init(config: &Config) -> Result<Guard, error::Observability> {
|
|||
let flame_layer = flame_layer.with_empty_samples(false);
|
||||
|
||||
Ok::<_, error::Observability>((
|
||||
flame_layer.with_filter(config_filter_layer()?),
|
||||
flame_layer.with_filter(EnvFilter::from(&config.log)),
|
||||
guard,
|
||||
))
|
||||
})
|
||||
|
|
@ -122,7 +120,7 @@ pub(crate) fn init(config: &Config) -> Result<Guard, error::Observability> {
|
|||
.unzip();
|
||||
|
||||
let fmt_layer = tracing_subscriber::fmt::Layer::new()
|
||||
.with_filter(config_filter_layer()?);
|
||||
.with_filter(EnvFilter::from(&config.log));
|
||||
|
||||
let subscriber = Registry::default()
|
||||
.with(jaeger_layer)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue