func verifyPromMetric()

in quickstarttest/testcases.go [144:160]


func verifyPromMetric(t assert.TestingT, promMetrics map[string]*dto.MetricFamily, tc testCase) {
	if !assert.Contains(t, promMetrics, tc.metricName, "prometheus metrics do not contain %v:\n%v", tc.metricName, promMetrics) {
		return
	}
	mf := promMetrics[tc.metricName]

	for _, metric := range mf.Metric {
		for _, labelPair := range metric.GetLabel() {
			if labelPair.GetName() == "exporter" && labelPair.GetValue() == tc.exporter {
				value := metric.GetCounter().GetValue()
				assert.Greater(t, value, tc.threshold, "Metric %v was expected to have value > %v, got %v", metric, sentItemsThreshold, value)
				return
			}
		}
	}
	assert.Fail(t, "Could not find a metric sample for exporter=%v, got metrics %v", tc.exporter, mf)
}