truncate MatchedPath for span field
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
213a6d441f
commit
14dcc8db15
1 changed files with 7 additions and 1 deletions
|
@ -182,7 +182,13 @@ fn tracing_span<T>(request: &http::Request<T>) -> tracing::Span {
|
||||||
let path = request
|
let path = request
|
||||||
.extensions()
|
.extensions()
|
||||||
.get::<MatchedPath>()
|
.get::<MatchedPath>()
|
||||||
.map_or_else(|| request.uri().path(), |p| p.as_str());
|
.map_or_else(|| request.uri().path(), truncated_matched_path);
|
||||||
|
|
||||||
tracing::info_span!("router:", %path)
|
tracing::info_span!("router:", %path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn truncated_matched_path(path: &MatchedPath) -> &str {
|
||||||
|
path.as_str()
|
||||||
|
.rsplit_once(':')
|
||||||
|
.map_or(path.as_str(), |path| path.0.strip_suffix('/').unwrap_or(path.0))
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue