How to log request body using tracing #1133
-
I'm looking for a way to log the request body using tracing, so far I have arrived at this attempt:
But it doesn't work because My next idea was maybe if I could have access to the Span in my service method where the request is available? I don't think its possible to have access to that tho. Is there a recommended approach of doing this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This is hard because the body is an async stream that can only be consumed once. I would recommend logging things in your handlers as necessary without relying on middleware. You can probably also write a middleware that does it but it's not simple. I don't believe we have any examples of doing that. |
Beta Was this translation helpful? Give feedback.
This is hard because the body is an async stream that can only be consumed once.
I would recommend logging things in your handlers as necessary without relying on middleware.
You can probably also write a middleware that does it but it's not simple. I don't believe we have any examples of doing that.