pub struct TraceLayer { /* private fields */ }
Expand description
A Tower Layer
which decorates TraceService
.
§Example with Axum
use stackable_telemetry::AxumTraceLayer;
use axum::{routing::get, Router};
let trace_layer = AxumTraceLayer::new();
let router = Router::new()
.route("/", get(|| async { "Hello, World!" }))
.layer(trace_layer);
§Example with Webhook
The usage is even simpler when combined with the stackable_webhook
crate.
The webhook server has built-in support to automatically emit HTTP spans on
every incoming request.
use stackable_webhook::{WebhookServer, Options};
use axum::Router;
let router = Router::new();
let server = WebhookServer::new(router, Options::default());
This layer is implemented based on this official Tower guide.
Implementations§
Source§impl TraceLayer
impl TraceLayer
Sourcepub fn with_opt_in(self) -> Self
pub fn with_opt_in(self) -> Self
Enables various fields marked as opt-in by the specification.
This will require more computing power and will increase the latency. See https://opentelemetry.io/docs/specs/semconv/http/http-spans/
Trait Implementations§
Source§impl Clone for TraceLayer
impl Clone for TraceLayer
Source§fn clone(&self) -> TraceLayer
fn clone(&self) -> TraceLayer
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for TraceLayer
impl Debug for TraceLayer
Source§impl Default for TraceLayer
impl Default for TraceLayer
Source§fn default() -> TraceLayer
fn default() -> TraceLayer
Returns the “default value” for a type. Read more
Source§impl<S> Layer<S> for TraceLayer
impl<S> Layer<S> for TraceLayer
Auto Trait Implementations§
impl Freeze for TraceLayer
impl RefUnwindSafe for TraceLayer
impl Send for TraceLayer
impl Sync for TraceLayer
impl Unpin for TraceLayer
impl UnwindSafe for TraceLayer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request