Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exemplar support for const histogram #986

Merged
merged 7 commits into from
Mar 17, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
avoid panic when there are fewer buckets than exemplars
Co-authored-by: Arun Mahendra <[email protected]>

Signed-off-by: William Perron <[email protected]>
  • Loading branch information
arun-shopify authored and wperron committed Mar 11, 2022
commit daaf45b2ed492ecb3dc13038819f2513998d400f
3 changes: 2 additions & 1 deletion prometheus/histogram.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,8 @@ func (h *constHistogram) Write(out *dto.Metric) error {

if len(h.exemplars) > 0 {
r := len(buckets)
for i := 0; i < r; i++ {
l := len(h.exemplars)
for i := 0; i < r && i < l; i++ {
bound := sort.SearchFloat64s(bounds, *h.exemplars[i].Value)
// Only append the exemplar if it's within the bounds defined in the
// buckets.
Expand Down