diff --git a/src/api/mod.rs b/src/api/mod.rs index bc6d428..898570e 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -18,6 +18,8 @@ use tower::buffer::BufferLayer; use tower::limit::RateLimitLayer; use tower::{BoxError, ServiceBuilder}; +const NO_METRICS_ENDPOINTS: [&str; 2] = ["/health", "/metrics"]; + #[derive(Clone)] pub struct AppState { pub db: SqlitePool, @@ -103,6 +105,10 @@ pub fn with_admin_routes(state: AppState, router: Router) -> Router Response { let path = request.uri().to_string(); + if NO_METRICS_ENDPOINTS.contains(&path.as_str()) { + return next.run(request).await; + } + let start = SystemTime::now(); let resp = next.run(request).await; let end = start diff --git a/src/controller.rs b/src/controller.rs index 6336ac7..8ee3b3d 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -288,7 +288,11 @@ impl Controller { .map(|_r| evaluation) .wrap_err("Failed to store premint") } else { - tracing::info!("Premint failed validation: {:?}", premint); + tracing::info!( + "Premint {:?} failed validation: {:?}", + premint.metadata().id, + evaluation.only_failures() + ); tracing::info!(histogram.rules_rejected = 1); Err(evaluation).wrap_err("Premint failed validation") diff --git a/src/rules.rs b/src/rules.rs index 529fc0e..26731f6 100644 --- a/src/rules.rs +++ b/src/rules.rs @@ -118,6 +118,16 @@ impl Results { .any(|r| matches!(r.result, Ok(Evaluation::Reject(_)))) } + pub fn only_failures(&self) -> Self { + Self( + self.0 + .iter() + .filter(|r| r.result.is_err() || matches!(r.result, Ok(Evaluation::Reject(_)))) + .cloned() + .collect(), + ) + } + pub fn is_err(&self) -> bool { self.0.iter().any(|r| r.result.is_err()) } @@ -443,8 +453,9 @@ mod general { Ok(Accept) } else { reject!( - "Existing premint with higher version {} exists", - existing.metadata().version + "Existing premint with version {} exists, trying to store version {}", + existing.metadata().version, + meta.version ) } }