Reputation: 1451
When using counters in prometheus, would we ever hit the problem of reaching the max limit for the counter (assuming the application never restarts) ? If so, would it affect the underlying application that is trying to expose the metric or would it be taken care by prometheus?
Upvotes: 4
Views: 5840
Reputation: 13566
If you take a look at the declaration of counter
metrics type from prometheus/client_golang
.
type counter struct {
// valBits contains the bits of the represented float64 value, while
// valInt stores values that are exact integers. Both have to go first
// in the struct to guarantee alignment for atomic operations.
// http://golang.org/pkg/sync/atomic/#pkg-note-BUG
valBits uint64
valInt uint64
selfCollector
desc *Desc
labelPairs []*dto.LabelPair
}
They used unsigned int64
type for valInt
counter. So once it exceeds the limit of int64
, it will be set to zero
again. I guess it will be similar for other client libraries too.
Upvotes: 6