【问题标题】:What is the lowest granularity for Prometheus Go client library's ExponentialBuckets API?Prometheus Go 客户端库的 ExponentialBuckets API 的最低粒度是多少?
【发布时间】:2018-12-20 01:54:21
【问题描述】:

我正在尝试Prometheus Go client libraryExponentialBuckets API 是否接受小于 1.0 的参数 start(例如 0.001)?

【问题讨论】:

    标签: go prometheus


    【解决方案1】:

    package prometheus

    import "github.com/prometheus/client_golang/prometheus"
    

    func ExponentialBuckets

    func ExponentialBuckets(start, factor float64, count int) []float64
    

    ExponentialBuckets 创建 'count' 个桶,其中最低的桶 具有“开始”的上限和每个后续存储桶的上限 是“因子”乘以前一个桶的上限。最后的 +Inf bucket 不计算在内,也不包含在返回的切片中。这 返回的切片旨在用于 Buckets 字段 直方图选项。

    如果 'count' 为 0 或负数,如果 'start' 为 0 或 负数,或者如果“因子”小于或等于 1。


    尝试将start 等于最小正数float64

    package main
    
    import (
        "fmt"
        "math"
    )
    
    func main() {
        // Minimum normal positive float64
        // 0 00000000001 0000000000000000000000000000000000000000000000000000
        // 2.2250738585072014e−308
        start := math.Float64frombits(uint64(1 << (63 - 11)))
        fmt.Println(start)
    }
    

    输出:

    2.2250738585072014e-308
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-22
      • 1970-01-01
      • 1970-01-01
      • 2017-03-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多