diff --git a/prometheus/histogram.go b/prometheus/histogram.go index eb0eb88..1690a56 100644 --- a/prometheus/histogram.go +++ b/prometheus/histogram.go @@ -1673,6 +1673,7 @@ func makeNativeExemplars(ttl time.Duration, maxCount int) nativeExemplars { if maxCount < 0 { maxCount = 0 + ttl = -1 } return nativeExemplars{ @@ -1682,13 +1683,13 @@ func makeNativeExemplars(ttl time.Duration, maxCount int) nativeExemplars { } func (n *nativeExemplars) addExemplar(e *dto.Exemplar) { - n.Lock() - defer n.Unlock() - - if cap(n.exemplars) == 0 { + if n.ttl == -1 { return } + n.Lock() + defer n.Unlock() + // The index where to insert the new exemplar. var nIdx int = -1