https://github.com/vicanso/http-trace
http trace
https://github.com/vicanso/http-trace
http-trace
Last synced: 8 months ago
JSON representation
http trace
- Host: GitHub
- URL: https://github.com/vicanso/http-trace
- Owner: vicanso
- License: apache-2.0
- Created: 2019-06-24T13:01:25.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-02-25T04:40:39.000Z (over 1 year ago)
- Last Synced: 2024-04-09T22:28:39.120Z (over 1 year ago)
- Topics: http-trace
- Language: Go
- Size: 66.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# http trace
[](https://github.com/vicanso/http-trace/actions)
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```go
trace, ht := NewClientTrace()
ctx := context.Background()
ctx = httptrace.WithClientTrace(ctx, trace)
req, _ := http.NewRequest("GET", "https://www.baidu.com/", nil)req = req.WithContext(ctx)
resp, _ := http.DefaultClient.Do(req)ht.Finish()
stats := ht.Stats()
fmt.Println(stats)
fmt.Println(resp.Status)
```