README
¶
go-httpstat

go-httpstat
is a golang package to trace golang HTTP request latency (DNSLookup, TCP Connection and so on). Because it uses httptrace
internally, just creating go-httpstat
powered context
and giving it your http.Request
kicks tracing (no big code modification is required). The original idea came from httpstat
command ( and Dave Cheney's golang implementation) 👏. This package now traces same latency infomation as them.
See usage and example on GoDoc.
NOTE: Since httptrace
was introduced after go1.7, this package may not work with old HTTP client. Especially, if you don't use net.DialContext
it can not trace DNS and connection.
Install
Use go get
,
$ go get github.com/tcnksm/go-httpstat
Author
Documentation
¶
Overview ¶
Package httpstat traces HTTP latency infomation (DNSLookup, TCP Connection and so on) on any golang HTTP request. It uses `httptrace` package. Just create `go-httpstat` powered `context.Context` and give it your `http.Request` (no big code modification is required).
Example ¶
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Result ¶
type Result struct { // The following are duration for each phase DNSLookup time.Duration TCPConnection time.Duration TLSHandshake time.Duration ServerProcessing time.Duration // DNS and connection Info IsIPv6 bool Addresses []net.IPAddr ConnectedTo net.Addr // The followings are timeline of request NameLookup time.Duration Connect time.Duration Pretransfer time.Duration StartTransfer time.Duration // contains filtered or unexported fields }
Result stores httpstat info.
func (*Result) ContentTransfer ¶
ContentTransfer returns the duration of content transfer time. It is from first response byte to the given time. The time must be time after read body (go-httpstat can not detect that time).
func (*Result) End ¶
End sets the time when reading response is done. This must be called after reading response body.