Struct tower_http::trace::Trace
source · [−]pub struct Trace<S, M, MakeSpan = DefaultMakeSpan, OnRequest = DefaultOnRequest, OnResponse = DefaultOnResponse, OnBodyChunk = DefaultOnBodyChunk, OnEos = DefaultOnEos, OnFailure = DefaultOnFailure> { /* private fields */ }
trace
only.Expand description
Middleware that adds high level tracing to a Service
.
See the module docs for an example.
Implementations
Create a new Trace
using the given MakeClassifier
.
Returns a new Layer
that wraps services with a TraceLayer
middleware.
Consumes self
, returning the underlying service.
pub fn on_request<NewOnRequest>(
self,
new_on_request: NewOnRequest
) -> Trace<S, M, MakeSpan, NewOnRequest, OnResponse, OnBodyChunk, OnEos, OnFailure>
pub fn on_request<NewOnRequest>(
self,
new_on_request: NewOnRequest
) -> Trace<S, M, MakeSpan, NewOnRequest, OnResponse, OnBodyChunk, OnEos, OnFailure>
Customize what to do when a request is received.
NewOnRequest
is expected to implement OnRequest
.
pub fn on_response<NewOnResponse>(
self,
new_on_response: NewOnResponse
) -> Trace<S, M, MakeSpan, OnRequest, NewOnResponse, OnBodyChunk, OnEos, OnFailure>
pub fn on_response<NewOnResponse>(
self,
new_on_response: NewOnResponse
) -> Trace<S, M, MakeSpan, OnRequest, NewOnResponse, OnBodyChunk, OnEos, OnFailure>
Customize what to do when a response has been produced.
NewOnResponse
is expected to implement OnResponse
.
pub fn on_body_chunk<NewOnBodyChunk>(
self,
new_on_body_chunk: NewOnBodyChunk
) -> Trace<S, M, MakeSpan, OnRequest, OnResponse, NewOnBodyChunk, OnEos, OnFailure>
pub fn on_body_chunk<NewOnBodyChunk>(
self,
new_on_body_chunk: NewOnBodyChunk
) -> Trace<S, M, MakeSpan, OnRequest, OnResponse, NewOnBodyChunk, OnEos, OnFailure>
Customize what to do when a body chunk has been sent.
NewOnBodyChunk
is expected to implement OnBodyChunk
.
Customize what to do when a streaming response has closed.
NewOnEos
is expected to implement OnEos
.
pub fn on_failure<NewOnFailure>(
self,
new_on_failure: NewOnFailure
) -> Trace<S, M, MakeSpan, OnRequest, OnResponse, OnBodyChunk, OnEos, NewOnFailure>
pub fn on_failure<NewOnFailure>(
self,
new_on_failure: NewOnFailure
) -> Trace<S, M, MakeSpan, OnRequest, OnResponse, OnBodyChunk, OnEos, NewOnFailure>
Customize what to do when a response has been classified as a failure.
NewOnFailure
is expected to implement OnFailure
.
pub fn make_span_with<NewMakeSpan>(
self,
new_make_span: NewMakeSpan
) -> Trace<S, M, NewMakeSpan, OnRequest, OnResponse, OnBodyChunk, OnEos, OnFailure>
pub fn make_span_with<NewMakeSpan>(
self,
new_make_span: NewMakeSpan
) -> Trace<S, M, NewMakeSpan, OnRequest, OnResponse, OnBodyChunk, OnEos, OnFailure>
Create a new Trace
using ServerErrorsAsFailures
which supports classifying
regular HTTP responses based on the status code.
Create a new Trace
using GrpcErrorsAsFailures
which supports classifying
gRPC responses and streams based on the grpc-status
header.
Trait Implementations
impl<S, ReqBody, ResBody, M, OnRequestT, OnResponseT, OnFailureT, OnBodyChunkT, OnEosT, MakeSpanT> Service<Request<ReqBody>> for Trace<S, M, MakeSpanT, OnRequestT, OnResponseT, OnBodyChunkT, OnEosT, OnFailureT> where
S: Service<Request<ReqBody>, Response = Response<ResBody>>,
ReqBody: Body,
ResBody: Body,
ResBody::Error: Display + 'static,
S::Error: Display + 'static,
M: MakeClassifier,
M::Classifier: Clone,
MakeSpanT: MakeSpan<ReqBody>,
OnRequestT: OnRequest<ReqBody>,
OnResponseT: OnResponse<ResBody> + Clone,
OnBodyChunkT: OnBodyChunk<ResBody::Data> + Clone,
OnEosT: OnEos + Clone,
OnFailureT: OnFailure<M::FailureClass> + Clone,
impl<S, ReqBody, ResBody, M, OnRequestT, OnResponseT, OnFailureT, OnBodyChunkT, OnEosT, MakeSpanT> Service<Request<ReqBody>> for Trace<S, M, MakeSpanT, OnRequestT, OnResponseT, OnBodyChunkT, OnEosT, OnFailureT> where
S: Service<Request<ReqBody>, Response = Response<ResBody>>,
ReqBody: Body,
ResBody: Body,
ResBody::Error: Display + 'static,
S::Error: Display + 'static,
M: MakeClassifier,
M::Classifier: Clone,
MakeSpanT: MakeSpan<ReqBody>,
OnRequestT: OnRequest<ReqBody>,
OnResponseT: OnResponse<ResBody> + Clone,
OnBodyChunkT: OnBodyChunk<ResBody::Data> + Clone,
OnEosT: OnEos + Clone,
OnFailureT: OnFailure<M::FailureClass> + Clone,
type Response = Response<ResponseBody<ResBody, M::ClassifyEos, OnBodyChunkT, OnEosT, OnFailureT>>
type Response = Response<ResponseBody<ResBody, M::ClassifyEos, OnBodyChunkT, OnEosT, OnFailureT>>
Responses given by the service.
type Future = ResponseFuture<S::Future, M::Classifier, OnResponseT, OnBodyChunkT, OnEosT, OnFailureT>
type Future = ResponseFuture<S::Future, M::Classifier, OnResponseT, OnBodyChunkT, OnEosT, OnFailureT>
The future response value.
Returns Poll::Ready(Ok(()))
when the service is able to process requests. Read more
Auto Trait Implementations
impl<S, M, MakeSpan, OnRequest, OnResponse, OnBodyChunk, OnEos, OnFailure> RefUnwindSafe for Trace<S, M, MakeSpan, OnRequest, OnResponse, OnBodyChunk, OnEos, OnFailure> where
M: RefUnwindSafe,
MakeSpan: RefUnwindSafe,
OnBodyChunk: RefUnwindSafe,
OnEos: RefUnwindSafe,
OnFailure: RefUnwindSafe,
OnRequest: RefUnwindSafe,
OnResponse: RefUnwindSafe,
S: RefUnwindSafe,
impl<S, M, MakeSpan, OnRequest, OnResponse, OnBodyChunk, OnEos, OnFailure> Send for Trace<S, M, MakeSpan, OnRequest, OnResponse, OnBodyChunk, OnEos, OnFailure> where
M: Send,
MakeSpan: Send,
OnBodyChunk: Send,
OnEos: Send,
OnFailure: Send,
OnRequest: Send,
OnResponse: Send,
S: Send,
impl<S, M, MakeSpan, OnRequest, OnResponse, OnBodyChunk, OnEos, OnFailure> Sync for Trace<S, M, MakeSpan, OnRequest, OnResponse, OnBodyChunk, OnEos, OnFailure> where
M: Sync,
MakeSpan: Sync,
OnBodyChunk: Sync,
OnEos: Sync,
OnFailure: Sync,
OnRequest: Sync,
OnResponse: Sync,
S: Sync,
impl<S, M, MakeSpan, OnRequest, OnResponse, OnBodyChunk, OnEos, OnFailure> Unpin for Trace<S, M, MakeSpan, OnRequest, OnResponse, OnBodyChunk, OnEos, OnFailure> where
M: Unpin,
MakeSpan: Unpin,
OnBodyChunk: Unpin,
OnEos: Unpin,
OnFailure: Unpin,
OnRequest: Unpin,
OnResponse: Unpin,
S: Unpin,
impl<S, M, MakeSpan, OnRequest, OnResponse, OnBodyChunk, OnEos, OnFailure> UnwindSafe for Trace<S, M, MakeSpan, OnRequest, OnResponse, OnBodyChunk, OnEos, OnFailure> where
M: UnwindSafe,
MakeSpan: UnwindSafe,
OnBodyChunk: UnwindSafe,
OnEos: UnwindSafe,
OnFailure: UnwindSafe,
OnRequest: UnwindSafe,
OnResponse: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
follow-redirect
only.Create a new Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more
Yields a mutable reference to the service when it is ready to accept a request.
please use the ServiceExt::ready
method instead
Yields a mutable reference to the service when it is ready to accept a request.
Yields the service when it is ready to accept a request.
Consume this Service
, calling with the providing request once it is ready.
Executes a new future after this service’s future resolves. This does
not alter the behaviour of the poll_ready
method. Read more
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F> where
F: FnOnce(Self::Response) -> Response + Clone,
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F> where
F: FnOnce(Self::Response) -> Response + Clone,
Maps this service’s response value to a different value. This does not
alter the behaviour of the poll_ready
method. Read more
Maps this service’s error value to a different value. This does not
alter the behaviour of the poll_ready
method. Read more
Maps this service’s result type (Result<Self::Response, Self::Error>
)
to a different value, regardless of whether the future succeeds or
fails. Read more
fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F> where
F: FnMut(NewRequest) -> Request,
fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F> where
F: FnMut(NewRequest) -> Request,
Composes a function in front of the service. Read more
Composes an asynchronous function after this service. Read more
Composes a function that transforms futures produced by the service. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more