use mz_ore::metric;
use mz_ore::metrics::MetricsRegistry;
use mz_ore::stats::histogram_seconds_buckets;
use prometheus::{HistogramVec, IntCounterVec, IntGaugeVec};
#[derive(Debug, Clone)]
pub struct Metrics {
pub http_request_count: IntCounterVec,
pub request_duration_seconds: HistogramVec,
pub refresh_tasks_active: IntGaugeVec,
pub session_request_count: IntCounterVec,
pub session_refresh_count: IntCounterVec,
}
impl Metrics {
pub(crate) fn register_into(registry: &MetricsRegistry) -> Self {
Self {
http_request_count: registry.register(metric!(
name: "mz_auth_request_count",
help: "Total number of HTTP requests made to Frontegg for authentication",
var_labels: ["path", "status"],
)),
request_duration_seconds: registry.register(metric!(
name: "mz_auth_request_duration_seconds",
help: "How long it takes for a request to Frontegg to complete in seconds.",
var_labels: ["path"],
buckets: histogram_seconds_buckets(0.000_128, 8.0),
)),
refresh_tasks_active: registry.register(metric!(
name: "mz_auth_refresh_tasks_active",
help: "The number of active refresh tasks we have running.",
)),
session_request_count: registry.register(metric!(
name: "mz_auth_session_request_count",
help: "Total number of session start requests the Authenticator has received.",
var_labels: ["existing_session"],
)),
session_refresh_count: registry.register(metric!(
name: "mz_auth_session_refresh_count",
help: "Total number of authentication sessions that get refreshed.",
var_labels: ["outstanding_receivers", "recent_drop"],
)),
}
}
}