项目作者: vicanso

项目描述 :
http trace
高级语言: Go
项目地址: git://github.com/vicanso/http-trace.git
创建时间: 2019-06-24T13:01:25Z
项目社区:https://github.com/vicanso/http-trace

开源协议:Apache License 2.0

下载


http trace

Build Status

HTTP Request trace, timing and request’s information.
Timing include dns, connect, tls, first response byte and so on.

events:

  • GetConn
  • DNSStart
  • DNSDone
  • ConnectStart
  • ConnectDone
  • TLSHandshakeStart
  • TLSHandshakeDone
  • GotConn
  • WroteHeaders
  • WroteRequest
  • GotFirstResponseByte
  1. trace, ht := NewClientTrace()
  2. ctx := context.Background()
  3. ctx = httptrace.WithClientTrace(ctx, trace)
  4. req, _ := http.NewRequest("GET", "https://www.baidu.com/", nil)
  5. req = req.WithContext(ctx)
  6. resp, _ := http.DefaultClient.Do(req)
  7. ht.Finish()
  8. stats := ht.Stats()
  9. fmt.Println(stats)
  10. fmt.Println(resp.Status)