maybe measure idle time better

This commit is contained in:
Andre Medeiros 2021-07-07 22:41:27 -04:00
parent e56483dbb7
commit 8fb6adfae2

View file

@ -28,8 +28,10 @@ type Client struct {
func NewClient(id, secret string, statsd *statsd.Client) *Client {
tracer := &httptrace.ClientTrace{
GotConn: func(info httptrace.GotConnInfo) {
if info.Reused {
if info.WasIdle {
idleTime := float64(int64(info.IdleTime) / int64(time.Millisecond))
statsd.Incr("reddit.api.connections.reused", []string{}, 0.1)
statsd.Histogram("reddit.api.connections.idle_time", idleTime, []string{}, 0.1)
} else {
statsd.Incr("reddit.api.connections.created", []string{}, 0.1)
}