(t *testing.T)
| 22 | } |
| 23 | |
| 24 | func TestCollectorCollectSample(t *testing.T) { |
| 25 | t.Parallel() |
| 26 | |
| 27 | r := metrics.NewRegistry() |
| 28 | m1, err := r.NewMetric("metric1", metrics.Counter) |
| 29 | require.NoError(t, err) |
| 30 | |
| 31 | tags := r.RootTagSet().With("t1", "v1") |
| 32 | samples := metrics.Samples(make([]metrics.Sample, 3)) |
| 33 | |
| 34 | c := collector{ |
| 35 | aggregationPeriod: 3 * time.Second, |
| 36 | waitPeriod: 1 * time.Second, |
| 37 | timeBuckets: make(map[int64]map[metrics.TimeSeries]metricValue), |
| 38 | nowFunc: func() time.Time { |
| 39 | return time.Unix(31, 0) |
| 40 | }, |
| 41 | } |
| 42 | for i := range samples { |
| 43 | sample := metrics.Sample{ |
| 44 | TimeSeries: metrics.TimeSeries{ |
| 45 | Metric: m1, |
| 46 | Tags: tags, |
| 47 | }, |
| 48 | Value: 1.0, |
| 49 | Time: time.Unix(int64((i+1)*10), 0), // 10, 20, 30 |
| 50 | } |
| 51 | c.collectSample(sample) |
| 52 | } |
| 53 | |
| 54 | assert.Len(t, c.timeBuckets, 3) |
| 55 | } |
| 56 | |
| 57 | func TestCollectorCollectSampleAggregateNumbers(t *testing.T) { |
| 58 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…