From 4e453e0db2aa62dd96545cd1d368ed10d5964448 Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Fri, 15 Jul 2022 12:36:29 -0400 Subject: [PATCH] measure reddit latency when we finish reading the body --- internal/reddit/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/reddit/client.go b/internal/reddit/client.go index 84ee0bf..2a6faa1 100644 --- a/internal/reddit/client.go +++ b/internal/reddit/client.go @@ -149,7 +149,6 @@ func (rc *Client) doRequest(ctx context.Context, r *Request) ([]byte, *RateLimit resp, err := client.Do(req) _ = rc.statsd.Incr("reddit.api.calls", r.tags, 0.1) - _ = rc.statsd.Histogram("reddit.api.latency", float64(time.Since(start).Milliseconds()), r.tags, 0.1) if err != nil { _ = rc.statsd.Incr("reddit.api.errors", r.tags, 0.1) @@ -170,6 +169,7 @@ func (rc *Client) doRequest(ctx context.Context, r *Request) ([]byte, *RateLimit } bb, err := ioutil.ReadAll(resp.Body) + _ = rc.statsd.Histogram("reddit.api.latency", float64(time.Since(start).Milliseconds()), r.tags, 0.1) switch resp.StatusCode { case 200: