普罗米修斯计数器的最大限制

sat*_*hyz 4 prometheus

在普罗米修斯中使用计数器时,我们是否会遇到达到计数器最大限制的问题(假设应用程序永远不会重新启动)?如果是这样,它会影响尝试公开指标的底层应用程序还是会由普罗米修斯处理?

Kam*_*san 6

如果您查看counter来自 的指标类型 的声明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
}
Run Code Online (Sandbox Code Playgroud)

他们使用unsigned int64类型作为valInt计数器。所以一旦超过 的限制int64,就会zero再次设置为 。我想其他客户端库也会类似。