diff --git a/sdk/metric/internal/exemplar/rand.go b/sdk/metric/internal/exemplar/rand.go index 8cbcff2404ac..a2407a4678d5 100644 --- a/sdk/metric/internal/exemplar/rand.go +++ b/sdk/metric/internal/exemplar/rand.go @@ -123,7 +123,9 @@ func (r *randRes) Offer(ctx context.Context, t time.Time, n Value, a []attribute } else { if r.count == r.next { // Overwrite a random existing measurement with the one offered. + rngMu.Lock() idx := int(rng.Int63n(int64(cap(r.store)))) + rngMu.Unlock() r.store[idx] = newMeasurement(ctx, t, n, a) r.advance() }