tracing: extract request info into tags
Some checks failed
ci/woodpecker/pr/ci Pipeline failed

This commit is contained in:
Daniel Lundin 2024-11-26 15:38:45 +01:00
parent fbbd753312
commit eff094e856
Signed by: dln
SSH key fingerprint: SHA256:dQy1Xj3UiqJYpKR5ggQ2bxgz4jCH8IF+k3AB8o0kmdI

View file

@ -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<Arc<()>>,
) -> Result<HttpResponseOk<VersionInfo>, 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))
}