Skip to content

Commit

Permalink
Fix race condition with Exemplar in Counter
Browse files Browse the repository at this point in the history
Potential fix for #1145.

Signed-off-by: Fabian Stäber <fabian@fstab.de>
  • Loading branch information
fstab committed Oct 7, 2022
1 parent 9801a4e commit 9e13cd2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion prometheus/counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ func (c *counter) get() float64 {
}

func (c *counter) Write(out *dto.Metric) error {
val := c.get()

var exemplar *dto.Exemplar
if e := c.exemplar.Load(); e != nil {
exemplar = e.(*dto.Exemplar)
}
val := c.get()

return populateMetric(CounterValue, val, c.labelPairs, exemplar, out)
}
Expand Down

0 comments on commit 9e13cd2

Please sign in to comment.