Skip to content

Commit 43f31c2

Browse files
authored
Merge pull request #886 from prometheus/beorn7/histogram
Switch sparse histograms to base-2 buckets
2 parents 5aa8534 + 5142344 commit 43f31c2

File tree

6 files changed

+403
-69
lines changed

6 files changed

+403
-69
lines changed

examples/random/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ var (
5454
// normal distribution, with 20 buckets centered on the mean, each
5555
// half-sigma wide.
5656
rpcDurationsHistogram = prometheus.NewHistogram(prometheus.HistogramOpts{
57-
Name: "rpc_durations_histogram_seconds",
58-
Help: "RPC latency distributions.",
59-
Buckets: prometheus.LinearBuckets(*normMean-5**normDomain, .5**normDomain, 20),
60-
SparseBucketsResolution: 20,
57+
Name: "rpc_durations_histogram_seconds",
58+
Help: "RPC latency distributions.",
59+
Buckets: prometheus.LinearBuckets(*normMean-5**normDomain, .5**normDomain, 20),
60+
SparseBucketsFactor: 1.1,
6161
})
6262
)
6363

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ require (
55
github.com/cespare/xxhash/v2 v2.1.1
66
github.com/golang/protobuf v1.4.3
77
github.com/json-iterator/go v1.1.11
8-
github.com/prometheus/client_model v0.2.1-0.20210403151606-24db95a3d5d6
8+
github.com/prometheus/client_model v0.2.1-0.20210624201024-61b6c1aac064
99
github.com/prometheus/common v0.26.0
1010
github.com/prometheus/procfs v0.6.0
1111
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40

go.sum

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a
2424
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
2525
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
2626
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
27+
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
2728
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
2829
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
2930
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
@@ -77,8 +78,8 @@ github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP
7778
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
7879
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
7980
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
80-
github.com/prometheus/client_model v0.2.1-0.20210403151606-24db95a3d5d6 h1:wlZYx9ITBsvMO/wVoi30A36fAdRlBC130JksGGfaYl8=
81-
github.com/prometheus/client_model v0.2.1-0.20210403151606-24db95a3d5d6/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
81+
github.com/prometheus/client_model v0.2.1-0.20210624201024-61b6c1aac064 h1:Kyx21CLOfWDA4e2TcOcupRl2g/Bmddu0AL0hR1BldEw=
82+
github.com/prometheus/client_model v0.2.1-0.20210624201024-61b6c1aac064/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
8283
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
8384
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
8485
github.com/prometheus/common v0.26.0 h1:iMAkS2TDoNWnKM+Kopnx/8tnEStIfpYA0ur0xQzzhMQ=

prometheus/examples_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,8 @@ func ExampleHistogram() {
538538
// cumulative_count: 816
539539
// upper_bound: 40
540540
// >
541-
// sb_resolution: 0
542-
// sb_zero_threshold: 1e-128
541+
// sb_schema: 0
542+
// sb_zero_threshold: 0
543543
// >
544544
}
545545

0 commit comments

Comments
 (0)