Use trace-request for dropshot instrumentation

This commit is contained in:
Daniel Lundin 2024-12-16 23:36:33 +01:00
parent da210ffc16
commit 31c8921aca
Signed by: dln
SSH key fingerprint: SHA256:dQy1Xj3UiqJYpKR5ggQ2bxgz4jCH8IF+k3AB8o0kmdI
13 changed files with 246 additions and 36 deletions

View file

@ -9,11 +9,16 @@ license = "MPL-2.0"
anyhow.workspace = true
clap.workspace = true
dropshot.workspace = true
patagia-common = { path = "../common" }
http.workspace = true
instrumentation = { path = "../instrumentation" }
schemars.workspace = true
serde.workspace = true
slog-async.workspace = true
slog.workspace = true
tokio.workspace = true
trace-request = { path = "../trace-request" }
tracing-slog.workspace = true
tracing.workspace = true
[package.metadata.cargo-machete]
ignored = ["http"]

View file

@ -9,7 +9,6 @@ use std::net::SocketAddr;
use std::str::FromStr;
use std::sync::Arc;
use patagia_common::instrumentation;
use patagia_controller::api;
use patagia_controller::context::ControllerContext;

View file

@ -1,7 +1,7 @@
use dropshot::{endpoint, HttpError, HttpResponseOk, RequestContext};
use schemars::JsonSchema;
use serde::Serialize;
use tracing::Instrument;
use trace_request::trace_request;
use std::sync::Arc;
@ -19,16 +19,7 @@ struct VersionInfo {
method = GET,
path = "/version",
}]
#[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),
)]
#[trace_request]
pub(crate) async fn version(
rqctx: RequestContext<Arc<ControllerContext>>,
) -> Result<HttpResponseOk<VersionInfo>, HttpError> {
@ -45,5 +36,6 @@ pub(crate) async fn version(
}
.instrument(tracing::info_span!("Let's do the thing...."))
.await;
Ok(HttpResponseOk(ver))
}