mirror of
https://github.com/tokio-rs/tracing.git
synced 2025-10-02 15:24:47 +00:00
fix span entry in hyper example
This commit is contained in:
parent
9008d14497
commit
b2e60146aa
@ -79,19 +79,22 @@ fn echo(req: Request<Body>) -> Instrumented<BoxFut> {
|
|||||||
// future, waiting on concatenating the full body, so that
|
// future, waiting on concatenating the full body, so that
|
||||||
// it can be reversed. Only then can we return a `Response`.
|
// it can be reversed. Only then can we return a `Response`.
|
||||||
(&Method::POST, "/echo/reversed") => {
|
(&Method::POST, "/echo/reversed") => {
|
||||||
let reversed = req.into_body().concat2().map(move |chunk| {
|
let span = span!("response", response_kind = "reversed");
|
||||||
let body = chunk.iter().rev().cloned().collect::<Vec<u8>>();
|
let reversed = span.clone().enter(|| {
|
||||||
event!(Level::Debug,
|
req.into_body().concat2().map(move |chunk| {
|
||||||
{
|
let body = chunk.iter().rev().cloned().collect::<Vec<u8>>();
|
||||||
chunk = str::from_utf8(&chunk[..]),
|
event!(Level::Debug,
|
||||||
reversed = str::from_utf8(&body[..])
|
{
|
||||||
},
|
chunk = str::from_utf8(&chunk[..]),
|
||||||
"reversed request body");
|
reversed = str::from_utf8(&body[..])
|
||||||
*response.body_mut() = Body::from(body);
|
},
|
||||||
response
|
"reversed request body");
|
||||||
|
*response.body_mut() = Body::from(body);
|
||||||
|
response
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
(span!("response", response_kind = "reversed"), Box::new(reversed))
|
(span, Box::new(reversed))
|
||||||
}
|
}
|
||||||
|
|
||||||
// The 404 Not Found route...
|
// The 404 Not Found route...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user