diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7703d940..c0d430207 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: - uses: prometheus/promci@52c7012f5f0070d7281b8db4a119e21341d43c91 # v0.4.5 - uses: ./.github/promci/actions/setup_environment - run: go test --tags=dedupelabels ./... - - run: GOARCH=386 go test ./cmd/prometheus + - run: GOARCH=386 go test ./... - uses: ./.github/promci/actions/check_proto with: version: "3.15.8" diff --git a/model/histogram/test_utils.go b/model/histogram/test_utils.go index 9e9a711c2..e6b33863b 100644 --- a/model/histogram/test_utils.go +++ b/model/histogram/test_utils.go @@ -19,12 +19,12 @@ func GenerateBigTestHistograms(numHistograms, numBuckets int) []*Histogram { bucketsPerSide := numBuckets / 2 spanLength := uint32(bucketsPerSide / numSpans) // Given all bucket deltas are 1, sum bucketsPerSide + 1. - observationCount := bucketsPerSide * (1 + bucketsPerSide) + observationCount := uint64(bucketsPerSide) * (1 + uint64(bucketsPerSide)) var histograms []*Histogram for i := 0; i < numHistograms; i++ { h := &Histogram{ - Count: uint64(i + observationCount), + Count: uint64(i) + observationCount, ZeroCount: uint64(i), ZeroThreshold: 1e-128, Sum: 18.4 * float64(i+1), diff --git a/promql/engine.go b/promql/engine.go index 13f8b0697..a23e899d0 100644 --- a/promql/engine.go +++ b/promql/engine.go @@ -1352,7 +1352,7 @@ func (ev *evaluator) rangeEvalAgg(ctx context.Context, aggExpr *parser.Aggregate } groups := make([]groupedAggregation, groupCount) - var k int + var k int64 var ratio float64 var seriess map[uint64]Series switch aggExpr.Op { @@ -1360,9 +1360,9 @@ func (ev *evaluator) rangeEvalAgg(ctx context.Context, aggExpr *parser.Aggregate if !convertibleToInt64(param) { ev.errorf("Scalar value %v overflows int64", param) } - k = int(param) - if k > len(inputMatrix) { - k = len(inputMatrix) + k = int64(param) + if k > int64(len(inputMatrix)) { + k = int64(len(inputMatrix)) } if k < 1 { return nil, warnings @@ -3172,7 +3172,7 @@ func (ev *evaluator) aggregation(e *parser.AggregateExpr, q float64, inputMatrix // seriesToResult maps inputMatrix indexes to groups indexes. // For an instant query, returns a Matrix in descending order for topk or ascending for bottomk, or without any order for limitk / limit_ratio. // For a range query, aggregates output in the seriess map. -func (ev *evaluator) aggregationK(e *parser.AggregateExpr, k int, r float64, inputMatrix Matrix, seriesToResult []int, groups []groupedAggregation, enh *EvalNodeHelper, seriess map[uint64]Series) (Matrix, annotations.Annotations) { +func (ev *evaluator) aggregationK(e *parser.AggregateExpr, k int64, r float64, inputMatrix Matrix, seriesToResult []int, groups []groupedAggregation, enh *EvalNodeHelper, seriess map[uint64]Series) (Matrix, annotations.Annotations) { op := e.Op var s Sample var annos annotations.Annotations @@ -3243,7 +3243,7 @@ seriesLoop: case s.H != nil: // Ignore histogram sample and add info annotation. annos.Add(annotations.NewHistogramIgnoredInAggregationInfo("topk", e.PosRange)) - case len(group.heap) < k: + case int64(len(group.heap)) < k: heap.Push(&group.heap, &s) case group.heap[0].F < s.F || (math.IsNaN(group.heap[0].F) && !math.IsNaN(s.F)): // This new element is bigger than the previous smallest element - overwrite that. @@ -3259,7 +3259,7 @@ seriesLoop: case s.H != nil: // Ignore histogram sample and add info annotation. annos.Add(annotations.NewHistogramIgnoredInAggregationInfo("bottomk", e.PosRange)) - case len(group.heap) < k: + case int64(len(group.heap)) < k: heap.Push((*vectorByReverseValueHeap)(&group.heap), &s) case group.heap[0].F > s.F || (math.IsNaN(group.heap[0].F) && !math.IsNaN(s.F)): // This new element is smaller than the previous biggest element - overwrite that. @@ -3270,13 +3270,13 @@ seriesLoop: } case parser.LIMITK: - if len(group.heap) < k { + if int64(len(group.heap)) < k { heap.Push(&group.heap, &s) } // LIMITK optimization: early break if we've added K elem to _every_ group, // especially useful for large timeseries where the user is exploring labels via e.g. // limitk(10, my_metric) - if !group.groupAggrComplete && len(group.heap) == k { + if !group.groupAggrComplete && int64(len(group.heap)) == k { group.groupAggrComplete = true groupsRemaining-- if groupsRemaining == 0 { diff --git a/scrape/manager_test.go b/scrape/manager_test.go index 0f1b9fe69..b9c6f4c40 100644 --- a/scrape/manager_test.go +++ b/scrape/manager_test.go @@ -894,7 +894,7 @@ func findSamplesForMetric(floats []floatSample, metricName string) (ret []floatS // generateTestHistogram generates the same thing as tsdbutil.GenerateTestHistogram, // but in the form of dto.Histogram. func generateTestHistogram(i int) *dto.Histogram { - helper := tsdbutil.GenerateTestHistogram(i) + helper := tsdbutil.GenerateTestHistogram(int64(i)) h := &dto.Histogram{} h.SampleCount = proto.Uint64(helper.Count) h.SampleSum = proto.Float64(helper.Sum) diff --git a/storage/merge_test.go b/storage/merge_test.go index 04d4e9207..92d951b83 100644 --- a/storage/merge_test.go +++ b/storage/merge_test.go @@ -385,13 +385,13 @@ func TestMergeChunkQuerierWithNoVerticalChunkSeriesMerger(t *testing.T) { } func histogramSample(ts int64, hint histogram.CounterResetHint) hSample { - h := tsdbutil.GenerateTestHistogram(int(ts + 1)) + h := tsdbutil.GenerateTestHistogram(ts + 1) h.CounterResetHint = hint return hSample{t: ts, h: h} } func floatHistogramSample(ts int64, hint histogram.CounterResetHint) fhSample { - fh := tsdbutil.GenerateTestFloatHistogram(int(ts + 1)) + fh := tsdbutil.GenerateTestFloatHistogram(ts + 1) fh.CounterResetHint = hint return fhSample{t: ts, fh: fh} } diff --git a/storage/remote/queue_manager_test.go b/storage/remote/queue_manager_test.go index 8369da3f1..202c71c34 100644 --- a/storage/remote/queue_manager_test.go +++ b/storage/remote/queue_manager_test.go @@ -2077,7 +2077,7 @@ func createTimeseriesWithOldSamples(numSamples, numSeries int, extraLabels ...la for j := 0; j < numSamples/2; j++ { sample := record.RefSample{ Ref: chunks.HeadSeriesRef(i), - T: int64(int(time.Now().UnixMilli()) + j), + T: time.Now().UnixMilli() + int64(j), V: float64(i), } samples = append(samples, sample) diff --git a/tsdb/db_test.go b/tsdb/db_test.go index 306dc4579..6e1f6c54b 100644 --- a/tsdb/db_test.go +++ b/tsdb/db_test.go @@ -4101,7 +4101,7 @@ func TestOOOWALWrite(t *testing.T) { }, "integer histogram": { appendSample: func(app storage.Appender, l labels.Labels, mins int64) (storage.SeriesRef, error) { - seriesRef, err := app.AppendHistogram(0, l, minutes(mins), tsdbutil.GenerateTestHistogram(int(mins)), nil) + seriesRef, err := app.AppendHistogram(0, l, minutes(mins), tsdbutil.GenerateTestHistogram(mins), nil) require.NoError(t, err) return seriesRef, nil }, @@ -4192,7 +4192,7 @@ func TestOOOWALWrite(t *testing.T) { }, "float histogram": { appendSample: func(app storage.Appender, l labels.Labels, mins int64) (storage.SeriesRef, error) { - seriesRef, err := app.AppendHistogram(0, l, minutes(mins), nil, tsdbutil.GenerateTestFloatHistogram(int(mins))) + seriesRef, err := app.AppendHistogram(0, l, minutes(mins), nil, tsdbutil.GenerateTestFloatHistogram(mins)) require.NoError(t, err) return seriesRef, nil }, @@ -4736,12 +4736,12 @@ func TestMultipleEncodingsCommitOrder(t *testing.T) { return sample{t: ts, f: float64(ts)} } if valType == chunkenc.ValHistogram { - h := tsdbutil.GenerateTestHistogram(int(ts)) + h := tsdbutil.GenerateTestHistogram(ts) _, err := app.AppendHistogram(0, labels.FromStrings("foo", "bar1"), ts, h, nil) require.NoError(t, err) return sample{t: ts, h: h} } - fh := tsdbutil.GenerateTestFloatHistogram(int(ts)) + fh := tsdbutil.GenerateTestFloatHistogram(ts) _, err := app.AppendHistogram(0, labels.FromStrings("foo", "bar1"), ts, nil, fh) require.NoError(t, err) return sample{t: ts, fh: fh} @@ -5427,37 +5427,37 @@ func TestQuerierOOOQuery(t *testing.T) { }, "integer histogram": { appendFunc: func(app storage.Appender, ts int64, counterReset bool) (storage.SeriesRef, error) { - h := tsdbutil.GenerateTestHistogram(int(ts)) + h := tsdbutil.GenerateTestHistogram(ts) if counterReset { h.CounterResetHint = histogram.CounterReset } return app.AppendHistogram(0, labels.FromStrings("foo", "bar1"), ts, h, nil) }, sampleFunc: func(ts int64) chunks.Sample { - return sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(ts))} + return sample{t: ts, h: tsdbutil.GenerateTestHistogram(ts)} }, }, "float histogram": { appendFunc: func(app storage.Appender, ts int64, counterReset bool) (storage.SeriesRef, error) { - fh := tsdbutil.GenerateTestFloatHistogram(int(ts)) + fh := tsdbutil.GenerateTestFloatHistogram(ts) if counterReset { fh.CounterResetHint = histogram.CounterReset } return app.AppendHistogram(0, labels.FromStrings("foo", "bar1"), ts, nil, fh) }, sampleFunc: func(ts int64) chunks.Sample { - return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(int(ts))} + return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(ts)} }, }, "integer histogram counter resets": { // Adding counter reset to all histograms means each histogram will have its own chunk. appendFunc: func(app storage.Appender, ts int64, counterReset bool) (storage.SeriesRef, error) { - h := tsdbutil.GenerateTestHistogram(int(ts)) + h := tsdbutil.GenerateTestHistogram(ts) h.CounterResetHint = histogram.CounterReset // For this scenario, ignore the counterReset argument. return app.AppendHistogram(0, labels.FromStrings("foo", "bar1"), ts, h, nil) }, sampleFunc: func(ts int64) chunks.Sample { - return sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(ts))} + return sample{t: ts, h: tsdbutil.GenerateTestHistogram(ts)} }, }, } @@ -5743,37 +5743,37 @@ func TestChunkQuerierOOOQuery(t *testing.T) { }, "integer histogram": { appendFunc: func(app storage.Appender, ts int64, counterReset bool) (storage.SeriesRef, error) { - h := tsdbutil.GenerateTestHistogram(int(ts)) + h := tsdbutil.GenerateTestHistogram(ts) if counterReset { h.CounterResetHint = histogram.CounterReset } return app.AppendHistogram(0, labels.FromStrings("foo", "bar1"), ts, h, nil) }, sampleFunc: func(ts int64) chunks.Sample { - return sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(ts))} + return sample{t: ts, h: tsdbutil.GenerateTestHistogram(ts)} }, }, "float histogram": { appendFunc: func(app storage.Appender, ts int64, counterReset bool) (storage.SeriesRef, error) { - fh := tsdbutil.GenerateTestFloatHistogram(int(ts)) + fh := tsdbutil.GenerateTestFloatHistogram(ts) if counterReset { fh.CounterResetHint = histogram.CounterReset } return app.AppendHistogram(0, labels.FromStrings("foo", "bar1"), ts, nil, fh) }, sampleFunc: func(ts int64) chunks.Sample { - return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(int(ts))} + return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(ts)} }, }, "integer histogram counter resets": { // Adding counter reset to all histograms means each histogram will have its own chunk. appendFunc: func(app storage.Appender, ts int64, counterReset bool) (storage.SeriesRef, error) { - h := tsdbutil.GenerateTestHistogram(int(ts)) + h := tsdbutil.GenerateTestHistogram(ts) h.CounterResetHint = histogram.CounterReset // For this scenario, ignore the counterReset argument. return app.AppendHistogram(0, labels.FromStrings("foo", "bar1"), ts, h, nil) }, sampleFunc: func(ts int64) chunks.Sample { - return sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(ts))} + return sample{t: ts, h: tsdbutil.GenerateTestHistogram(ts)} }, }, "integer histogram with recode": { @@ -6908,7 +6908,7 @@ func TestOOOHistogramCompactionWithCounterResets(t *testing.T) { app := db.Appender(context.Background()) tsMs := ts * time.Minute.Milliseconds() if floatHistogram { - h := tsdbutil.GenerateTestFloatHistogram(val) + h := tsdbutil.GenerateTestFloatHistogram(int64(val)) h.CounterResetHint = hint _, err = app.AppendHistogram(0, l, tsMs, nil, h) require.NoError(t, err) @@ -6916,7 +6916,7 @@ func TestOOOHistogramCompactionWithCounterResets(t *testing.T) { return sample{t: tsMs, fh: h.Copy()} } - h := tsdbutil.GenerateTestHistogram(val) + h := tsdbutil.GenerateTestHistogram(int64(val)) h.CounterResetHint = hint _, err = app.AppendHistogram(0, l, tsMs, h, nil) require.NoError(t, err) @@ -7267,14 +7267,14 @@ func TestInterleavedInOrderAndOOOHistogramCompactionWithCounterResets(t *testing app := db.Appender(context.Background()) tsMs := ts if floatHistogram { - h := tsdbutil.GenerateTestFloatHistogram(val) + h := tsdbutil.GenerateTestFloatHistogram(int64(val)) _, err = app.AppendHistogram(0, l, tsMs, nil, h) require.NoError(t, err) require.NoError(t, app.Commit()) return sample{t: tsMs, fh: h.Copy()} } - h := tsdbutil.GenerateTestHistogram(val) + h := tsdbutil.GenerateTestHistogram(int64(val)) _, err = app.AppendHistogram(0, l, tsMs, h, nil) require.NoError(t, err) require.NoError(t, app.Commit()) diff --git a/tsdb/head_test.go b/tsdb/head_test.go index 2ca3aeffc..fb158b593 100644 --- a/tsdb/head_test.go +++ b/tsdb/head_test.go @@ -4732,7 +4732,7 @@ func TestOOOHistogramCounterResetHeaders(t *testing.T) { // OOO histogram for i := 1; i <= 5; i++ { - appendHistogram(100+int64(i), tsdbutil.GenerateTestHistogram(1000+i)) + appendHistogram(100+int64(i), tsdbutil.GenerateTestHistogram(1000+int64(i))) } // Nothing mmapped yet. checkOOOExpCounterResetHeader() @@ -4820,7 +4820,7 @@ func TestOOOHistogramCounterResetHeaders(t *testing.T) { appendHistogram(300, tsdbutil.SetHistogramCounterReset(tsdbutil.GenerateTestHistogram(3000))) for i := 1; i <= 4; i++ { - appendHistogram(300+int64(i), tsdbutil.GenerateTestHistogram(3000+i)) + appendHistogram(300+int64(i), tsdbutil.GenerateTestHistogram(3000+int64(i))) } // One mmapped chunk with (ts, val) [(300, 3000), (301, 3001), (302, 3002), (303, 3003), (350, 4000)]. diff --git a/tsdb/ooo_head_test.go b/tsdb/ooo_head_test.go index 37a46e76d..203330fcd 100644 --- a/tsdb/ooo_head_test.go +++ b/tsdb/ooo_head_test.go @@ -54,12 +54,12 @@ func TestOOOInsert(t *testing.T) { }, "integer histogram": { sampleFunc: func(ts int64) sample { - return sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(ts))} + return sample{t: ts, h: tsdbutil.GenerateTestHistogram(ts)} }, }, "float histogram": { sampleFunc: func(ts int64) sample { - return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(int(ts))} + return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(ts)} }, }, } @@ -118,12 +118,12 @@ func TestOOOInsertDuplicate(t *testing.T) { }, "integer histogram": { sampleFunc: func(ts int64) sample { - return sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(ts))} + return sample{t: ts, h: tsdbutil.GenerateTestHistogram(ts)} }, }, "float histogram": { sampleFunc: func(ts int64) sample { - return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(int(ts))} + return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(ts)} }, }, } diff --git a/tsdb/querier_test.go b/tsdb/querier_test.go index 3462ca409..2d83b04ba 100644 --- a/tsdb/querier_test.go +++ b/tsdb/querier_test.go @@ -1826,12 +1826,12 @@ func checkCurrVal(t *testing.T, valType chunkenc.ValueType, it *populateWithDelS ts, h := it.AtHistogram(nil) require.Equal(t, int64(expectedTs), ts) h.CounterResetHint = histogram.UnknownCounterReset - require.Equal(t, tsdbutil.GenerateTestHistogram(expectedValue), h) + require.Equal(t, tsdbutil.GenerateTestHistogram(int64(expectedValue)), h) case chunkenc.ValFloatHistogram: ts, h := it.AtFloatHistogram(nil) require.Equal(t, int64(expectedTs), ts) h.CounterResetHint = histogram.UnknownCounterReset - require.Equal(t, tsdbutil.GenerateTestFloatHistogram(expectedValue), h) + require.Equal(t, tsdbutil.GenerateTestFloatHistogram(int64(expectedValue)), h) default: panic("unexpected value type") } @@ -3588,16 +3588,16 @@ func TestQueryWithDeletedHistograms(t *testing.T) { ctx := context.Background() testcases := map[string]func(int) (*histogram.Histogram, *histogram.FloatHistogram){ "intCounter": func(i int) (*histogram.Histogram, *histogram.FloatHistogram) { - return tsdbutil.GenerateTestHistogram(i), nil + return tsdbutil.GenerateTestHistogram(int64(i)), nil }, "intgauge": func(i int) (*histogram.Histogram, *histogram.FloatHistogram) { - return tsdbutil.GenerateTestGaugeHistogram(rand.Int() % 1000), nil + return tsdbutil.GenerateTestGaugeHistogram(rand.Int63() % 1000), nil }, "floatCounter": func(i int) (*histogram.Histogram, *histogram.FloatHistogram) { - return nil, tsdbutil.GenerateTestFloatHistogram(i) + return nil, tsdbutil.GenerateTestFloatHistogram(int64(i)) }, "floatGauge": func(i int) (*histogram.Histogram, *histogram.FloatHistogram) { - return nil, tsdbutil.GenerateTestGaugeFloatHistogram(rand.Int() % 1000) + return nil, tsdbutil.GenerateTestGaugeFloatHistogram(rand.Int63() % 1000) }, } diff --git a/tsdb/testutil.go b/tsdb/testutil.go index c39eb133c..57516c627 100644 --- a/tsdb/testutil.go +++ b/tsdb/testutil.go @@ -63,45 +63,45 @@ var sampleTypeScenarios = map[string]sampleTypeScenario{ intHistogram: { sampleType: sampleMetricTypeHistogram, appendFunc: func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, sample, error) { - s := sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(value))} + s := sample{t: ts, h: tsdbutil.GenerateTestHistogram(value)} ref, err := appender.AppendHistogram(0, lbls, ts, s.h, nil) return ref, s, err }, sampleFunc: func(ts, value int64) sample { - return sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(value))} + return sample{t: ts, h: tsdbutil.GenerateTestHistogram(value)} }, }, floatHistogram: { sampleType: sampleMetricTypeHistogram, appendFunc: func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, sample, error) { - s := sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(int(value))} + s := sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(value)} ref, err := appender.AppendHistogram(0, lbls, ts, nil, s.fh) return ref, s, err }, sampleFunc: func(ts, value int64) sample { - return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(int(value))} + return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(value)} }, }, gaugeIntHistogram: { sampleType: sampleMetricTypeHistogram, appendFunc: func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, sample, error) { - s := sample{t: ts, h: tsdbutil.GenerateTestGaugeHistogram(int(value))} + s := sample{t: ts, h: tsdbutil.GenerateTestGaugeHistogram(value)} ref, err := appender.AppendHistogram(0, lbls, ts, s.h, nil) return ref, s, err }, sampleFunc: func(ts, value int64) sample { - return sample{t: ts, h: tsdbutil.GenerateTestGaugeHistogram(int(value))} + return sample{t: ts, h: tsdbutil.GenerateTestGaugeHistogram(value)} }, }, gaugeFloatHistogram: { sampleType: sampleMetricTypeHistogram, appendFunc: func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, sample, error) { - s := sample{t: ts, fh: tsdbutil.GenerateTestGaugeFloatHistogram(int(value))} + s := sample{t: ts, fh: tsdbutil.GenerateTestGaugeFloatHistogram(value)} ref, err := appender.AppendHistogram(0, lbls, ts, nil, s.fh) return ref, s, err }, sampleFunc: func(ts, value int64) sample { - return sample{t: ts, fh: tsdbutil.GenerateTestGaugeFloatHistogram(int(value))} + return sample{t: ts, fh: tsdbutil.GenerateTestGaugeFloatHistogram(value)} }, }, } diff --git a/tsdb/tsdbutil/histogram.go b/tsdb/tsdbutil/histogram.go index ce934a638..60c3e5f72 100644 --- a/tsdb/tsdbutil/histogram.go +++ b/tsdb/tsdbutil/histogram.go @@ -21,7 +21,7 @@ import ( func GenerateTestHistograms(n int) (r []*histogram.Histogram) { for i := 0; i < n; i++ { - h := GenerateTestHistogram(i) + h := GenerateTestHistogram(int64(i)) if i > 0 { h.CounterResetHint = histogram.NotCounterReset } @@ -31,13 +31,13 @@ func GenerateTestHistograms(n int) (r []*histogram.Histogram) { } func GenerateTestHistogramWithHint(n int, hint histogram.CounterResetHint) *histogram.Histogram { - h := GenerateTestHistogram(n) + h := GenerateTestHistogram(int64(n)) h.CounterResetHint = hint return h } // GenerateTestHistogram but it is up to the user to set any known counter reset hint. -func GenerateTestHistogram(i int) *histogram.Histogram { +func GenerateTestHistogram(i int64) *histogram.Histogram { return &histogram.Histogram{ Count: 12 + uint64(i*9), ZeroCount: 2 + uint64(i), @@ -48,16 +48,16 @@ func GenerateTestHistogram(i int) *histogram.Histogram { {Offset: 0, Length: 2}, {Offset: 1, Length: 2}, }, - PositiveBuckets: []int64{int64(i + 1), 1, -1, 0}, + PositiveBuckets: []int64{i + 1, 1, -1, 0}, NegativeSpans: []histogram.Span{ {Offset: 0, Length: 2}, {Offset: 1, Length: 2}, }, - NegativeBuckets: []int64{int64(i + 1), 1, -1, 0}, + NegativeBuckets: []int64{i + 1, 1, -1, 0}, } } -func GenerateTestCustomBucketsHistogram(i int) *histogram.Histogram { +func GenerateTestCustomBucketsHistogram(i int64) *histogram.Histogram { return &histogram.Histogram{ Count: 5 + uint64(i*4), Sum: 18.4 * float64(i+1), @@ -66,20 +66,20 @@ func GenerateTestCustomBucketsHistogram(i int) *histogram.Histogram { {Offset: 0, Length: 2}, {Offset: 1, Length: 2}, }, - PositiveBuckets: []int64{int64(i + 1), 1, -1, 0}, + PositiveBuckets: []int64{i + 1, 1, -1, 0}, CustomValues: []float64{0, 1, 2, 3, 4}, } } func GenerateTestGaugeHistograms(n int) (r []*histogram.Histogram) { for x := 0; x < n; x++ { - i := int(math.Sin(float64(x))*100) + 100 + i := int64(math.Sin(float64(x))*100) + 100 r = append(r, GenerateTestGaugeHistogram(i)) } return r } -func GenerateTestGaugeHistogram(i int) *histogram.Histogram { +func GenerateTestGaugeHistogram(i int64) *histogram.Histogram { h := GenerateTestHistogram(i) h.CounterResetHint = histogram.GaugeType return h @@ -87,7 +87,7 @@ func GenerateTestGaugeHistogram(i int) *histogram.Histogram { func GenerateTestFloatHistograms(n int) (r []*histogram.FloatHistogram) { for i := 0; i < n; i++ { - h := GenerateTestFloatHistogram(i) + h := GenerateTestFloatHistogram(int64(i)) if i > 0 { h.CounterResetHint = histogram.NotCounterReset } @@ -97,7 +97,7 @@ func GenerateTestFloatHistograms(n int) (r []*histogram.FloatHistogram) { } // GenerateTestFloatHistogram but it is up to the user to set any known counter reset hint. -func GenerateTestFloatHistogram(i int) *histogram.FloatHistogram { +func GenerateTestFloatHistogram(i int64) *histogram.FloatHistogram { return &histogram.FloatHistogram{ Count: 12 + float64(i*9), ZeroCount: 2 + float64(i), @@ -117,7 +117,7 @@ func GenerateTestFloatHistogram(i int) *histogram.FloatHistogram { } } -func GenerateTestCustomBucketsFloatHistogram(i int) *histogram.FloatHistogram { +func GenerateTestCustomBucketsFloatHistogram(i int64) *histogram.FloatHistogram { return &histogram.FloatHistogram{ Count: 5 + float64(i*4), Sum: 18.4 * float64(i+1), @@ -133,13 +133,13 @@ func GenerateTestCustomBucketsFloatHistogram(i int) *histogram.FloatHistogram { func GenerateTestGaugeFloatHistograms(n int) (r []*histogram.FloatHistogram) { for x := 0; x < n; x++ { - i := int(math.Sin(float64(x))*100) + 100 + i := int64(math.Sin(float64(x))*100) + 100 r = append(r, GenerateTestGaugeFloatHistogram(i)) } return r } -func GenerateTestGaugeFloatHistogram(i int) *histogram.FloatHistogram { +func GenerateTestGaugeFloatHistogram(i int64) *histogram.FloatHistogram { h := GenerateTestFloatHistogram(i) h.CounterResetHint = histogram.GaugeType return h diff --git a/util/testutil/context.go b/util/testutil/context.go index 0c9e0f6f6..ea4b0e374 100644 --- a/util/testutil/context.go +++ b/util/testutil/context.go @@ -49,8 +49,8 @@ func (c *MockContext) Value(interface{}) interface{} { // MockContextErrAfter is a MockContext that will return an error after a certain // number of calls to Err(). type MockContextErrAfter struct { + count atomic.Uint64 MockContext - count atomic.Uint64 FailAfter uint64 }