diff --git a/crates/collab/src/auth.rs b/crates/collab/src/auth.rs index 9819e600c3..9ce602c577 100644 --- a/crates/collab/src/auth.rs +++ b/crates/collab/src/auth.rs @@ -8,13 +8,24 @@ use axum::{ middleware::Next, response::IntoResponse, }; +use lazy_static::lazy_static; +use prometheus::{exponential_buckets, register_histogram, Histogram}; use rand::thread_rng; use scrypt::{ password_hash::{PasswordHash, PasswordHasher, PasswordVerifier, SaltString}, Scrypt, }; use serde::{Deserialize, Serialize}; -use std::sync::Arc; +use std::{sync::Arc, time::Instant}; + +lazy_static! { + static ref METRIC_ACCESS_TOKEN_HASHING_TIME: Histogram = register_histogram!( + "access_token_hashing_time", + "time spent hashing access tokens", + exponential_buckets(10.0, 2.0, 10).unwrap(), + ) + .unwrap(); +} pub async fn validate_header(mut req: Request, next: Next) -> impl IntoResponse { let mut auth_header = req @@ -129,7 +140,12 @@ pub async fn verify_access_token(token: &str, user_id: UserId, db: &Arc