diff --git a/services/backup/src/http/handlers/backup.rs b/services/backup/src/http/handlers/backup.rs --- a/services/backup/src/http/handlers/backup.rs +++ b/services/backup/src/http/handlers/backup.rs @@ -19,19 +19,18 @@ error::BackupError, }; -#[instrument(name = "upload_backup", skip_all, fields(backup_id))] +#[instrument(skip_all, fields(%user, backup_id))] pub async fn upload( user: UserIdentity, blob_client: web::Data, db_client: web::Data, mut multipart: actix_multipart::Multipart, ) -> actix_web::Result { - info!("Upload backup request"); - let backup_id = get_named_text_field("backup_id", &mut multipart).await?; - tracing::Span::current().record("backup_id", &backup_id); + info!("Backup data upload started"); + let (user_keys_blob_info, user_keys_revoke) = forward_field_to_blob( &mut multipart, &blob_client, @@ -107,11 +106,7 @@ Ok(HttpResponse::Ok().finish()) } -#[instrument( - skip_all, - name = "forward_to_blob", - fields(hash_field_name, data_field_name) -)] +#[instrument(skip_all, fields(hash_field_name, data_field_name))] async fn forward_field_to_blob<'revoke, 'blob: 'revoke>( multipart: &mut actix_multipart::Multipart, blob_client: &'blob web::Data, @@ -180,7 +175,7 @@ Ok((blob_info, revoke_holder)) } -#[instrument(skip_all, name = "create_attachment_holder")] +#[instrument(skip_all)] async fn create_attachment_holder<'revoke, 'blob: 'revoke>( attachment: &str, blob_client: &'blob web::Data, @@ -204,7 +199,7 @@ Ok((holder, revoke_holder)) } -#[instrument(name = "download_user_keys", skip_all, fields(backup_id = %path.as_str()))] +#[instrument(skip_all, fields(%user, backup_id = %path))] pub async fn download_user_keys( user: UserIdentity, path: web::Path, @@ -223,7 +218,7 @@ .await } -#[instrument(name = "download_user_data", skip_all, fields(backup_id = %path.as_str()))] +#[instrument(skip_all, fields(%user, backup_id = %path))] pub async fn download_user_data( user: UserIdentity, path: web::Path, @@ -267,7 +262,7 @@ ) } -#[instrument(name = "get_latest_backup_id", skip_all, fields(username = %path.as_str()))] +#[instrument(skip_all, fields(username = %path))] pub async fn get_latest_backup_id( path: web::Path, db_client: web::Data, @@ -291,7 +286,7 @@ Ok(web::Json(response)) } -#[instrument(name = "download_latest_backup_keys", skip_all, fields(username = %path.as_str()))] +#[instrument(skip_all, fields(username = %path))] pub async fn download_latest_backup_keys( path: web::Path, db_client: web::Data, diff --git a/shared/comm-lib/src/auth/types.rs b/shared/comm-lib/src/auth/types.rs --- a/shared/comm-lib/src/auth/types.rs +++ b/shared/comm-lib/src/auth/types.rs @@ -2,7 +2,7 @@ use constant_time_eq::constant_time_eq; use derive_more::{Display, Error, From}; use serde::{Deserialize, Serialize}; -use std::{str::FromStr, string::FromUtf8Error}; +use std::{fmt::Display, str::FromStr, string::FromUtf8Error}; /// This implements [`actix_web::FromRequest`], so it can be used to extract user /// identity information from HTTP requests. @@ -108,6 +108,15 @@ } } +impl Display for UserIdentity { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("UserIdentity") + .field("user_id", &self.user_id) + .field("device_id", &self.device_id) + .finish_non_exhaustive() + } +} + #[derive(Debug, Display, Error, From)] pub enum AuthorizationCredentialParseError { Base64DecodeError(base64::DecodeError),