diff --git a/src/blocking/client.rs b/src/blocking/client.rs index ea06f2f..b458c39 100644 --- a/src/blocking/client.rs +++ b/src/blocking/client.rs @@ -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>) -> Result>, 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 diff --git a/src/client.rs b/src/client.rs index d8db7a9..4078d13 100644 --- a/src/client.rs +++ b/src/client.rs @@ -27,20 +27,21 @@ pub trait Client: Sync + Send { // TODO: remove the allow when the upstream clippy issue is fixed: // #[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>) -> Result>, 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 diff --git a/src/endpoint.rs b/src/endpoint.rs index 7b5bbe1..e91a66d 100644 --- a/src/endpoint.rs +++ b/src/endpoint.rs @@ -95,7 +95,7 @@ impl Endpoint for MutatedEndpoint<'_, E, M> { &self, client: &impl Client, ) -> Result, ClientError> { - debug!("Executing endpoint"); + trace!("Executing endpoint"); let req = self.request(client.base())?; let resp = exec_mut(client, self, req, self.middleware).await?; @@ -107,7 +107,7 @@ impl Endpoint for MutatedEndpoint<'_, E, M> { &self, client: &impl BlockingClient, ) -> Result, ClientError> { - debug!("Executing endpoint"); + trace!("Executing endpoint"); let req = self.request(client.base())?; let resp = exec_block_mut(client, self, req, self.middleware)?; @@ -232,7 +232,7 @@ pub trait Endpoint: Send + Sync + Sized { &self, client: &impl Client, ) -> Result, ClientError> { - debug!("Executing endpoint"); + trace!("Executing endpoint"); let req = self.request(client.base())?; let resp = exec(client, req).await?; @@ -250,7 +250,7 @@ pub trait Endpoint: Send + Sync + Sized { &self, client: &impl BlockingClient, ) -> Result, ClientError> { - debug!("Executing endpoint"); + trace!("Executing endpoint"); let req = self.request(client.base())?; let resp = exec_block(client, req)?; diff --git a/src/http.rs b/src/http.rs index 43dcf79..1d7c674 100644 --- a/src/http.rs +++ b/src/http.rs @@ -41,7 +41,7 @@ pub fn build_request( query: Option, data: Option>, ) -> Result>, ClientError> { - debug!("Building endpoint request"); + trace!("Building endpoint request"); let uri = build_url(base, path, query)?; let method_err = method.clone();