Skip to content

Commit

Permalink
Merge pull request docker#2657 from jsternberg/metricwriter-race-cond…
Browse files Browse the repository at this point in the history
…ition

metrics: add mutex to the metric writer
  • Loading branch information
tonistiigi authored Aug 14, 2024
2 parents 0e64eb4 + 6c5279d commit 8411a76
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions util/progress/metricwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var re = sync.OnceValue(func() *rePatterns {
type metricWriter struct {
recorders []metricRecorder
attrs attribute.Set
mu sync.Mutex
}

func newMetrics(mp metric.MeterProvider, attrs attribute.Set) *metricWriter {
Expand All @@ -63,6 +64,9 @@ func newMetrics(mp metric.MeterProvider, attrs attribute.Set) *metricWriter {
}

func (mw *metricWriter) Write(ss *client.SolveStatus) {
mw.mu.Lock()
defer mw.mu.Unlock()

for _, recorder := range mw.recorders {
recorder.Record(ss)
}
Expand Down

0 comments on commit 8411a76

Please sign in to comment.