Fix memory leak in metrics

Co-authored-by: Ludovic Fernandez <ldez@users.noreply.github.com>
This commit is contained in:
Julien Salleyron
2020-03-19 13:48:04 +01:00
committed by GitHub
parent 683d5d5a48
commit b40fa61783
3 changed files with 13 additions and 31 deletions

View File

@@ -96,11 +96,9 @@ func (m *metricsMiddleware) ServeHTTP(rw http.ResponseWriter, req *http.Request)
labels = append(labels, "code", strconv.Itoa(recorder.getCode()))
histograms := m.reqDurationHistogram.With(labels...)
histograms.StartAt(start)
histograms.ObserveFromStart(start)
m.reqsCounter.With(labels...).Add(1)
histograms.ObserveDuration()
}
func getRequestProtocol(req *http.Request) string {