Trait ClientExt

Source
pub trait ClientExt {
    // Required method
    fn trace_request_with_context(
        self,
        cx: Context,
    ) -> InstrumentedClientRequest;

    // Provided method
    fn trace_request(self) -> InstrumentedClientRequest
       where Self: Sized { ... }
}
Available on crate feature awc only.
Expand description

OpenTelemetry extensions for actix-web’s awc::Client.

Required Methods§

Source

fn trace_request_with_context(self, cx: Context) -> InstrumentedClientRequest

Trace an awc::Client request using the given span context.

Example:

use actix_web_opentelemetry::ClientExt;
use awc::{Client, error::SendRequestError};
use opentelemetry::Context;

async fn execute_request(client: &Client) -> Result<(), SendRequestError> {
    let res = client.get("http://localhost:8080")
        // Add `trace_request_with_context` before `send` to any awc request to
        // add instrumentation
        .trace_request_with_context(Context::current())
        .send()
        .await?;

    println!("Response: {:?}", res);
    Ok(())
}

Provided Methods§

Source

fn trace_request(self) -> InstrumentedClientRequest
where Self: Sized,

Trace an awc::Client request using the current context.

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()
        .send()
        .await?;

    println!("Response: {:?}", res);
    Ok(())
}

Implementations on Foreign Types§

Source§

impl ClientExt for ClientRequest

Implementors§