server: Update tracing-forest and take advantage of the span fields
This commit is contained in:
committed by
nitnelave
parent
ce6bf7c548
commit
99ed6eface
@@ -423,7 +423,7 @@ where
|
||||
.unwrap_or_else(error_to_http_response)
|
||||
}
|
||||
|
||||
#[instrument(skip_all, level = "debug")]
|
||||
#[instrument(skip_all, level = "debug", fields(name = %request.name))]
|
||||
async fn post_authorize<Backend>(
|
||||
data: web::Data<AppState<Backend>>,
|
||||
request: web::Json<BindRequest>,
|
||||
@@ -432,7 +432,6 @@ where
|
||||
Backend: TcpBackendHandler + BackendHandler + LoginHandler + 'static,
|
||||
{
|
||||
let name = request.name.clone();
|
||||
debug!(%name);
|
||||
data.get_login_handler().bind(request.into_inner()).await?;
|
||||
get_login_successful_response(&data, &name).await
|
||||
}
|
||||
|
||||
@@ -48,7 +48,6 @@ impl Scheduler {
|
||||
|
||||
#[instrument(skip_all)]
|
||||
async fn cleanup_db(sql_pool: DbConnection) {
|
||||
info!("Cleaning DB");
|
||||
if let Err(e) = model::JwtRefreshStorage::delete_many()
|
||||
.filter(JwtRefreshStorageColumn::ExpiryDate.lt(chrono::Utc::now().naive_utc()))
|
||||
.exec(&sql_pool)
|
||||
@@ -70,7 +69,6 @@ impl Scheduler {
|
||||
{
|
||||
error!("DB error while cleaning up password reset tokens: {}", e);
|
||||
};
|
||||
info!("DB cleaned!");
|
||||
}
|
||||
|
||||
fn duration_until_next(&self) -> Duration {
|
||||
|
||||
@@ -69,7 +69,7 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[instrument(skip_all, level = "info", err)]
|
||||
#[instrument(level = "info", err)]
|
||||
pub async fn check_ldap(port: u16) -> Result<()> {
|
||||
check_ldap_endpoint(TcpStream::connect(format!("localhost:{}", port)).await?).await
|
||||
}
|
||||
@@ -126,7 +126,7 @@ fn get_tls_connector(ldaps_options: &LdapsOptions) -> Result<RustlsTlsConnector>
|
||||
Ok(std::sync::Arc::new(client_config).into())
|
||||
}
|
||||
|
||||
#[instrument(skip_all, level = "info", err)]
|
||||
#[instrument(skip_all, level = "info", err, fields(port = %ldaps_options.port))]
|
||||
pub async fn check_ldaps(ldaps_options: &LdapsOptions) -> Result<()> {
|
||||
if !ldaps_options.enabled {
|
||||
info!("LDAPS not enabled");
|
||||
@@ -150,7 +150,7 @@ pub async fn check_ldaps(ldaps_options: &LdapsOptions) -> Result<()> {
|
||||
.await
|
||||
}
|
||||
|
||||
#[instrument(skip_all, level = "info", err)]
|
||||
#[instrument(level = "info", err)]
|
||||
pub async fn check_api(port: u16) -> Result<()> {
|
||||
reqwest::get(format!("http://localhost:{}/health", port))
|
||||
.await?
|
||||
|
||||
@@ -243,9 +243,8 @@ impl<Backend: BackendHandler + LoginHandler + OpaqueHandler> LdapHandler<Backend
|
||||
)
|
||||
}
|
||||
|
||||
#[instrument(skip_all, level = "debug")]
|
||||
#[instrument(skip_all, level = "debug", fields(dn = %request.dn))]
|
||||
pub async fn do_bind(&mut self, request: &LdapBindRequest) -> (LdapResultCode, String) {
|
||||
debug!("DN: {}", &request.dn);
|
||||
let user_id = match get_user_id_from_distinguished_name(
|
||||
&request.dn.to_ascii_lowercase(),
|
||||
&self.ldap_info.base_dn,
|
||||
|
||||
@@ -3,8 +3,8 @@ use actix_web::{
|
||||
dev::{ServiceRequest, ServiceResponse},
|
||||
Error,
|
||||
};
|
||||
use tracing::{error, info, Span};
|
||||
use tracing_actix_web::{root_span, RootSpanBuilder};
|
||||
use tracing::{debug, error, Span};
|
||||
use tracing_actix_web::RootSpanBuilder;
|
||||
use tracing_subscriber::{filter::EnvFilter, layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
/// We will define a custom root span builder to capture additional fields, specific
|
||||
@@ -13,11 +13,11 @@ pub struct CustomRootSpanBuilder;
|
||||
|
||||
impl RootSpanBuilder for CustomRootSpanBuilder {
|
||||
fn on_request_start(request: &ServiceRequest) -> Span {
|
||||
let span = root_span!(request);
|
||||
span.in_scope(|| {
|
||||
info!(uri = %request.uri());
|
||||
});
|
||||
span
|
||||
tracing::debug_span!(
|
||||
"HTTP request",
|
||||
method = request.method().to_string(),
|
||||
uri = request.uri().to_string()
|
||||
)
|
||||
}
|
||||
|
||||
fn on_request_end<B>(_: Span, outcome: &Result<ServiceResponse<B>, Error>) {
|
||||
@@ -26,7 +26,7 @@ impl RootSpanBuilder for CustomRootSpanBuilder {
|
||||
if let Some(error) = response.response().error() {
|
||||
error!(?error);
|
||||
} else {
|
||||
info!(status_code = &response.response().status().as_u16());
|
||||
debug!(status_code = &response.response().status().as_u16());
|
||||
}
|
||||
}
|
||||
Err(error) => error!(?error),
|
||||
|
||||
Reference in New Issue
Block a user