pub struct Trace { /* private fields */ }Expand description
Joins each request to its trace, and puts the trace on the log line.
Outermost in the global stack, so every log emitted while handling the request carries the trace id — including the ones from middleware that rejected it, which are the lines you most want to find later.
MiddlewareStack::new().push(Trace::new()).push(RecordMetrics::new(metrics))§What it does without an exporter
Everything except send spans anywhere. The trace id is on the request, on
the response and on every log line, so a request can be followed across
services by grepping — which is most of the value, and it costs no
dependency. The otlp feature adds the exporter.
Implementations§
Source§impl Trace
impl Trace
Sourcepub fn sampling(self, sample: bool) -> Trace
pub fn sampling(self, sample: bool) -> Trace
Whether to sample a trace this service starts.
Only applies when there is no incoming traceparent: a decision made
upstream is honoured, because a trace sampled in half its services is a
trace with holes in it.
Sourcepub fn respond_with_header(self, respond: bool) -> Trace
pub fn respond_with_header(self, respond: bool) -> Trace
Whether to return traceparent on the response.
On by default, and it is what lets somebody paste a trace id from a browser’s network tab into a trace viewer. Turn it off if you would rather not tell a client your trace ids.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Trace
impl RefUnwindSafe for Trace
impl Send for Trace
impl Sync for Trace
impl Unpin for Trace
impl UnsafeUnpin for Trace
impl UnwindSafe for Trace
Blanket Implementations§
impl<T> Actor for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> ConcreteMiddleware for Twhere
T: Middleware,
impl<T> ConcreteMiddleware for Twhere
T: Middleware,
Source§fn concrete_type_id(&self) -> TypeId
fn concrete_type_id(&self) -> TypeId
TypeId of the implementing type.Source§fn concrete_type_name(&self) -> &'static str
fn concrete_type_name(&self) -> &'static str
Source§impl<T> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more