Skip to content

Commit 5f202ee

Browse files
authored
Merge pull request #1150 from prometheus/sparsehistogram
Merge sparsehistogram branch into main
2 parents 0859bb8 + fffb76c commit 5f202ee

File tree

5 files changed

+1323
-94
lines changed

5 files changed

+1323
-94
lines changed

examples/random/main.go

+15-7
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,22 @@ func NewMetrics(reg prometheus.Registerer, normMean, normDomain float64) *metric
4848
},
4949
[]string{"service"},
5050
),
51-
// The same as above, but now as a histogram, and only for the normal
52-
// distribution. The buckets are targeted to the parameters of the
53-
// normal distribution, with 20 buckets centered on the mean, each
54-
// half-sigma wide.
51+
// The same as above, but now as a histogram, and only for the
52+
// normal distribution. The histogram features both conventional
53+
// buckets as well as sparse buckets, the latter needed for the
54+
// experimental native histograms (ingested by a Prometheus
55+
// server v2.40 with the corresponding feature flag
56+
// enabled). The conventional buckets are targeted to the
57+
// parameters of the normal distribution, with 20 buckets
58+
// centered on the mean, each half-sigma wide. The sparse
59+
// buckets are always centered on zero, with a growth factor of
60+
// one bucket to the text of (at most) 1.1. (The precise factor
61+
// is 2^2^-3 = 1.0905077...)
5562
rpcDurationsHistogram: prometheus.NewHistogram(prometheus.HistogramOpts{
56-
Name: "rpc_durations_histogram_seconds",
57-
Help: "RPC latency distributions.",
58-
Buckets: prometheus.LinearBuckets(normMean-5*normDomain, .5*normDomain, 20),
63+
Name: "rpc_durations_histogram_seconds",
64+
Help: "RPC latency distributions.",
65+
Buckets: prometheus.LinearBuckets(normMean-5*normDomain, .5*normDomain, 20),
66+
NativeHistogramBucketFactor: 1.1,
5967
}),
6068
}
6169
reg.MustRegister(m.rpcDurations)

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/davecgh/go-spew v1.1.1
99
github.com/golang/protobuf v1.5.2
1010
github.com/json-iterator/go v1.1.12
11-
github.com/prometheus/client_model v0.2.0
11+
github.com/prometheus/client_model v0.3.0
1212
github.com/prometheus/common v0.37.0
1313
github.com/prometheus/procfs v0.8.0
1414
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a

go.sum

+2-1
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW
134134
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
135135
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
136136
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
137-
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
138137
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
138+
github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4=
139+
github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
139140
github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE=
140141
github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA=
141142
github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo=

0 commit comments

Comments
 (0)