use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Default, Deserialize, schemars::JsonSchema, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Observability {
#[serde(default)]
pub admin_addr: Option<String>,
#[serde(default)]
pub access_log: bool,
#[serde(default)]
pub otlp_endpoint: Option<String>,
}
#[cfg(test)]
mod tests {
use crate::manifest::Manifest;
#[test]
fn observability_defaults_off_and_parses_when_present() {
let bare = Manifest::from_toml("").unwrap();
assert_eq!(bare.observability.admin_addr, None);
assert!(!bare.observability.access_log);
assert_eq!(bare.observability.otlp_endpoint, None);
let m = Manifest::from_toml(
r#"
[observability]
admin_addr = "127.0.0.1:9090"
access_log = true
otlp_endpoint = "http://localhost:4318"
"#,
)
.unwrap();
assert_eq!(
m.observability.admin_addr.as_deref(),
Some("127.0.0.1:9090")
);
assert!(m.observability.access_log);
assert_eq!(
m.observability.otlp_endpoint.as_deref(),
Some("http://localhost:4318")
);
}
#[test]
fn observability_is_not_part_of_the_content_hash() {
let without = Manifest::from_toml("").unwrap();
let with = Manifest::from_toml(
r#"
[observability]
admin_addr = "127.0.0.1:9090"
access_log = true
otlp_endpoint = "http://localhost:4318"
"#,
)
.unwrap();
assert_eq!(
without.content_hash().unwrap(),
with.content_hash().unwrap(),
"observability config must not affect the semantic content hash"
);
}
}