Skip to content

Sort upperBound by ascending order in mergeHistogram#7378

Open
SungJin1212 wants to merge 1 commit intocortexproject:masterfrom
SungJin1212:Sort-uppderBound-after-merge
Open

Sort upperBound by ascending order in mergeHistogram#7378
SungJin1212 wants to merge 1 commit intocortexproject:masterfrom
SungJin1212:Sort-uppderBound-after-merge

Conversation

@SungJin1212
Copy link
Member

I have noticed the TestMergeHistogram is flaky. The reason is mergeHistogram() merged classic histogram buckets via a map[float64]uint64 (bucketMap), since Go map iteration is non-deterministic, the resulting bucket order could vary.
This PR sorts by Bucket.UpperBound in ascending order and keeps the output stable.

Related Log

--- FAIL: TestMergeHistogram (0.00s)
    --- FAIL: TestMergeHistogram/native_+_classic (0.00s)
        metrics_helper_test.go:1562: 
            	Error Trace:	/__w/cortex/cortex/pkg/util/metrics_helper_test.go:1562
            	            				/__w/cortex/cortex/pkg/util/metrics_helper_test.go:1609
            	Error:      	Not equal: 
            	            	expected: 1
            	            	actual  : 5
            	Test:       	TestMergeHistogram/native_+_classic
FAIL

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Signed-off-by: SungJin1212 <tjdwls1201@gmail.com>
@SungJin1212 SungJin1212 changed the title Sort upperBound by ascending order Sort upperBound by ascending order in mergeHistogram Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant