diff --git a/Cargo.lock b/Cargo.lock index 3a90255..9a98513 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2644,8 +2644,11 @@ dependencies = [ "argon2", "async-trait", "axum", + "axum-extra", "clap", "figment", + "headers", + "http", "opentelemetry", "opentelemetry-otlp", "opentelemetry-semantic-conventions", diff --git a/Cargo.toml b/Cargo.toml index 1190177..b784276 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -173,3 +173,6 @@ rustical_dav_push.workspace = true rustical_oidc.workspace = true quick-xml.workspace = true tower-http.workspace = true +axum-extra.workspace = true +headers.workspace = true +http.workspace = true diff --git a/src/app.rs b/src/app.rs index 1dffe9a..85c7d99 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,7 +1,8 @@ use axum::Router; use axum::extract::Request; use axum::response::Response; -use reqwest::StatusCode; +use headers::{HeaderMapExt, UserAgent}; +use http::StatusCode; use rustical_caldav::caldav_router; use rustical_carddav::carddav_router; use rustical_frontend::nextcloud_login::{NextcloudFlows, nextcloud_login_router}; @@ -80,20 +81,24 @@ pub fn make_app( .make_span_with(|request: &Request| { tracing::info_span!( "http-request", - status_code = tracing::field::Empty, + status = tracing::field::Empty, otel.name = tracing::field::display(format!( "{} {}", request.method(), request.uri() )), + ua = tracing::field::Empty, ) }) .on_request(|req: &Request, span: &Span| { span.record("method", display(req.method())); span.record("path", display(req.uri())); + if let Some(ua) = req.headers().typed_get::() { + span.record("ua", display(ua)); + } }) .on_response(|response: &Response, _latency: Duration, span: &Span| { - span.record("status_code", display(response.status())); + span.record("status", display(response.status())); if response.status().is_server_error() { tracing::error!("server error"); } else if response.status().is_client_error() {