Improve tracing of request error responses.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
use std::{mem, ops::Deref};
|
use std::{fmt::Debug, mem, ops::Deref};
|
||||||
|
|
||||||
use axum::{body::Body, extract::FromRequest};
|
use axum::{body::Body, extract::FromRequest};
|
||||||
use bytes::{BufMut, Bytes, BytesMut};
|
use bytes::{BufMut, Bytes, BytesMut};
|
||||||
@@ -13,6 +13,7 @@ use super::{auth, auth::Auth, request, request::Request};
|
|||||||
use crate::State;
|
use crate::State;
|
||||||
|
|
||||||
/// Extractor for Ruma request structs
|
/// Extractor for Ruma request structs
|
||||||
|
#[derive(Debug)]
|
||||||
pub(crate) struct Args<T> {
|
pub(crate) struct Args<T> {
|
||||||
/// Request struct body
|
/// Request struct body
|
||||||
pub(crate) body: T,
|
pub(crate) body: T,
|
||||||
@@ -38,10 +39,7 @@ pub(crate) struct Args<T> {
|
|||||||
pub(crate) json_body: Option<CanonicalJsonValue>,
|
pub(crate) json_body: Option<CanonicalJsonValue>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Args<T>
|
impl<T> Args<T> {
|
||||||
where
|
|
||||||
T: IncomingRequest + Send + Sync + 'static,
|
|
||||||
{
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn sender(&self) -> (&UserId, &DeviceId) {
|
pub(crate) fn sender(&self) -> (&UserId, &DeviceId) {
|
||||||
(self.sender_user(), self.sender_device())
|
(self.sender_user(), self.sender_device())
|
||||||
@@ -71,7 +69,7 @@ where
|
|||||||
|
|
||||||
impl<T> Deref for Args<T>
|
impl<T> Deref for Args<T>
|
||||||
where
|
where
|
||||||
T: IncomingRequest + Send + Sync + 'static,
|
T: Sync,
|
||||||
{
|
{
|
||||||
type Target = T;
|
type Target = T;
|
||||||
|
|
||||||
@@ -80,10 +78,11 @@ where
|
|||||||
|
|
||||||
impl<T> FromRequest<State, Body> for Args<T>
|
impl<T> FromRequest<State, Body> for Args<T>
|
||||||
where
|
where
|
||||||
T: IncomingRequest + Send + Sync + 'static,
|
T: IncomingRequest + Debug + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
type Rejection = Error;
|
type Rejection = Error;
|
||||||
|
|
||||||
|
#[tracing::instrument(name = "ar", level = "debug", skip(services), ret, err)]
|
||||||
async fn from_request(
|
async fn from_request(
|
||||||
request: hyper::Request<Body>,
|
request: hyper::Request<Body>,
|
||||||
services: &State,
|
services: &State,
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use std::{fmt::Debug, time::SystemTime};
|
||||||
|
|
||||||
use axum::RequestPartsExt;
|
use axum::RequestPartsExt;
|
||||||
use axum_extra::{
|
use axum_extra::{
|
||||||
TypedHeader,
|
TypedHeader,
|
||||||
@@ -43,7 +45,7 @@ enum Token {
|
|||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Debug, Default)]
|
||||||
pub(super) struct Auth {
|
pub(super) struct Auth {
|
||||||
pub(super) origin: Option<OwnedServerName>,
|
pub(super) origin: Option<OwnedServerName>,
|
||||||
pub(super) sender_user: Option<OwnedUserId>,
|
pub(super) sender_user: Option<OwnedUserId>,
|
||||||
@@ -51,6 +53,12 @@ pub(super) struct Auth {
|
|||||||
pub(super) appservice_info: Option<RegistrationInfo>,
|
pub(super) appservice_info: Option<RegistrationInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(
|
||||||
|
level = "trace",
|
||||||
|
skip(services, request, json_body),
|
||||||
|
ret,
|
||||||
|
err
|
||||||
|
)]
|
||||||
pub(super) async fn auth(
|
pub(super) async fn auth(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
request: &mut Request,
|
request: &mut Request,
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use std::fmt::Debug;
|
||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
Router,
|
Router,
|
||||||
extract::FromRequestParts,
|
extract::FromRequestParts,
|
||||||
@@ -38,7 +40,7 @@ macro_rules! ruma_handler {
|
|||||||
where
|
where
|
||||||
Fun: Fn($($tx,)* Ruma<Req>,) -> Fut + Send + Sync + 'static,
|
Fun: Fn($($tx,)* Ruma<Req>,) -> Fut + Send + Sync + 'static,
|
||||||
Fut: Future<Output = Result<Req::OutgoingResponse, Err>> + Send,
|
Fut: Future<Output = Result<Req::OutgoingResponse, Err>> + Send,
|
||||||
Req: IncomingRequest + Send + Sync + 'static,
|
Req: IncomingRequest + Debug + Send + Sync + 'static,
|
||||||
Err: IntoResponse + Send,
|
Err: IntoResponse + Send,
|
||||||
<Req as IncomingRequest>::OutgoingResponse: Send,
|
<Req as IncomingRequest>::OutgoingResponse: Send,
|
||||||
$( $tx: FromRequestParts<State> + Send + Sync + 'static, )*
|
$( $tx: FromRequestParts<State> + Send + Sync + 'static, )*
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ use tuwunel_service::Services;
|
|||||||
name = "request",
|
name = "request",
|
||||||
level = "debug",
|
level = "debug",
|
||||||
skip_all,
|
skip_all,
|
||||||
|
err(Debug)
|
||||||
fields(
|
fields(
|
||||||
id = %services
|
id = %services
|
||||||
.server
|
.server
|
||||||
|
|||||||
Reference in New Issue
Block a user