Skip to content
Discussion options

You must be logged in to vote

That is because you need to implement tower::Service and not hyper::Service:

impl<S> tower::Service<Request<Body>> for TraceIdService<S>
where
    S: tower::Service<Request<Body>>,
{
    type Response = S::Response;
    type Error = S::Error;
    type Future = Instrumented<S::Future>;

    fn poll_ready(&mut self, cx: &mut std::task::Context<'_>) -> std::task::Poll<Result<(), Self::Error>> {
        self.inner.poll_ready(cx)
    }

    fn call(&mut self, mut req: Request<Body>) -> Self::Future {
        let trace_id = TraceId::generate();
        let span = trace_span!("request", trace_id = trace_id.to_string());
        req.extensions_mut().insert(trace_id);
        self.inner.call(req).i…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by niconicoj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants