pub struct InstrumentedClientRequest { /* private fields */ }
Available on crate feature
awc
only.Expand description
A wrapper for the actix-web awc::ClientRequest.
Implementations§
Source§impl InstrumentedClientRequest
impl InstrumentedClientRequest
Sourcepub async fn send(
self,
) -> Result<ClientResponse<Decoder<Payload<BoxedPayloadStream>>>, SendRequestError>
pub async fn send( self, ) -> Result<ClientResponse<Decoder<Payload<BoxedPayloadStream>>>, SendRequestError>
Generate an awc::ClientResponse
from a traced request with an empty body.
Sourcepub async fn send_body<B>(
self,
body: B,
) -> Result<ClientResponse<Decoder<Payload<BoxedPayloadStream>>>, SendRequestError>where
B: MessageBody + 'static,
pub async fn send_body<B>(
self,
body: B,
) -> Result<ClientResponse<Decoder<Payload<BoxedPayloadStream>>>, SendRequestError>where
B: MessageBody + 'static,
Generate an awc::ClientResponse from a traced request with the given body.
Sourcepub async fn send_form<T: Serialize>(
self,
value: &T,
) -> Result<ClientResponse<Decoder<Payload<BoxedPayloadStream>>>, SendRequestError>
pub async fn send_form<T: Serialize>( self, value: &T, ) -> Result<ClientResponse<Decoder<Payload<BoxedPayloadStream>>>, SendRequestError>
Generate an awc::ClientResponse from a traced request with the given form body.
Sourcepub async fn send_json<T: Serialize>(
self,
value: &T,
) -> Result<ClientResponse<Decoder<Payload<BoxedPayloadStream>>>, SendRequestError>
pub async fn send_json<T: Serialize>( self, value: &T, ) -> Result<ClientResponse<Decoder<Payload<BoxedPayloadStream>>>, SendRequestError>
Generate an awc::ClientResponse from a traced request with the given JSON body.
Sourcepub async fn send_stream<S, E>(
self,
stream: S,
) -> Result<ClientResponse<Decoder<Payload<BoxedPayloadStream>>>, SendRequestError>
pub async fn send_stream<S, E>( self, stream: S, ) -> Result<ClientResponse<Decoder<Payload<BoxedPayloadStream>>>, SendRequestError>
Generate an awc::ClientResponse from a traced request with the given stream body.
Sourcepub fn with_attributes(
self,
attrs: impl IntoIterator<Item = KeyValue>,
) -> InstrumentedClientRequest
pub fn with_attributes( self, attrs: impl IntoIterator<Item = KeyValue>, ) -> InstrumentedClientRequest
Add additional attributes to the instrumented span for a given request.
The standard otel attributes will still be tracked.
Example:
use actix_web_opentelemetry::ClientExt;
use awc::{Client, error::SendRequestError};
use opentelemetry::KeyValue;
async fn execute_request(client: &Client) -> Result<(), SendRequestError> {
let attrs = [KeyValue::new("dye-key", "dye-value")];
let res = client.get("http://localhost:8080")
// Add `trace_request` before `send` to any awc request to add instrumentation
.trace_request()
.with_attributes(attrs)
.send()
.await?;
println!("Response: {:?}", res);
Ok(())
}
Sourcepub fn with_span_namer(
self,
span_namer: fn(&ClientRequest) -> String,
) -> InstrumentedClientRequest
pub fn with_span_namer( self, span_namer: fn(&ClientRequest) -> String, ) -> InstrumentedClientRequest
Customise the Span Name, for example to reduce cardinality
Example:
use actix_web_opentelemetry::ClientExt;
use awc::{Client, error::SendRequestError};
async fn execute_request(client: &Client) -> Result<(), SendRequestError> {
let res = client.get("http://localhost:8080")
// Add `trace_request` before `send` to any awc request to add instrumentation
.trace_request()
.with_span_namer(|r| format!("HTTP {}", r.get_method()))
.send()
.await?;
println!("Response: {:?}", res);
Ok(())
}
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for InstrumentedClientRequest
impl !RefUnwindSafe for InstrumentedClientRequest
impl !Send for InstrumentedClientRequest
impl !Sync for InstrumentedClientRequest
impl Unpin for InstrumentedClientRequest
impl !UnwindSafe for InstrumentedClientRequest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more