(t *testing.T)
| 178 | } |
| 179 | |
| 180 | func Test_counter_externalLabels(t *testing.T) { |
| 181 | c := newCounter("my_counter", noopLimiter, map[string]string{"external_label": "external_value"}, 15*time.Minute) |
| 182 | |
| 183 | c.Inc(buildTestLabels([]string{"label"}, []string{"value-1"}), 1.0) |
| 184 | c.Inc(buildTestLabels([]string{"label"}, []string{"value-2"}), 2.0) |
| 185 | |
| 186 | collectionTimeMs := time.Now().UnixMilli() |
| 187 | endOfLastMinuteMs := getEndOfLastMinuteMs(collectionTimeMs) |
| 188 | expectedSamples := []sample{ |
| 189 | newSample(map[string]string{"__name__": "my_counter", "label": "value-1", "external_label": "external_value"}, endOfLastMinuteMs, 0), |
| 190 | newSample(map[string]string{"__name__": "my_counter", "label": "value-1", "external_label": "external_value"}, collectionTimeMs, 1), |
| 191 | newSample(map[string]string{"__name__": "my_counter", "label": "value-2", "external_label": "external_value"}, endOfLastMinuteMs, 0), |
| 192 | newSample(map[string]string{"__name__": "my_counter", "label": "value-2", "external_label": "external_value"}, collectionTimeMs, 2), |
| 193 | } |
| 194 | collectMetricAndAssert(t, c, collectionTimeMs, 2, expectedSamples, nil) |
| 195 | } |
| 196 | |
| 197 | func Test_counter_concurrencyDataRace(t *testing.T) { |
| 198 | c := newCounter("my_counter", noopLimiter, map[string]string{}, 15*time.Minute) |
nothing calls this directly
no test coverage detected