fix tracing spans across awaits
This commit is contained in:
parent
e30c610de4
commit
c9e64e5f0b
2 changed files with 21 additions and 15 deletions
|
@ -13,7 +13,7 @@ use oauth2::{
|
||||||
ClientSecret, CsrfToken, RedirectUrl, RefreshToken, TokenResponse, TokenUrl,
|
ClientSecret, CsrfToken, RedirectUrl, RefreshToken, TokenResponse, TokenUrl,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tracing::trace_span;
|
use tracing::{trace_span, Instrument};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app_error::AppError,
|
app_error::AppError,
|
||||||
|
@ -197,7 +197,7 @@ impl FromRequestParts<AppState> for AuthInfo {
|
||||||
parts: &mut Parts,
|
parts: &mut Parts,
|
||||||
state: &AppState,
|
state: &AppState,
|
||||||
) -> Result<Self, <Self as FromRequestParts<AppState>>::Rejection> {
|
) -> Result<Self, <Self as FromRequestParts<AppState>>::Rejection> {
|
||||||
let _ = trace_span!("AuthInfo from_request_parts()").enter();
|
async move {
|
||||||
let session = parts
|
let session = parts
|
||||||
.extract_with_state::<AppSession, AppState>(state)
|
.extract_with_state::<AppSession, AppState>(state)
|
||||||
.await?
|
.await?
|
||||||
|
@ -210,4 +210,8 @@ impl FromRequestParts<AppState> for AuthInfo {
|
||||||
)?;
|
)?;
|
||||||
Ok(user)
|
Ok(user)
|
||||||
}
|
}
|
||||||
|
// The Span.enter() guard pattern doesn't play nicely async
|
||||||
|
.instrument(trace_span!("AuthInfo from_request_parts()"))
|
||||||
|
.await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use axum::{
|
||||||
use axum_extra::extract::CookieJar;
|
use axum_extra::extract::CookieJar;
|
||||||
use chrono::{DateTime, TimeDelta, Utc};
|
use chrono::{DateTime, TimeDelta, Utc};
|
||||||
use diesel::{pg::Pg, prelude::*, upsert::excluded};
|
use diesel::{pg::Pg, prelude::*, upsert::excluded};
|
||||||
use tracing::trace_span;
|
use tracing::{trace_span, Instrument};
|
||||||
|
|
||||||
use crate::{app_error::AppError, app_state::AppState, schema::browser_sessions};
|
use crate::{app_error::AppError, app_state::AppState, schema::browser_sessions};
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ impl FromRequestParts<AppState> for AppSession {
|
||||||
parts: &mut Parts,
|
parts: &mut Parts,
|
||||||
state: &AppState,
|
state: &AppState,
|
||||||
) -> Result<Self, <Self as FromRequestParts<AppState>>::Rejection> {
|
) -> Result<Self, <Self as FromRequestParts<AppState>>::Rejection> {
|
||||||
let _ = trace_span!("AppSession::from_request_parts()").enter();
|
async move {
|
||||||
let jar = parts.extract::<CookieJar>().await.unwrap();
|
let jar = parts.extract::<CookieJar>().await.unwrap();
|
||||||
let session_cookie = match jar.get(&state.settings.auth.cookie_name) {
|
let session_cookie = match jar.get(&state.settings.auth.cookie_name) {
|
||||||
Some(cookie) => cookie,
|
Some(cookie) => cookie,
|
||||||
|
@ -167,5 +167,7 @@ impl FromRequestParts<AppState> for AppSession {
|
||||||
tracing::debug!("no matching session found in database");
|
tracing::debug!("no matching session found in database");
|
||||||
Ok(AppSession(None))
|
Ok(AppSession(None))
|
||||||
}
|
}
|
||||||
|
// The Span.enter() guard pattern doesn't play nicely async
|
||||||
|
}.instrument(trace_span!("AppSession::from_request_parts()")).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue