Skip to content

Commit 4d59b33

Browse files
committed
Remove Prometheus metrics support
OpenTelemetry tracing is sufficient. Drop the metrics and metrics-exporter-prometheus crates, the metrics_bind config field, the PrometheusBuilder listener, and the corresponding docs. Add a regression test ensuring metrics_bind is rejected as unknown.
1 parent a5bff2a commit 4d59b33

5 files changed

Lines changed: 29 additions & 21 deletions

File tree

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,12 @@ Copy `config.example.toml` to `config.toml` and edit it. Key sections:
4141
| `rules[].extension_value` | Value to match in the extension |
4242
| `rules[].allowed_destinations` | List of `host` or `host:port` entries. Port defaults to `443` if omitted. |
4343

44-
**`[observability]`** -- Logging, tracing, and metrics.
44+
**`[observability]`** -- Logging and tracing.
4545

4646
| Field | Required | Description |
4747
|---|---|---|
4848
| `log_level` | yes | `tracing` filter (e.g. `info`, `debug`, `agent_gateway=debug`) |
4949
| `otlp_endpoint` | no | OTLP gRPC endpoint for distributed tracing |
50-
| `metrics_bind` | no | `host:port` for Prometheus metrics scraping |
5150

5251
## Running
5352

config.example.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ client_ca_path = "certs/client-ca.pem"
77
[observability]
88
log_level = "info"
99
otlp_endpoint = "http://localhost:4317"
10-
metrics_bind = "0.0.0.0:9090"
1110

1211
# Custom extension OID to extract from client certs
1312
[policy]

src/config.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ pub struct ServerConfig {
2727
pub struct ObservabilityConfig {
2828
pub log_level: String,
2929
pub otlp_endpoint: Option<String>,
30-
pub metrics_bind: Option<String>,
3130
}
3231

3332
#[derive(Debug, Deserialize)]
@@ -62,11 +61,6 @@ impl Config {
6261
x509_parser::oid_registry::Oid::from_str(&self.policy.client_ext_oid)
6362
.map_err(|e| anyhow::anyhow!("invalid policy.client_ext_oid: {e:?}"))?;
6463

65-
if let Some(ref bind) = self.observability.metrics_bind {
66-
bind.parse::<std::net::SocketAddr>()
67-
.map_err(|e| anyhow::anyhow!("invalid observability.metrics_bind: {e}"))?;
68-
}
69-
7064
for (i, rule) in self.policy.rules.iter().enumerate() {
7165
anyhow::ensure!(
7266
!rule.extension_value.is_empty(),

src/observability.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::net::SocketAddr;
21
use std::sync::OnceLock;
32

43
use anyhow::Context;
@@ -49,17 +48,6 @@ pub fn init(config: &ObservabilityConfig) -> anyhow::Result<()> {
4948
.try_init()
5049
.context("initializing tracing subscriber")?;
5150

52-
if let Some(ref bind) = config.metrics_bind {
53-
let addr: SocketAddr = bind
54-
.parse()
55-
.with_context(|| format!("invalid metrics_bind: {bind}"))?;
56-
57-
metrics_exporter_prometheus::PrometheusBuilder::new()
58-
.with_http_listener(addr)
59-
.install()
60-
.context("installing Prometheus metrics exporter")?;
61-
}
62-
6351
Ok(())
6452
}
6553

tests/integration.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,34 @@ allowed_destinations = ["{dest}"]
365365
assert!(make("[::1]").is_ok());
366366
}
367367

368+
#[test]
369+
fn config_rejects_removed_metrics_bind_field() {
370+
let toml = r#"
371+
[server]
372+
listen_addr = "0.0.0.0:8443"
373+
tls_cert_path = "c.pem"
374+
tls_key_path = "k.pem"
375+
client_ca_path = "ca.pem"
376+
377+
[observability]
378+
log_level = "info"
379+
metrics_bind = "0.0.0.0:9090"
380+
381+
[policy]
382+
client_ext_oid = "1.3.6.1.4.1.57264.1.1"
383+
384+
[[policy.rules]]
385+
extension_value = "x"
386+
allowed_destinations = ["api.example.com"]
387+
"#;
388+
let tmpdir = std::env::temp_dir().join("agent_gw_test_config");
389+
std::fs::create_dir_all(&tmpdir).ok();
390+
let path = tmpdir.join("reject_metrics_bind.toml");
391+
std::fs::write(&path, toml).unwrap();
392+
let result = agent_gateway::config::Config::load(&path);
393+
assert!(result.is_err(), "metrics_bind should be rejected as an unknown field");
394+
}
395+
368396
// ---- Proxy Destination parsing ----
369397

370398
fn parse_dest(authority: &str) -> Result<Destination, String> {

0 commit comments

Comments
 (0)