OrthoConfig emits structured tracing events for discovery attempts, selected
files, skips, and failures. The library does not install a subscriber; the
binary should do that once during start-up. Add the subscriber with its
environment-filter support:
[dependencies]
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
use ortho_config::{OrthoConfig, OrthoResult};
use serde::Deserialize;
#[derive(Deserialize, OrthoConfig)]
struct Config {
#[ortho_config(default = 8080)]
port: u16,
}
fn main() -> OrthoResult<()> {
tracing_subscriber::fmt()
.with_env_filter("ortho_config=debug")
.with_writer(std::io::stderr)
.try_init()
.ok();
let config = Config::load()?;
println!("port={}", config.port);
Ok(())
}
Do not log configuration values or candidate paths around these events. The crate's own diagnostics avoid path and value fields because configuration locations and values may be sensitive.
Metrics are a low-cost opt-in when the application already has a metrics
recorder:
[dependencies]
ortho_config = { version = "0.9.0", features = ["metrics"] }
The feature emits bounded counters such as discovery attempts, outcomes, and failures. OrthoConfig never installs a recorder, and enabling the feature does nothing visible until the application installs one.