From df8876c096c9aaacf398ed7518dc83215796660b Mon Sep 17 00:00:00 2001 From: Nutomic Date: Thu, 19 Sep 2024 12:22:48 +0200 Subject: [PATCH] Log warning if activity sending is slow (#127) --- src/activity_sending.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/activity_sending.rs b/src/activity_sending.rs index 45efeb8..1c84757 100644 --- a/src/activity_sending.rs +++ b/src/activity_sending.rs @@ -24,9 +24,9 @@ use rsa::{pkcs8::DecodePrivateKey, RsaPrivateKey}; use serde::Serialize; use std::{ fmt::{Debug, Display}, - time::{Duration, SystemTime}, + time::{Duration, Instant, SystemTime}, }; -use tracing::debug; +use tracing::{debug, warn}; use url::Url; #[derive(Clone, Debug)] @@ -92,7 +92,17 @@ impl SendActivityTask { self.http_signature_compat, ) .await?; + + // Send the activity, and log a warning if its too slow. + let now = Instant::now(); let response = client.execute(request).await?; + let elapsed = now.elapsed().as_secs(); + if elapsed > 10 { + warn!( + "Sending activity {} to {} took {}s", + self.activity_id, self.inbox, elapsed + ); + } self.handle_response(response).await }