Consider a way to produce a network trace natively from Kestrel
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
One issue we have when debugging issues deep within Kestrel is that we need a network trace in order to make progress. Asking a user to do this is difficult as it involves complex tools like Wireshark (or `tcpdump` on Linux, which is admittedly easier). It also gets very complicated in an HTTP/2 and TLS-by-default world since everything is encrypted.
We have the Connection Logging feature that allows us to log individual bytes read for a connection which is cool, but having the bytes in a text log isn't much more helpful for us.
My proposal is that we provide a way to produce some kind of machine-readable trace that contains every byte sent/received by Kestrel, with as much data as we have. The best-case scenario would be to try to have this component "synthesize" a Wireshark `.pcap` file, since then it could be easily opened.
It's **not** a goal that this feature be a complete replacement for network traces, since we don't have the ability to capture TCP-level (and lower) data. But it would be a nice feature to allow for better diagnostics. We could perhaps use EventPipe for this and make a simple global tool (or integrate with `dotnet-trace`) so that a user can run a simple command `dotnet trace --profile KestrelNetworking -p [process id]` to capture the trace.
Contributor guide
Assessment
This issue has not been assessed yet.