log method on tracing req spans, fix path sometimes being truncated
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
652b04b9b6
commit
2ce91f33af
2 changed files with 14 additions and 8 deletions
|
@ -184,12 +184,20 @@ fn catch_panic(err: Box<dyn Any + Send + 'static>) -> http::Response<http_body_u
|
|||
}
|
||||
|
||||
fn tracing_span<T>(request: &http::Request<T>) -> tracing::Span {
|
||||
let path = request
|
||||
.extensions()
|
||||
.get::<MatchedPath>()
|
||||
.map_or_else(|| request.uri().path(), truncated_matched_path);
|
||||
let path = request.extensions().get::<MatchedPath>().map_or_else(
|
||||
|| {
|
||||
request
|
||||
.uri()
|
||||
.path_and_query()
|
||||
.expect("all requests have a path")
|
||||
.as_str()
|
||||
},
|
||||
truncated_matched_path,
|
||||
);
|
||||
|
||||
tracing::info_span!("router:", %path)
|
||||
let method = request.method();
|
||||
|
||||
tracing::info_span!("router:", %method, %path)
|
||||
}
|
||||
|
||||
fn truncated_matched_path(path: &MatchedPath) -> &str {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue