(t *testing.T)
| 50 | } |
| 51 | |
| 52 | func TestGaugeDifferentLabels(t *testing.T) { |
| 53 | var seriesAdded int |
| 54 | lifecycler := &mockLimiter{ |
| 55 | onAddFunc: func(hash uint64, _ uint32, lbls labels.Labels) (labels.Labels, uint64) { |
| 56 | seriesAdded++ |
| 57 | return lbls, hash |
| 58 | }, |
| 59 | } |
| 60 | |
| 61 | c := newGauge("my_gauge", lifecycler, map[string]string{}, 15*time.Minute) |
| 62 | |
| 63 | c.Inc(buildTestLabels([]string{"label"}, []string{"value-1"}), 1.0) |
| 64 | c.Inc(buildTestLabels([]string{"another_label"}, []string{"another_value"}), 2.0) |
| 65 | |
| 66 | assert.Equal(t, 2, seriesAdded) |
| 67 | |
| 68 | collectionTimeMs := time.Now().UnixMilli() |
| 69 | expectedSamples := []sample{ |
| 70 | newSample(map[string]string{"__name__": "my_gauge", "label": "value-1"}, collectionTimeMs, 1), |
| 71 | newSample(map[string]string{"__name__": "my_gauge", "another_label": "another_value"}, collectionTimeMs, 2), |
| 72 | } |
| 73 | collectMetricAndAssert(t, c, collectionTimeMs, 2, expectedSamples, nil) |
| 74 | } |
| 75 | |
| 76 | func Test_gaugeSet(t *testing.T) { |
| 77 | var seriesAdded int |
nothing calls this directly
no test coverage detected