Skip to content

Commit 888b71b

Browse files
cuiweixiefjl
andauthored
metrics: use atomic.Pointer in runtimeHistogram (#32361)
Co-authored-by: Felix Lange <[email protected]>
1 parent f86870f commit 888b71b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

metrics/runtimehistogram.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func getOrRegisterRuntimeHistogram(name string, scale float64, r Registry) *runt
1414

1515
// runtimeHistogram wraps a runtime/metrics histogram.
1616
type runtimeHistogram struct {
17-
v atomic.Value // v is a pointer to a metrics.Float64Histogram
17+
v atomic.Pointer[metrics.Float64Histogram]
1818
scaleFactor float64
1919
}
2020

@@ -58,7 +58,7 @@ func (h *runtimeHistogram) Update(int64) {
5858

5959
// Snapshot returns a non-changing copy of the histogram.
6060
func (h *runtimeHistogram) Snapshot() HistogramSnapshot {
61-
hist := h.v.Load().(*metrics.Float64Histogram)
61+
hist := h.v.Load()
6262
return newRuntimeHistogramSnapshot(hist)
6363
}
6464

0 commit comments

Comments
 (0)