Log warning if activity sending is slow (#127)

This commit is contained in:
Nutomic 2024-09-19 12:22:48 +02:00 committed by GitHub
parent a35c8cbea5
commit df8876c096
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -24,9 +24,9 @@ use rsa::{pkcs8::DecodePrivateKey, RsaPrivateKey};
use serde::Serialize; use serde::Serialize;
use std::{ use std::{
fmt::{Debug, Display}, fmt::{Debug, Display},
time::{Duration, SystemTime}, time::{Duration, Instant, SystemTime},
}; };
use tracing::debug; use tracing::{debug, warn};
use url::Url; use url::Url;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -92,7 +92,17 @@ impl SendActivityTask {
self.http_signature_compat, self.http_signature_compat,
) )
.await?; .await?;
// Send the activity, and log a warning if its too slow.
let now = Instant::now();
let response = client.execute(request).await?; 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 self.handle_response(response).await
} }