Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

feat: spans with information #66

Merged
merged 2 commits into from
Sep 7, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use {
Router,
},
config::Configuration,
http::Request,
hyper::Body,
opentelemetry::{sdk::Resource, KeyValue},
state::AppState,
std::{net::SocketAddr, sync::Arc},
Expand All @@ -17,7 +19,7 @@ use {
tower::ServiceBuilder,
tower_http::{
cors::{Any, CorsLayer},
trace::{DefaultMakeSpan, DefaultOnRequest, DefaultOnResponse, TraceLayer},
trace::{DefaultOnRequest, DefaultOnResponse, TraceLayer},
},
};

Expand Down Expand Up @@ -96,7 +98,9 @@ pub async fn bootstrap(

let global_middleware = ServiceBuilder::new().layer(
TraceLayer::new_for_http()
.make_span_with(DefaultMakeSpan::new().include_headers(true))
.make_span_with(|request: &Request<Body>| {
tracing::info_span!("http-request", "method" = ?request.method(), "uri" = ?request.uri())
})
.on_request(DefaultOnRequest::new().level(config.log_level()))
.on_response(
DefaultOnResponse::new()
Expand Down
Loading