This commit is contained in:
Mateusz Gruszczyński committed 2026-10-15 09:37:47 +02:00
1 parent bbfa8cbc3f
commit 2ccc598b12
49 files changed
+4771 -639

No files matched your search

+138 -13
View File
@@ -1,28 +1,153 @@
// Only configured Web Service IDs and bounded enumerated classes/reasons are labels.
fn render_web_php(snapshot: &crate::config::Snapshot, f: &mut Families) {
use crate::web_server::metrics::PHP_FAILURE_NAMES;
let config = &snapshot.envelope.config;
for service in &config.web_services {
let Some(compiled) = snapshot.web_php_services.get(&service.id) else { continue };
let Some(compiled) = snapshot.web_php_services.get(&service.id) else {
continue;
};
let web = &compiled.web_metrics;
let wl = labels(&[("web_service", service.id.as_str())]);
f.add("rust_proxy_web_server_requests_total", "counter", "Web Server requests completed through response headers, including PHP requests.", &wl, web.requests.load(Ordering::Relaxed));
f.add(
"rust_proxy_web_server_requests_total",
"counter",
"Web Server responses through headers, including PHP.",
&wl,
web.requests.load(Ordering::Relaxed),
);
for (class, count) in [
("2xx", &web.status_2xx), ("3xx", &web.status_3xx),
("4xx", &web.status_4xx), ("5xx", &web.status_5xx),
("2xx", &web.status_2xx),
("3xx", &web.status_3xx),
("4xx", &web.status_4xx),
("5xx", &web.status_5xx),
] {
f.add("rust_proxy_web_server_responses_total", "counter", "Web Server responses by status class.", &format!("{wl},class=\"{class}\""), count.load(Ordering::Relaxed));
f.add(
"rust_proxy_web_server_responses_total",
"counter",
"Web Server response status classes.",
&format!("{wl},class=\"{class}\""),
count.load(Ordering::Relaxed),
);
}
f.add(
"rust_proxy_web_server_response_header_duration_microseconds_total",
"counter",
"Cumulative response-header latency, not full streamed response latency.",
&wl,
web.response_headers_us.load(Ordering::Relaxed),
);
f.add("rust_proxy_web_server_response_body_bytes_total", "counter", "Web Server body frame bytes observed before downstream compression, not network traffic.", &wl, web.response_bytes.load(Ordering::Relaxed));
f.add(
"rust_proxy_web_server_requests_active",
"gauge",
"Web Server requests still waiting for response headers.",
&wl,
web.in_flight_headers.load(Ordering::Relaxed),
);
for (kind, count) in [
("static", &web.static_requests),
("php", &web.php_requests),
("other", &web.other_requests),
] {
f.add(
"rust_proxy_web_server_request_kind_total",
"counter",
"Web Server responses by resolved handler (other includes early rejects).",
&format!("{wl},kind=\"{kind}\""),
count.load(Ordering::Relaxed),
);
}
for (method, count) in ["GET", "POST", "PUT", "DELETE", "other"]
.iter()
.zip(&web.methods)
{
f.add(
"rust_proxy_web_server_methods_total",
"counter",
"Web Server requests grouped by HTTP method.",
&format!("{wl},method=\"{method}\""),
count.load(Ordering::Relaxed),
);
}
for (status, count) in ["200", "206", "304", "403", "404", "500", "502", "503"]
.iter()
.zip(&web.selected_status)
{
f.add(
"rust_proxy_web_server_status_code_total",
"counter",
"Selected exact HTTP status codes (other codes are in class totals).",
&format!("{wl},status=\"{status}\""),
count.load(Ordering::Relaxed),
);
}
for (encoding, count) in ["gzip", "br", "zstd", "deflate"]
.iter()
.zip(&web.compression)
{
f.add("rust_proxy_web_server_compression_total", "counter", "Web Server routed responses compressed by RustProxy's downstream encoder (excludes precompressed source files).", &format!("{wl},encoding=\"{encoding}\""), count.load(Ordering::Relaxed));
}
f.add("rust_proxy_web_server_response_header_duration_microseconds_total", "counter", "Web Server response header latency, excluding streamed body transfer.", &wl, web.response_headers_us.load(Ordering::Relaxed));
let Some(php) = &compiled.php else { continue };
let l = labels(&[("web_service", service.id.as_str())]);
let m = &php.metrics;
f.add("rust_proxy_php_requests_total", "counter", "PHP-FPM requests completed through response headers.", &l, m.requests.load(Ordering::Relaxed));
f.add(
"rust_proxy_php_requests_total",
"counter",
"PHP requests completed through response headers.",
&wl,
m.requests.load(Ordering::Relaxed),
);
for (class, count) in [
("2xx", &m.status_2xx), ("3xx", &m.status_3xx),
("4xx", &m.status_4xx), ("5xx", &m.status_5xx),
("2xx", &m.status_2xx),
("3xx", &m.status_3xx),
("4xx", &m.status_4xx),
("5xx", &m.status_5xx),
] {
f.add("rust_proxy_php_responses_total", "counter", "PHP response headers by status class.", &format!("{l},class=\"{class}\""), count.load(Ordering::Relaxed));
f.add(
"rust_proxy_php_responses_total",
"counter",
"PHP response headers by status class.",
&format!("{wl},class=\"{class}\""),
count.load(Ordering::Relaxed),
);
}
f.add(
"rust_proxy_php_response_header_duration_microseconds_total",
"counter",
"Cumulative PHP response-header latency, excludes streamed body.",
&wl,
m.response_headers_us.load(Ordering::Relaxed),
);
f.add(
"rust_proxy_php_response_body_bytes_total",
"counter",
"PHP response body bytes emitted before downstream compression, not network traffic.",
&wl,
m.response_bytes.load(Ordering::Relaxed),
);
let available = php.permits.available_permits();
f.add(
"rust_proxy_php_concurrency_available",
"gauge",
"Available PHP-FPM request permits in RustProxy for this service.",
&wl,
available,
);
f.add("rust_proxy_php_concurrency_limit", "gauge", "Configured PHP request concurrency limit within RustProxy (not PHP-FPM process capacity).", &wl, php.max_concurrent);
f.add(
"rust_proxy_php_concurrency_in_use",
"gauge",
"Permits acquired for requests to PHP-FPM (includes body streaming).",
&wl,
php.max_concurrent.saturating_sub(available),
);
for (reason, count) in PHP_FAILURE_NAMES.iter().zip(&m.failures) {
f.add(
"rust_proxy_php_failures_total",
"counter",
"PHP connection, request and response failures by fixed reason.",
&format!("{wl},reason=\"{reason}\""),
count.load(Ordering::Relaxed),
);
}
f.add("rust_proxy_php_response_header_duration_microseconds_total", "counter", "Cumulative PHP response header latency in microseconds, excluding streamed body time.", &l, m.response_headers_us.load(Ordering::Relaxed));
f.add("rust_proxy_php_concurrency_available", "gauge", "Available PHP-FPM request permits in this Web Service.", &l, php.permits.available_permits());
}
}