mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
include method in otel.name for incoming requests
Also change the name of the field from path to endpoint since it's not the exact request path, and swap the order of method and endpoint.
This commit is contained in:
parent
1b51e0beec
commit
f2e5b281c9
1 changed files with 7 additions and 5 deletions
12
src/main.rs
12
src/main.rs
|
|
@ -145,19 +145,21 @@ async fn run_server() -> Result<(), error::Serve> {
|
||||||
.layer(axum::middleware::from_fn(spawn_task))
|
.layer(axum::middleware::from_fn(spawn_task))
|
||||||
.layer(TraceLayer::new_for_http().make_span_with(
|
.layer(TraceLayer::new_for_http().make_span_with(
|
||||||
|request: &http::Request<_>| {
|
|request: &http::Request<_>| {
|
||||||
let path = if let Some(path) =
|
let endpoint = if let Some(endpoint) =
|
||||||
request.extensions().get::<MatchedPath>()
|
request.extensions().get::<MatchedPath>()
|
||||||
{
|
{
|
||||||
path.as_str()
|
endpoint.as_str()
|
||||||
} else {
|
} else {
|
||||||
request.uri().path()
|
request.uri().path()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let method = request.method();
|
||||||
|
|
||||||
tracing::info_span!(
|
tracing::info_span!(
|
||||||
"http_request",
|
"http_request",
|
||||||
otel.name = path,
|
otel.name = format!("{method} {endpoint}"),
|
||||||
%path,
|
%method,
|
||||||
method = %request.method(),
|
%endpoint,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue