diff --git a/libsignal-service/src/account_manager.rs b/libsignal-service/src/account_manager.rs index 0ca2abad9..379913054 100644 --- a/libsignal-service/src/account_manager.rs +++ b/libsignal-service/src/account_manager.rs @@ -626,6 +626,7 @@ impl AccountManager { /// Should be called as the primary device to migrate from pre-PNI to PNI. /// /// This is the equivalent of Android's PnpInitializeDevicesJob or iOS' PniHelloWorldManager. + #[tracing::instrument(skip(self, aci_protocol_store, pni_protocol_store, sender, local_aci, csprng), fields(local_aci = %local_aci))] pub async fn pnp_initialize_devices< // XXX So many constraints here, all imposed by the MessageSender R: rand::Rng + rand::CryptoRng, diff --git a/libsignal-service/src/sender.rs b/libsignal-service/src/sender.rs index f0c8fcfd7..dca9ba03e 100644 --- a/libsignal-service/src/sender.rs +++ b/libsignal-service/src/sender.rs @@ -315,8 +315,8 @@ where /// Send a message `content` to a single `recipient`. #[tracing::instrument( - skip(self, unidentified_access, message), - fields(unidentified_access = unidentified_access.is_some()), + skip(self, unidentified_access, message, recipient), + fields(unidentified_access = unidentified_access.is_some(), recipient = %recipient), )] pub async fn send_message( &mut self, @@ -496,8 +496,8 @@ where /// Send a message (`content`) to an address (`recipient`). #[tracing::instrument( level = "trace", - skip(self, unidentified_access, content_body), - fields(unidentified_access = unidentified_access.is_some()), + skip(self, unidentified_access, content_body, recipient), + fields(unidentified_access = unidentified_access.is_some(), recipient = %recipient), )] async fn try_send_message( &mut self, @@ -646,8 +646,8 @@ where /// Upload contact details to the CDN and send a sync message #[tracing::instrument( - skip(self, unidentified_access, contacts), - fields(unidentified_access = unidentified_access.is_some()), + skip(self, unidentified_access, contacts, recipient), + fields(unidentified_access = unidentified_access.is_some(), recipient = %recipient), )] pub async fn send_contact_details( &mut self, @@ -687,7 +687,7 @@ where } /// Send `Configuration` synchronization message - #[tracing::instrument(skip(self))] + #[tracing::instrument(skip(self, recipient), fields(recipient = %recipient))] pub async fn send_configuration( &mut self, recipient: &ServiceAddress, @@ -706,7 +706,7 @@ where } /// Send `MessageRequestResponse` synchronization message with either a recipient ACI or a GroupV2 ID - #[tracing::instrument(skip(self))] + #[tracing::instrument(skip(self, recipient), fields(recipient = %recipient))] pub async fn send_message_request_response( &mut self, recipient: &ServiceAddress, @@ -772,8 +772,8 @@ where // Equivalent with `getEncryptedMessages` #[tracing::instrument( level = "trace", - skip(self, unidentified_access, content), - fields(unidentified_access = unidentified_access.is_some()), + skip(self, unidentified_access, content, recipient), + fields(unidentified_access = unidentified_access.is_some(), recipient = %recipient), )] async fn create_encrypted_messages( &mut self, @@ -882,8 +882,8 @@ where /// When no session with the recipient exists, we need to create one. #[tracing::instrument( level = "trace", - skip(self, unidentified_access, content), - fields(unidentified_access = unidentified_access.is_some()), + skip(self, unidentified_access, content, recipient), + fields(unidentified_access = unidentified_access.is_some(), recipient = %recipient), )] pub(crate) async fn create_encrypted_message( &mut self, diff --git a/libsignal-service/src/service_address.rs b/libsignal-service/src/service_address.rs index 912c06503..de3c74267 100644 --- a/libsignal-service/src/service_address.rs +++ b/libsignal-service/src/service_address.rs @@ -20,6 +20,18 @@ pub struct ServiceAddress { pub identity: ServiceIdType, } +impl std::fmt::Display for ServiceAddress { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + // This is used in ServiceAddress::to_service_id(&self), so keep this consistent. + match self.identity { + ServiceIdType::AccountIdentity => write!(f, "{}", self.uuid), + ServiceIdType::PhoneNumberIdentity => { + write!(f, "PNI:{}", self.uuid) + }, + } + } +} + impl ServiceAddress { pub fn to_protocol_address( &self, @@ -71,12 +83,7 @@ impl ServiceAddress { } pub fn to_service_id(&self) -> String { - match self.identity { - ServiceIdType::AccountIdentity => self.uuid.to_string(), - ServiceIdType::PhoneNumberIdentity => { - format!("PNI:{}", self.uuid) - }, - } + self.to_string() } }