Skip to content

Commit

Permalink
remove data race from telemetry metrics hot pointer
Browse files Browse the repository at this point in the history
Signed-off-by: Eliott Bouhana <[email protected]>
  • Loading branch information
eliottness committed Jan 31, 2025
1 parent 091c522 commit 51286ca
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/newtelemetry/globalclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (
globalClientRecorder = internal.NewRecorder[Client]()

// metricsHandleHotPointers contains all the metricsHotPointer, used to replay actions done before the actual MetricHandle is set
metricsHandleHotPointers []metricsHotPointer
metricsHandleHotPointers []*metricsHotPointer
metricsHandleHotPointersMu sync.Mutex
)

Expand Down Expand Up @@ -62,8 +62,7 @@ func SwapClient(client Client) {
metricsHandleHotPointersMu.Lock()
defer metricsHandleHotPointersMu.Unlock()
for i := range metricsHandleHotPointers {
hotPointer := &metricsHandleHotPointers[i]
hotPointer.swap(hotPointer.maker(client))
metricsHandleHotPointers[i].swap(metricsHandleHotPointers[i].maker(client))
}
}
}
Expand Down Expand Up @@ -236,8 +235,9 @@ func newMetricsHotPointer(maker func(client Client) MetricHandle) *metricsHotPoi
metricsHandleHotPointersMu.Lock()
defer metricsHandleHotPointersMu.Unlock()

metricsHandleHotPointers = append(metricsHandleHotPointers, metricsHotPointer{maker: maker})
return &metricsHandleHotPointers[len(metricsHandleHotPointers)-1]
hotPtr := &metricsHotPointer{maker: maker}
metricsHandleHotPointers = append(metricsHandleHotPointers, hotPtr)
return hotPtr
}

var metricLogLossOnce sync.Once
Expand Down

0 comments on commit 51286ca

Please sign in to comment.