dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.44k stars 10.01k forks source link

Log HTTP Request and Response Trailers #31840

Open jkotalik opened 3 years ago

jkotalik commented 3 years ago

As a follow up to https://github.com/dotnet/aspnetcore/pull/31816, we should log Http Request and Response trailers if available.

I see a few potential issues:

JamesNK commented 3 years ago

@Tratcher @halter73 @davidfowl

The trick here will be logging them when they are all available and before they disappear. This will be especially true with response trailers. With them you'll need to wait until the response body has finished writing (someone could add a trailer at any time while the response is writing) but before the response ends.

Tratcher commented 3 years ago

Logging the response trailers as the middleware exits should be adequate, it will capture trailers added by anything after it. That does leave a window between this middleware and the start of the pipeline where someone else could add trailers, but that seems like a tradeoff people would be able to understand. In theory you could have the same problem with response headers when there's no body.

Request trailers could be logged when the end of the request body is read (we'll be wrapping the body so we'll know), or when the middleware exits.

ghost commented 3 years ago

Thanks for contacting us. We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. Because it's not immediately obvious that this is a bug in our framework, we would like to keep this around to collect more feedback, which can later help us determine the impact of it. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

ghost commented 3 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

adityamandaleeka commented 2 years ago

@wtgodbe @Tratcher Have we seen any demand for this? I'm inclined to move it back to backlog.

Tratcher commented 2 years ago

gRPC would be the main scenario. @JamesNK?

JamesNK commented 2 years ago

gRPC uses response trailers. Important information - grpc-status (i.e. did the RPC succeed) - is sent via trailers.

JamesNK commented 2 years ago

~(I think it should be left here for .NET 8)~ I think it should be moved to .NET 8 planning.

adityamandaleeka commented 2 years ago

Done.