Skip to content

Commit c57e49c

Browse files
committed
Rename buckets to upperBounds in histogram builder
1 parent 7dff411 commit c57e49c

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

docs/content/config/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Metrics Properties
4040
| io.prometheus.metrics.exemplarsEnabled | [Counter.Builder.withExemplars()](/client_java/api/io/prometheus/metrics/core/metrics/Counter.Builder.html#withExemplars()) | (1) (2) |
4141
| io.prometheus.metrics.histogramNativeOnly | [Histogram.Builder.nativeOnly()](/client_java/api/io/prometheus/metrics/core/metrics/Histogram.Builder.html#nativeOnly()) | (2) |
4242
| io.prometheus.metrics.histogramClassicOnly | [Histogram.Builder.classicOnly()](/client_java/api/io/prometheus/metrics/core/metrics/Histogram.Builder.html#classicOnly()) | (2) |
43-
| io.prometheus.metrics.histogramClassicUpperBounds | [Histogram.Builder.classicBuckets()](/client_java/api/io/prometheus/metrics/core/metrics/Histogram.Builder.html#classicBuckets(double...)) | (3) |
43+
| io.prometheus.metrics.histogramClassicUpperBounds | [Histogram.Builder.classicUpperBounds()](/client_java/api/io/prometheus/metrics/core/metrics/Histogram.Builder.html#classicUpperBounds(double...)) | (3) |
4444
| io.prometheus.metrics.histogramNativeInitialSchema | [Histogram.Builder.nativeInitialSchema()](/client_java/api/io/prometheus/metrics/core/metrics/Histogram.Builder.html#nativeInitialSchema(int)) | |
4545
| io.prometheus.metrics.histogramNativeMinZeroThreshold | [Histogram.Builder.nativeMinZeroThreshold()](/client_java/api/io/prometheus/metrics/core/metrics/Histogram.Builder.html#nativeMinZeroThreshold(double)) | |
4646
| io.prometheus.metrics.histogramNativeMaxZeroThreshold | [Histogram.Builder.nativeMaxZeroThreshold()](/client_java/api/io/prometheus/metrics/core/metrics/Histogram.Builder.html#nativeMaxZeroThreshold(double)) | |

prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/metrics/Histogram.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ public Builder classicOnly() {
735735
* If the +Inf bucket is missing it will be added.
736736
* If upperBounds contains duplicates the duplicates will be removed.
737737
*/
738-
public Builder classicBuckets(double... upperBounds) {
738+
public Builder classicUpperBounds(double... upperBounds) {
739739
this.classicUpperBounds = upperBounds;
740740
for (double bound : upperBounds) {
741741
if (Double.isNaN(bound)) {
@@ -755,7 +755,7 @@ public Builder classicBuckets(double... upperBounds) {
755755
* @param width is the width of each bucket
756756
* @param count is the total number of buckets, including start
757757
*/
758-
public Builder classicLinearBuckets(double start, double width, int count) {
758+
public Builder classicLinearUpperBounds(double start, double width, int count) {
759759
this.classicUpperBounds = new double[count];
760760
// Use BigDecimal to avoid weird bucket boundaries like 0.7000000000000001.
761761
BigDecimal s = new BigDecimal(Double.toString(start));
@@ -776,7 +776,7 @@ public Builder classicLinearBuckets(double start, double width, int count) {
776776
* @param factor growth factor
777777
* @param count total number of buckets, including start
778778
*/
779-
public Builder classicExponentialBuckets(double start, double factor, int count) {
779+
public Builder classicExponentialUpperBounds(double start, double factor, int count) {
780780
classicUpperBounds = new double[count];
781781
for (int i = 0; i < count; i++) {
782782
classicUpperBounds[i] = start * Math.pow(factor, i);

prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/HistogramTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ public void markCurrentSpanAsExemplar() {
756756
.name("test")
757757
// The default number of Exemplars is 4.
758758
// Use 5 buckets to verify that the exemplar sample is configured with the buckets.
759-
.classicBuckets(1.0, 2.0, 3.0, 4.0, Double.POSITIVE_INFINITY)
759+
.classicUpperBounds(1.0, 2.0, 3.0, 4.0, Double.POSITIVE_INFINITY)
760760
.labelNames("path")
761761
.build();
762762

@@ -1076,7 +1076,7 @@ public void testNullName() {
10761076
public void testDuplicateClassicBuckets() {
10771077
Histogram histogram = Histogram.builder()
10781078
.name("test")
1079-
.classicBuckets(0, 3, 17, 3, 21)
1079+
.classicUpperBounds(0, 3, 17, 3, 21)
10801080
.build();
10811081
List<Double> upperBounds = getData(histogram).getClassicBuckets().stream()
10821082
.map(ClassicHistogramBucket::getUpperBound)
@@ -1088,7 +1088,7 @@ public void testDuplicateClassicBuckets() {
10881088
public void testUnsortedBuckets() {
10891089
Histogram histogram = Histogram.builder()
10901090
.name("test")
1091-
.classicBuckets(0.2, 0.1)
1091+
.classicUpperBounds(0.2, 0.1)
10921092
.build();
10931093
List<Double> upperBounds = getData(histogram).getClassicBuckets().stream()
10941094
.map(ClassicHistogramBucket::getUpperBound)
@@ -1100,7 +1100,7 @@ public void testUnsortedBuckets() {
11001100
public void testEmptyBuckets() {
11011101
Histogram histogram = Histogram.builder()
11021102
.name("test")
1103-
.classicBuckets()
1103+
.classicUpperBounds()
11041104
.build();
11051105
List<Double> upperBounds = getData(histogram).getClassicBuckets().stream()
11061106
.map(ClassicHistogramBucket::getUpperBound)
@@ -1112,7 +1112,7 @@ public void testEmptyBuckets() {
11121112
public void testBucketsIncludePositiveInfinity() {
11131113
Histogram histogram = Histogram.builder()
11141114
.name("test")
1115-
.classicBuckets(0.01, 0.1, 1.0, Double.POSITIVE_INFINITY)
1115+
.classicUpperBounds(0.01, 0.1, 1.0, Double.POSITIVE_INFINITY)
11161116
.build();
11171117
List<Double> upperBounds = getData(histogram).getClassicBuckets().stream()
11181118
.map(ClassicHistogramBucket::getUpperBound)
@@ -1124,7 +1124,7 @@ public void testBucketsIncludePositiveInfinity() {
11241124
public void testLinearBuckets() {
11251125
Histogram histogram = Histogram.builder()
11261126
.name("test")
1127-
.classicLinearBuckets(0.1, 0.1, 10)
1127+
.classicLinearUpperBounds(0.1, 0.1, 10)
11281128
.build();
11291129
List<Double> upperBounds = getData(histogram).getClassicBuckets().stream()
11301130
.map(ClassicHistogramBucket::getUpperBound)
@@ -1135,7 +1135,7 @@ public void testLinearBuckets() {
11351135
@Test
11361136
public void testExponentialBuckets() {
11371137
Histogram histogram = Histogram.builder()
1138-
.classicExponentialBuckets(2, 2.5, 3)
1138+
.classicExponentialUpperBounds(2, 2.5, 3)
11391139
.name("test")
11401140
.build();
11411141
List<Double> upperBounds = getData(histogram).getClassicBuckets().stream()
@@ -1148,7 +1148,7 @@ public void testExponentialBuckets() {
11481148
public void testBucketsIncludeNaN() {
11491149
Histogram.builder()
11501150
.name("test")
1151-
.classicBuckets(0.01, 0.1, 1.0, Double.NaN);
1151+
.classicUpperBounds(0.01, 0.1, 1.0, Double.NaN);
11521152
}
11531153

11541154
@Test
@@ -1192,7 +1192,7 @@ public void testNegativeAmount() {
11921192
Histogram histogram = Histogram.builder()
11931193
.name("histogram")
11941194
.help("test histogram for negative values")
1195-
.classicBuckets(-10, -5, 0, 5, 10)
1195+
.classicUpperBounds(-10, -5, 0, 5, 10)
11961196
.build();
11971197
double expectedCount = 0;
11981198
double expectedSum = 0;

0 commit comments

Comments
 (0)