From eff094e8566535142331f2b7a762a9e73634b5a5 Mon Sep 17 00:00:00 2001 From: Daniel Lundin Date: Tue, 26 Nov 2024 15:38:45 +0100 Subject: [PATCH] tracing: extract request info into tags --- controller/src/main.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/controller/src/main.rs b/controller/src/main.rs index 62097eb..5c9577a 100644 --- a/controller/src/main.rs +++ b/controller/src/main.rs @@ -44,7 +44,16 @@ struct VersionInfo { method = GET, path = "/version", }] -#[tracing::instrument()] +#[tracing::instrument( + skip(rqctx), + fields( + http.method=rqctx.request.method().as_str(), + http.path=rqctx.request.uri().path(), + http.remote_ip=rqctx.request.remote_addr().ip().to_string(), + request_id = rqctx.request_id, + ), + err(Debug), +)] async fn api_version( rqctx: RequestContext>, ) -> Result, HttpError> { @@ -52,6 +61,8 @@ async fn api_version( name: env!("CARGO_PKG_NAME").to_string(), version: env!("CARGO_PKG_VERSION").to_string(), }; + + tracing::info!("Someone made a request to /version"); Ok(HttpResponseOk(ver)) }