diff --git a/pageserver/src/config.rs b/pageserver/src/config.rs index 7e773f56b3..62f5b009f7 100644 --- a/pageserver/src/config.rs +++ b/pageserver/src/config.rs @@ -544,6 +544,23 @@ impl PageServerConf { ratio.numerator, ratio.denominator ) ); + + let url = Url::parse(&tracing_config.export_config.endpoint) + .map_err(anyhow::Error::msg) + .with_context(|| { + format!( + "tracing endpoint URL is invalid : {}", + tracing_config.export_config.endpoint + ) + })?; + + ensure!( + url.scheme() == "http" || url.scheme() == "https", + format!( + "tracing endpoint URL must start with http:// or https://: {}", + tracing_config.export_config.endpoint + ) + ); } IndexEntry::validate_checkpoint_distance(conf.default_tenant_conf.checkpoint_distance) @@ -660,4 +677,25 @@ mod tests { PageServerConf::parse_and_validate(NodeId(0), config_toml, &workdir) .expect("parse_and_validate"); } + + #[test] + fn test_config_tracing_endpoint_is_invalid() { + let input = r#" + control_plane_api = "http://localhost:6666" + + [tracing] + + sampling_ratio = { numerator = 1, denominator = 0 } + + [tracing.export_config] + endpoint = "localhost:4317" + protocol = "http-binary" + timeout = "1ms" + "#; + let config_toml = toml_edit::de::from_str::(input) + .expect("config has valid fields"); + let workdir = Utf8PathBuf::from("/nonexistent"); + PageServerConf::parse_and_validate(NodeId(0), config_toml, &workdir) + .expect_err("parse_and_validate should fail for endpoint without scheme"); + } }