From 3bf16d42530e65236de7c7443aee4fcbeabb0f46 Mon Sep 17 00:00:00 2001 From: Firstyear Date: Thu, 22 Feb 2024 17:34:46 +1000 Subject: [PATCH] Make /status less noisy (#2574) --- server/core/src/https/middleware/mod.rs | 4 ++-- server/core/src/https/trace.rs | 5 +++-- server/lib/src/status.rs | 4 +--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/server/core/src/https/middleware/mod.rs b/server/core/src/https/middleware/mod.rs index 2b946cd94..e7a9cb169 100644 --- a/server/core/src/https/middleware/mod.rs +++ b/server/core/src/https/middleware/mod.rs @@ -24,7 +24,7 @@ pub async fn version_middleware(request: Request, next: Next) -> Respon #[cfg(any(test, debug_assertions))] /// This is a debug middleware to ensure that /v1/ endpoints only return JSON -#[instrument(level = "debug", name = "are_we_json_yet", skip_all)] +#[instrument(level = "trace", name = "are_we_json_yet", skip_all)] pub async fn are_we_json_yet(request: Request, next: Next) -> Response { let uri = request.uri().path().to_string(); @@ -52,7 +52,7 @@ pub struct KOpId { } /// This runs at the start of the request, adding an extension with `KOpId` which has useful things inside it. -#[instrument(level = "debug", name = "kopid_middleware", skip_all)] +#[instrument(level = "trace", name = "kopid_middleware", skip_all)] pub async fn kopid_middleware(mut request: Request, next: Next) -> Response { // generate the event ID let eventid = sketching::tracing_forest::id(); diff --git a/server/core/src/https/trace.rs b/server/core/src/https/trace.rs index bd10b7f12..81a70e9c4 100644 --- a/server/core/src/https/trace.rs +++ b/server/core/src/https/trace.rs @@ -25,8 +25,9 @@ impl Default for DefaultMakeSpanKanidmd { } impl tower_http::trace::MakeSpan for DefaultMakeSpanKanidmd { - #[instrument(name = "handle_request", skip_all, fields(latency, status_code))] fn make_span(&mut self, request: &Request) -> Span { + // Needs to be at info to ensure that there is always a span for each + // tracing event to hook into. tracing::span!( Level::INFO, "request", @@ -77,7 +78,7 @@ impl tower_http::trace::OnResponse for DefaultOnResponseKanidmd { }; let (level, msg) = match response.status().is_success() || response.status().is_informational() { - true => (Level::INFO, "response sent"), + true => (Level::DEBUG, "response sent"), false => { if response.status().is_redirection() { (Level::INFO, "client redirection sent") diff --git a/server/lib/src/status.rs b/server/lib/src/status.rs index d87cd14ca..6143cff3c 100644 --- a/server/lib/src/status.rs +++ b/server/lib/src/status.rs @@ -2,8 +2,6 @@ use uuid::Uuid; -use crate::prelude::*; - // TODO: this should *totally* be running the OTEL metrics collector pub struct StatusRequestEvent { @@ -21,7 +19,7 @@ impl StatusActor { } pub async fn handle_request(&self, _event: StatusRequestEvent) -> bool { - admin_info!("status handler complete"); + trace!("status handler complete"); true } }