Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/prometheus/client/histogram.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def type
end

def observe(value, labels: {})
bucket = buckets.find {|upper_limit| upper_limit > value }
bucket = buckets.find {|upper_limit| upper_limit >= value }
bucket = "+Inf" if bucket.nil?

base_label_set = label_set_for(labels)
Expand Down
2 changes: 2 additions & 0 deletions spec/prometheus/client/histogram_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,12 @@
it 'returns a hash of all recorded summaries' do
histogram.observe(3, labels: { status: 'bar' })
histogram.observe(6, labels: { status: 'foo' })
histogram.observe(10, labels: { status: 'baz' })

expect(histogram.values).to eql(
{ status: 'bar' } => { "2.5" => 0.0, "5" => 1.0, "10" => 1.0, "+Inf" => 1.0, "sum" => 3.0 },
{ status: 'foo' } => { "2.5" => 0.0, "5" => 0.0, "10" => 1.0, "+Inf" => 1.0, "sum" => 6.0 },
{ status: 'baz' } => { "2.5" => 0.0, "5" => 0.0, "10" => 1.0, "+Inf" => 1.0, "sum" => 10.0 },
)
end
end
Expand Down