英文:
prometheus.NewHistogram() api for histogram metric type
问题
使用github.com/prometheus/client_golang/prometheus
库来为GO应用程序进行指标仪表化:
在下面的代码中:
requestDurations := prometheus.NewHistogram(prometheus.HistogramOpts{
Name: "http_request_duration_seconds",
Help: "A Histogram of the http request duration in seconds",
// Cumulative bucket upper bounds
Buckets: []float64{0.05, 0.1, 0.25, 0.5, 1, 2, 5, 5, 10}
})
requestDurations.Observe(0.42)
-
Buckets: []float64{0.05, 0.1, 0.25, 0.5, 1, 2, 5, 5, 10}
表示什么? -
requestDurations.Observe(0.42)
表示什么?
英文:
Using github.com/prometheus/client_golang/prometheus
library to instrument GO app, for metrics:
In the below code:
requestDurations := prometheus.NewHistogram(prometheus.HistogramOpts{
Name: "http_request_duration_seconds"
Help: "A Histogram of the http request duration in secconds"
// Cumulative bucket upper bounds
Buckets: []float64{0.05, 0.1, 0.25, 0.5, 1, 2,5, 5, 10}
})
requestDurations.Observe(0.42)
-
What does
Buckets: []float64{0.05, 0.1, 0.25, 0.5, 1, 2,5, 5, 10}
imply? -
What does
requestDurations.Observe(0.42)
imply?
答案1
得分: 1
根据包的文档说明:
Buckets定义了观测值被计数的桶。切片中的每个元素都是一个桶的上限(包含)。这些值必须按严格递增的顺序排序。不需要添加一个具有+Inf边界的最高桶,它将被隐式添加。默认值是DefBuckets。
直方图会将观测值计数到各个桶中。通过这个声明,你声明了上限为0.05、0.1、0.25、...、5、10和+inf的桶。每个观测值将被计数到这些桶中的一个。例如,Observe(0.42)
会增加那些上限大于等于0.5的桶的计数。
英文:
As the package documentation states:
> Buckets defines the buckets into which observations are counted. Each
element in the slice is the upper inclusive bound of a bucket. The
values must be sorted in strictly increasing order. There is no need
to add a highest bucket with +Inf bound, it will be added
implicitly. The default value is DefBuckets.
Histogram counts observations in buckets. With this declaration, you declare buckets with upper limits of 0.05, 0.1, 0.25, ..., 5, 10, +inf. Each observation will be counted in one of these buckets. For instance, the Observe(0.42)
will increment the buckets whose upper limits are >=0.5.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论