Skip to content

Commit

Permalink
http_client: log each attempt at sending a request, instead of a sing…
Browse files Browse the repository at this point in the history
…le 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.
  • Loading branch information
bnjbvr committed Jul 4, 2024
1 parent 07b6425 commit 9570408
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 0 additions & 2 deletions crates/matrix-sdk/src/http_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion crates/matrix-sdk/src/http_client/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions crates/matrix-sdk/src/http_client/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;

Expand Down

0 comments on commit 9570408

Please sign in to comment.