mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-05-09 05:21:23 +02:00
Fix clippy warnings: remove unused async and format code
- Remove async from update_health_metrics since it doesn't await - Remove .await from call site in alive handler - Add clippy allow attributes for Rocket handler - Apply rustfmt formatting
This commit is contained in:
parent
b8e13fb026
commit
71e39c1095
4 changed files with 14 additions and 11 deletions
|
|
@ -30,9 +30,9 @@ use crate::{
|
|||
DbConn,
|
||||
},
|
||||
error::MapResult,
|
||||
mail, sso,
|
||||
mail, metrics, sso,
|
||||
sso::{OIDCCode, OIDCCodeChallenge, OIDCCodeVerifier, OIDCState},
|
||||
util, CONFIG, metrics,
|
||||
util, CONFIG,
|
||||
};
|
||||
|
||||
pub fn routes() -> Vec<Route> {
|
||||
|
|
@ -106,7 +106,11 @@ async fn login(
|
|||
};
|
||||
|
||||
// Record authentication metrics
|
||||
let auth_status = if login_result.is_ok() { "success" } else { "failed" };
|
||||
let auth_status = if login_result.is_ok() {
|
||||
"success"
|
||||
} else {
|
||||
"failed"
|
||||
};
|
||||
metrics::increment_auth_attempts(&auth_method, auth_status);
|
||||
|
||||
if let Some(user_id) = user_id {
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ async fn get_metrics(_token: MetricsToken, mut conn: DbConn) -> Result<RawText<S
|
|||
|
||||
/// Health check endpoint that also updates some basic metrics
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
pub async fn update_health_metrics(_conn: &mut DbConn) {
|
||||
pub fn update_health_metrics(_conn: &mut DbConn) {
|
||||
// Update basic system metrics
|
||||
use std::time::SystemTime;
|
||||
static START_TIME: std::sync::OnceLock<SystemTime> = std::sync::OnceLock::new();
|
||||
|
|
@ -117,4 +117,4 @@ pub async fn update_health_metrics(_conn: &mut DbConn) {
|
|||
}
|
||||
|
||||
#[cfg(not(feature = "enable_metrics"))]
|
||||
pub async fn update_health_metrics(_conn: &mut DbConn) {}
|
||||
pub fn update_health_metrics(_conn: &mut DbConn) {}
|
||||
|
|
|
|||
|
|
@ -179,9 +179,10 @@ async fn attachments(cipher_id: CipherId, file_id: AttachmentId, token: String)
|
|||
// We use DbConn here to let the alive healthcheck also verify the database connection.
|
||||
use crate::db::DbConn;
|
||||
#[get("/alive")]
|
||||
#[allow(clippy::let_unit_value, clippy::unused_async)]
|
||||
async fn alive(mut conn: DbConn) -> Json<String> {
|
||||
// Update basic health metrics if metrics are enabled
|
||||
let _ = crate::api::metrics::update_health_metrics(&mut conn).await;
|
||||
crate::api::metrics::update_health_metrics(&mut conn);
|
||||
now()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
use once_cell::sync::Lazy;
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
use prometheus::{
|
||||
register_gauge_vec, register_histogram_vec, register_int_counter_vec, register_int_gauge_vec,
|
||||
Encoder, GaugeVec, HistogramVec, IntCounterVec, IntGaugeVec, TextEncoder,
|
||||
register_gauge_vec, register_histogram_vec, register_int_counter_vec, register_int_gauge_vec, Encoder, GaugeVec,
|
||||
HistogramVec, IntCounterVec, IntGaugeVec, TextEncoder,
|
||||
};
|
||||
|
||||
use crate::{db::DbConn, error::Error, CONFIG};
|
||||
use std::time::SystemTime;
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::time::SystemTime;
|
||||
#[cfg(feature = "enable_metrics")]
|
||||
use std::time::UNIX_EPOCH;
|
||||
|
||||
|
|
@ -138,8 +138,6 @@ 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")]
|
||||
pub fn update_user_sessions(user_type: &str, count: i64) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue