1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
910//! Metrics for our Frontegg Authentication client.
1112use mz_ore::metric;
13use mz_ore::metrics::MetricsRegistry;
14use mz_ore::stats::histogram_seconds_buckets;
15use prometheus::{HistogramVec, IntCounterVec, IntGaugeVec};
1617#[derive(Debug, Clone)]
18pub struct Metrics {
19/// Total number of requests since process start.
20pub http_request_count: IntCounterVec,
21/// How long it takes for a request to Frontegg to complete.
22pub request_duration_seconds: HistogramVec,
23/// The number of active refresh tasks we have running.
24pub refresh_tasks_active: IntGaugeVec,
25/// Number of sessions that have requested to start.
26pub session_request_count: IntCounterVec,
27/// Number of sessions that get refreshed.
28pub session_refresh_count: IntCounterVec,
29}
3031impl Metrics {
32pub(crate) fn register_into(registry: &MetricsRegistry) -> Self {
33Self {
34 http_request_count: registry.register(metric!(
35 name: "mz_auth_request_count",
36 help: "Total number of HTTP requests made to Frontegg for authentication",
37 var_labels: ["path", "status"],
38 )),
39 request_duration_seconds: registry.register(metric!(
40 name: "mz_auth_request_duration_seconds",
41 help: "How long it takes for a request to Frontegg to complete in seconds.",
42 var_labels: ["path"],
43 buckets: histogram_seconds_buckets(0.000_128, 8.0),
44 )),
45 refresh_tasks_active: registry.register(metric!(
46 name: "mz_auth_refresh_tasks_active",
47 help: "The number of active refresh tasks we have running.",
48 )),
49 session_request_count: registry.register(metric!(
50 name: "mz_auth_session_request_count",
51 help: "Total number of session start requests the Authenticator has received.",
52 var_labels: ["existing_session"],
53 )),
54 session_refresh_count: registry.register(metric!(
55 name: "mz_auth_session_refresh_count",
56 help: "Total number of authentication sessions that get refreshed.",
57 var_labels: ["outstanding_receivers", "recent_drop"],
58 )),
59 }
60 }
61}