http_client: log each attempt at sending a request, instead of a single one

When a request fails because of the exponential backoff, it won't be
re-logged again. It would be useful, for the purposes of the send queue
notably, to see when a request is re-attempted.
This commit is contained in:
Benjamin Bouvier
2024-07-04 17:34:42 +02:00
parent b80c2f7197
commit d6300bbda7
3 changed files with 5 additions and 3 deletions

View File

@@ -221,8 +221,6 @@ impl HttpClient {
// will be automatically dropped at the end of this function
let _handle = self.concurrent_request_semaphore.acquire().await;
debug!("Sending request");
// There's a bunch of state in send_request, factor out a pinned inner
// future to reduce this size of futures that await this function.
match Box::pin(self.send_request::<R>(request, config, send_progress)).await {

View File

@@ -26,7 +26,7 @@ use eyeball::SharedObservable;
use http::header::CONTENT_LENGTH;
use reqwest::Certificate;
use ruma::api::{error::FromHttpResponseError, IncomingResponse, OutgoingRequest};
use tracing::{info, warn};
use tracing::{debug, info, warn};
use super::{response_to_http_response, HttpClient, TransmissionProgress, DEFAULT_REQUEST_TIMEOUT};
use crate::{
@@ -52,6 +52,8 @@ impl HttpClient {
let send_request = || {
let send_progress = send_progress.clone();
async {
debug!(num_attempt = retry_count.load(Ordering::SeqCst), "Sending request");
let stop = if let Some(retry_limit) = config.retry_limit {
retry_count.fetch_add(1, Ordering::Relaxed) >= retry_limit
} else {

View File

@@ -33,6 +33,8 @@ impl HttpClient {
R: OutgoingRequest + Debug,
HttpError: From<FromHttpResponseError<R::EndpointError>>,
{
tracing::debug!("Sending request");
let request = reqwest::Request::try_from(request)?;
let response = response_to_http_response(self.inner.execute(request).await?).await?;