Merge pull request #1171 from prometheus/beorn7/histogram

Fix issue with atomic variables on ppc64le
This commit is contained in:
Bartlomiej Plotka 2022-11-22 13:00:35 +00:00 committed by GitHub
commit 8b6e68085b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 13 deletions

View File

@ -544,16 +544,12 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr
} }
// Finally we know the final length of h.upperBounds and can make buckets // Finally we know the final length of h.upperBounds and can make buckets
// for both counts as well as exemplars: // for both counts as well as exemplars:
h.counts[0] = &histogramCounts{ h.counts[0] = &histogramCounts{buckets: make([]uint64, len(h.upperBounds))}
buckets: make([]uint64, len(h.upperBounds)), atomic.StoreUint64(&h.counts[0].nativeHistogramZeroThresholdBits, math.Float64bits(h.nativeHistogramZeroThreshold))
nativeHistogramZeroThresholdBits: math.Float64bits(h.nativeHistogramZeroThreshold), atomic.StoreInt32(&h.counts[0].nativeHistogramSchema, h.nativeHistogramSchema)
nativeHistogramSchema: h.nativeHistogramSchema, h.counts[1] = &histogramCounts{buckets: make([]uint64, len(h.upperBounds))}
} atomic.StoreUint64(&h.counts[1].nativeHistogramZeroThresholdBits, math.Float64bits(h.nativeHistogramZeroThreshold))
h.counts[1] = &histogramCounts{ atomic.StoreInt32(&h.counts[1].nativeHistogramSchema, h.nativeHistogramSchema)
buckets: make([]uint64, len(h.upperBounds)),
nativeHistogramZeroThresholdBits: math.Float64bits(h.nativeHistogramZeroThreshold),
nativeHistogramSchema: h.nativeHistogramSchema,
}
h.exemplars = make([]atomic.Value, len(h.upperBounds)+1) h.exemplars = make([]atomic.Value, len(h.upperBounds)+1)
h.init(h) // Init self-collection. h.init(h) // Init self-collection.

View File

@ -470,7 +470,7 @@ func TestHistogramExemplar(t *testing.T) {
} }
} }
func TestSparseHistogram(t *testing.T) { func TestNativeHistogram(t *testing.T) {
scenarios := []struct { scenarios := []struct {
name string name string
observations []float64 // With simulated interval of 1m. observations []float64 // With simulated interval of 1m.
@ -686,7 +686,7 @@ func TestSparseHistogram(t *testing.T) {
} }
} }
func TestSparseHistogramConcurrency(t *testing.T) { func TestNativeHistogramConcurrency(t *testing.T) {
if testing.Short() { if testing.Short() {
t.Skip("Skipping test in short mode.") t.Skip("Skipping test in short mode.")
} }
@ -703,7 +703,7 @@ func TestSparseHistogramConcurrency(t *testing.T) {
end.Add(concLevel) end.Add(concLevel)
his := NewHistogram(HistogramOpts{ his := NewHistogram(HistogramOpts{
Name: "test_sparse_histogram", Name: "test_native_histogram",
Help: "This help is sparse.", Help: "This help is sparse.",
NativeHistogramBucketFactor: 1.05, NativeHistogramBucketFactor: 1.05,
NativeHistogramZeroThreshold: 0.0000001, NativeHistogramZeroThreshold: 0.0000001,