Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/blocking/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@ pub trait Client {

/// This method provides a common interface to
/// [Endpoints][crate::endpoint::Endpoint] for execution.
#[instrument(skip(self, req), err)]
#[instrument(skip(self, req), fields(uri=%req.uri(), method=%req.method()), err)]
fn execute(&self, req: Request<Vec<u8>>) -> Result<Response<Vec<u8>>, ClientError> {
debug!(
"Client sending {} request to {} with {} bytes of data",
req.method().to_string(),
req.uri(),
req.body().len(),
name: "sending_request",
body_len=req.body().len(),
"Sending Request",
);
let response = self.send(req)?;

let status = response.status();
debug!(
"Client received {} response with {} bytes of body data",
response.status().as_u16(),
response.body().len()
name: "response_received",
status=status.as_u16(),
response_len=response.body().len(),
is_error=status.is_client_error() || status.is_server_error(),
"Response Received",
);

// Check response
Expand Down
19 changes: 10 additions & 9 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,21 @@ pub trait Client: Sync + Send {
// TODO: remove the allow when the upstream clippy issue is fixed:
// <https://github.com/rust-lang/rust-clippy/issues/12281>
#[allow(clippy::blocks_in_conditions)]
#[instrument(skip(self, req), err)]
#[instrument(skip(self, req), fields(uri=%req.uri(), method=%req.method()), err)]
async fn execute(&self, req: Request<Vec<u8>>) -> Result<Response<Vec<u8>>, ClientError> {
debug!(
"Client sending {} request to {} with {} bytes of data",
req.method().to_string(),
req.uri(),
req.body().len(),
name: "sending_request",
body_len=req.body().len(),
"Sending Request",
);
let response = self.send(req).await?;

let status = response.status();
debug!(
"Client received {} response with {} bytes of body data",
response.status().as_u16(),
response.body().len()
name: "response_received",
status=status.as_u16(),
response_len=response.body().len(),
is_error=status.is_client_error() || status.is_server_error(),
"Response Received",
);

// Check response
Expand Down
8 changes: 4 additions & 4 deletions src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<E: Endpoint, M: MiddleWare> Endpoint for MutatedEndpoint<'_, E, M> {
&self,
client: &impl Client,
) -> Result<EndpointResult<Self::Response>, ClientError> {
debug!("Executing endpoint");
trace!("Executing endpoint");

let req = self.request(client.base())?;
let resp = exec_mut(client, self, req, self.middleware).await?;
Expand All @@ -107,7 +107,7 @@ impl<E: Endpoint, M: MiddleWare> Endpoint for MutatedEndpoint<'_, E, M> {
&self,
client: &impl BlockingClient,
) -> Result<EndpointResult<Self::Response>, ClientError> {
debug!("Executing endpoint");
trace!("Executing endpoint");

let req = self.request(client.base())?;
let resp = exec_block_mut(client, self, req, self.middleware)?;
Expand Down Expand Up @@ -232,7 +232,7 @@ pub trait Endpoint: Send + Sync + Sized {
&self,
client: &impl Client,
) -> Result<EndpointResult<Self::Response>, ClientError> {
debug!("Executing endpoint");
trace!("Executing endpoint");

let req = self.request(client.base())?;
let resp = exec(client, req).await?;
Expand All @@ -250,7 +250,7 @@ pub trait Endpoint: Send + Sync + Sized {
&self,
client: &impl BlockingClient,
) -> Result<EndpointResult<Self::Response>, ClientError> {
debug!("Executing endpoint");
trace!("Executing endpoint");

let req = self.request(client.base())?;
let resp = exec_block(client, req)?;
Expand Down
2 changes: 1 addition & 1 deletion src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn build_request(
query: Option<String>,
data: Option<Vec<u8>>,
) -> Result<Request<Vec<u8>>, ClientError> {
debug!("Building endpoint request");
trace!("Building endpoint request");
let uri = build_url(base, path, query)?;

let method_err = method.clone();
Expand Down
Loading