Add ability to use custom prometheus buckets (#7171)

This commit is contained in:
serge-r 2022-01-15 08:27:41 +07:00 committed by GitHub
parent 5f7656f4cc
commit c0098f305c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 44 additions and 7 deletions

View file

@ -68,6 +68,17 @@ func TestNewUDPLogListener(t *testing.T) {
}
func TestCollector(t *testing.T) {
buckets := struct {
TimeBuckets []float64
LengthBuckets []float64
SizeBuckets []float64
}{
prometheus.DefBuckets,
prometheus.LinearBuckets(10, 10, 10),
prometheus.ExponentialBuckets(10, 10, 7),
}
cases := []struct {
name string
data []string
@ -338,7 +349,7 @@ func TestCollector(t *testing.T) {
t.Run(c.name, func(t *testing.T) {
registry := prometheus.NewPedanticRegistry()
sc, err := NewSocketCollector("pod", "default", "ingress", true)
sc, err := NewSocketCollector("pod", "default", "ingress", true, buckets)
if err != nil {
t.Errorf("%v: unexpected error creating new SocketCollector: %v", c.name, err)
}