pub struct InstrumentedClientRequest { /* private fields */ }Expand description
A wrapper for the actix-web awc::ClientRequest.
Implementations
sourceimpl 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>where
S: Stream<Item = Result<Bytes, E>> + Unpin + 'static,
E: Error + Into<Error> + 'static,
pub async fn send_stream<S, E>(
self,
stream: S
) -> Result<ClientResponse<Decoder<Payload<BoxedPayloadStream>>>, SendRequestError>where
S: Stream<Item = Result<Bytes, E>> + Unpin + 'static,
E: Error + Into<Error> + 'static,
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 !RefUnwindSafe for InstrumentedClientRequest
impl !Send for InstrumentedClientRequest
impl !Sync for InstrumentedClientRequest
impl Unpin for InstrumentedClientRequest
impl !UnwindSafe for InstrumentedClientRequest
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more