Trait actix_web_opentelemetry::ClientExt
source · [−]pub trait ClientExt {
fn trace_request_with_context(self, cx: Context) -> InstrumentedClientRequest;
fn trace_request(self) -> InstrumentedClientRequest
where
Self: Sized,
{ ... }
}Expand description
OpenTelemetry extensions for actix-web’s awc::Client.
Required Methods
sourcefn trace_request_with_context(self, cx: Context) -> InstrumentedClientRequest
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
sourcefn trace_request(self) -> InstrumentedClientRequestwhere
Self: Sized,
fn trace_request(self) -> InstrumentedClientRequestwhere
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(())
}