Skip to content

Commit 100f46c

Browse files
committed
Use binary search for histogram buckets
Signed-off-by: Konstantin Ilchenko <k.ilchenko@appodeal.com>
1 parent 5514b2b commit 100f46c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/prometheus/client/histogram.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def type
6767
# https://prometheus.io/docs/practices/histograms/#count-and-sum-of-observations
6868
# for details.
6969
def observe(value, labels: {})
70-
bucket = buckets.find {|upper_limit| upper_limit >= value }
70+
bucket = buckets.bsearch { |upper_limit| upper_limit >= value }
7171
bucket = "+Inf" if bucket.nil?
7272

7373
base_label_set = label_set_for(labels)

0 commit comments

Comments
 (0)