mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-05-09 05:21:23 +02:00
Fix duplicate static definitions and functions in metrics.rs to resolve compilation errors
This commit is contained in:
parent
2be654164a
commit
b8e13fb026
1 changed files with 0 additions and 101 deletions
101
src/metrics.rs
101
src/metrics.rs
|
|
@ -138,108 +138,7 @@ pub fn increment_auth_attempts(method: &str, status: &str) {
|
|||
AUTH_ATTEMPTS_TOTAL.with_label_values(&[method, status]).inc();
|
||||
}
|
||||
|
||||
// Database metrics
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
static DB_CONNECTIONS_ACTIVE: Lazy<IntGaugeVec> = Lazy::new(|| {
|
||||
register_int_gauge_vec!("vaultwarden_db_connections_active", "Number of active database connections", &["database"])
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
static DB_CONNECTIONS_IDLE: Lazy<IntGaugeVec> = Lazy::new(|| {
|
||||
register_int_gauge_vec!("vaultwarden_db_connections_idle", "Number of idle database connections", &["database"])
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
static DB_QUERY_DURATION_SECONDS: Lazy<HistogramVec> = Lazy::new(|| {
|
||||
register_histogram_vec!(
|
||||
"vaultwarden_db_query_duration_seconds",
|
||||
"Database query duration in seconds",
|
||||
&["operation"],
|
||||
vec![0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0]
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
// Authentication metrics
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
static AUTH_ATTEMPTS_TOTAL: Lazy<IntCounterVec> = Lazy::new(|| {
|
||||
register_int_counter_vec!(
|
||||
"vaultwarden_auth_attempts_total",
|
||||
"Total number of authentication attempts",
|
||||
&["method", "status"]
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
static USER_SESSIONS_ACTIVE: Lazy<IntGaugeVec> = Lazy::new(|| {
|
||||
register_int_gauge_vec!("vaultwarden_user_sessions_active", "Number of active user sessions", &["user_type"])
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
// Business metrics
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
static USERS_TOTAL: Lazy<IntGaugeVec> =
|
||||
Lazy::new(|| register_int_gauge_vec!("vaultwarden_users_total", "Total number of users", &["status"]).unwrap());
|
||||
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
static ORGANIZATIONS_TOTAL: Lazy<IntGaugeVec> = Lazy::new(|| {
|
||||
register_int_gauge_vec!("vaultwarden_organizations_total", "Total number of organizations", &["status"]).unwrap()
|
||||
});
|
||||
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
static VAULT_ITEMS_TOTAL: Lazy<IntGaugeVec> = Lazy::new(|| {
|
||||
register_int_gauge_vec!("vaultwarden_vault_items_total", "Total number of vault items", &["type", "organization"])
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
static COLLECTIONS_TOTAL: Lazy<IntGaugeVec> = Lazy::new(|| {
|
||||
register_int_gauge_vec!("vaultwarden_collections_total", "Total number of collections", &["organization"]).unwrap()
|
||||
});
|
||||
|
||||
// System metrics
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
static UPTIME_SECONDS: Lazy<GaugeVec> =
|
||||
Lazy::new(|| register_gauge_vec!("vaultwarden_uptime_seconds", "Uptime in seconds", &["version"]).unwrap());
|
||||
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
static BUILD_INFO: Lazy<IntGaugeVec> = Lazy::new(|| {
|
||||
register_int_gauge_vec!("vaultwarden_build_info", "Build information", &["version", "revision", "branch"]).unwrap()
|
||||
});
|
||||
|
||||
/// Increment HTTP request counter
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
pub fn increment_http_requests(method: &str, path: &str, status: u16) {
|
||||
HTTP_REQUESTS_TOTAL.with_label_values(&[method, path, &status.to_string()]).inc();
|
||||
}
|
||||
|
||||
/// Observe HTTP request duration
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
pub fn observe_http_request_duration(method: &str, path: &str, duration_seconds: f64) {
|
||||
HTTP_REQUEST_DURATION_SECONDS.with_label_values(&[method, path]).observe(duration_seconds);
|
||||
}
|
||||
|
||||
/// Update database connection metrics
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
pub fn update_db_connections(database: &str, active: i64, idle: i64) {
|
||||
DB_CONNECTIONS_ACTIVE.with_label_values(&[database]).set(active);
|
||||
DB_CONNECTIONS_IDLE.with_label_values(&[database]).set(idle);
|
||||
}
|
||||
|
||||
/// Observe database query duration
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
pub fn observe_db_query_duration(operation: &str, duration_seconds: f64) {
|
||||
DB_QUERY_DURATION_SECONDS.with_label_values(&[operation]).observe(duration_seconds);
|
||||
}
|
||||
|
||||
/// Increment authentication attempts
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
pub fn increment_auth_attempts(method: &str, status: &str) {
|
||||
AUTH_ATTEMPTS_TOTAL.with_label_values(&[method, status]).inc();
|
||||
}
|
||||
|
||||
/// Update active user sessions
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
|
|
|
|||
Loading…
Reference in a new issue