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
|
@ -5,7 +5,6 @@ use axum_extra::{
|
||||||
TypedHeader,
|
TypedHeader,
|
||||||
};
|
};
|
||||||
use conduit::{debug_error, err, warn, Err, Error, Result};
|
use conduit::{debug_error, err, warn, Err, Error, Result};
|
||||||
use http::uri::PathAndQuery;
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::{client::error::ErrorKind, AuthScheme, Metadata},
|
api::{client::error::ErrorKind, AuthScheme, Metadata},
|
||||||
server_util::authorization::XMatrix,
|
server_util::authorization::XMatrix,
|
||||||
|
@ -190,12 +189,11 @@ async fn auth_server(services: &Services, request: &mut Request, body: Option<&C
|
||||||
|
|
||||||
let destination = services.globals.server_name();
|
let destination = services.globals.server_name();
|
||||||
let origin = &x_matrix.origin;
|
let origin = &x_matrix.origin;
|
||||||
#[allow(clippy::or_fun_call)]
|
|
||||||
let signature_uri = request
|
let signature_uri = request
|
||||||
.parts
|
.parts
|
||||||
.uri
|
.uri
|
||||||
.path_and_query()
|
.path_and_query()
|
||||||
.unwrap_or(&PathAndQuery::from_static("/"))
|
.expect("all requests have a path")
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
let signature: [Member; 1] = [(x_matrix.key.to_string(), Value::String(x_matrix.sig.to_string()))];
|
let signature: [Member; 1] = [(x_matrix.key.to_string(), Value::String(x_matrix.sig.to_string()))];
|
||||||
|
|
|
@ -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 {
|
fn tracing_span<T>(request: &http::Request<T>) -> tracing::Span {
|
||||||
let path = request
|
let path = request.extensions().get::<MatchedPath>().map_or_else(
|
||||||
.extensions()
|
|| {
|
||||||
.get::<MatchedPath>()
|
request
|
||||||
.map_or_else(|| request.uri().path(), truncated_matched_path);
|
.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 {
|
fn truncated_matched_path(path: &MatchedPath) -> &str {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue