mirror of https://github.com/docker/buildx.git
Merge pull request #2657 from jsternberg/metricwriter-race-condition
metrics: add mutex to the metric writer
This commit is contained in:
commit
8411a763d9
|
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue