Skip to content

Bug: mergeHistogram produces non-deterministic bucket order causing flaky tests #7379

@Shvejan

Description

@Shvejan

The mergeHistogram function builds buckets from a Go map without sorting them, causing non-deterministic order. Prometheus client library explicitly
sorts buckets after building from maps
and assumes sorted order
for binary search
. This causes TestMergeHistogram to fail
intermittently when map iteration produces different orders.

Fix: Add sort.Slice after bucket construction in mergeHistogram(), matching Prometheus's approach.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions