gpt4 book ai didi

go - Prometheus Go 客户端库的 ExponentialBuckets API 的最低粒度是多少?

转载 作者:IT王子 更新时间:2023-10-29 01:46:48 26 4
gpt4 key购买 nike

我正在试验 Prometheus Go client library .是否ExponentialBuckets API接受小于 1.0(例如 0.001)的参数 start

最佳答案

package prometheus

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

func ExponentialBuckets

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

ExponentialBuckets creates 'count' buckets, where the lowest bucket has an upper bound of 'start' and each following bucket's upper bound is 'factor' times the previous bucket's upper bound. The final +Inf bucket is not counted and not included in the returned slice. The returned slice is meant to be used for the Buckets field of HistogramOpts.

The function panics if 'count' is 0 or negative, if 'start' is 0 or negative, or if 'factor' is less than or equal 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

关于go - Prometheus Go 客户端库的 ExponentialBuckets API 的最低粒度是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53861507/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com