Add Prometheus /metrics HTTP endpoint

Wire up unused metrics_port/metrics_whitelist config into working
HTTP server exposing proxy stats in Prometheus text format.
This commit is contained in:
Mikhail
2026-02-17 01:11:01 +03:00
parent 9b9c11e7ab
commit a1db082ec0
6 changed files with 217 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ mod config;
mod crypto;
mod error;
mod ip_tracker;
mod metrics;
mod protocol;
mod proxy;
mod stats;
@@ -707,6 +708,14 @@ match crate::transport::middle_proxy::fetch_proxy_secret(proxy_secret_path).awai
.reload(runtime_filter)
.expect("Failed to switch log filter");
if let Some(port) = config.server.metrics_port {
let stats = stats.clone();
let whitelist = config.server.metrics_whitelist.clone();
tokio::spawn(async move {
metrics::serve(port, stats, whitelist).await;
});
}
for listener in listeners {
let config = config.clone();
let stats = stats.clone();