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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 31 deletions

View file

@ -19,9 +19,9 @@ func TestScalableHistogram(t *testing.T) {
ticker := time.NewTicker(500 * time.Millisecond)
<-ticker.C
sh.StartAt(time.Now())
start := time.Now()
<-ticker.C
sh.ObserveDuration()
sh.ObserveFromStart(start)
var b bytes.Buffer
h.Print(&b)
@ -99,9 +99,7 @@ func (c *histogramMock) With(labelValues ...string) ScalableHistogram {
func (c *histogramMock) Start() {}
func (c *histogramMock) StartAt(t time.Time) {}
func (c *histogramMock) ObserveDuration() {}
func (c *histogramMock) ObserveFromStart(t time.Time) {}
func (c *histogramMock) Observe(v float64) {
c.lastHistogramValue = v