Tracing HTTP request latency in golang

httpstat as a golang package

reorx/httpstat ( and followed @davecheney’s golang implementation ) is getting hot recently ( there is also node implementation !) . It’s very useful to see these latency with intuitive way in console when something wrong happens on network.

While contributing the project, I thought it’s very useful if I can output the same information on my own golang HTTP client ( or my network connected CLI tool ) when debugging. So I wrote a small package to do this, https://github.com/tcnksm/go-httpstat .

Because it creates a httptrace powered `context.Context`, you just need to pass it to your `http.Request` by `withContext()` method ( So must be less code modification !).

The following is an example usage of this package (trace request to https://github.com ).

The result of this is like below,

The results are pretty much same as `httpstat` command. But there are some concerns about TLS handshaking time (see #7). Be care to use this in production as for now. I’ll continue to improve this.

If you find a something, please file a issue on Github.

Principal YAML engineer at Mercari platform group. https;://twitter.com/deeeet

Principal YAML engineer at Mercari platform group. https;://twitter.com/deeeet