forked from mirrors/statsd_exporter
Adding new test section to check on metrics
Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
This commit is contained in:
parent
2d339b0853
commit
d015cda365
1 changed files with 11 additions and 7 deletions
|
@ -22,9 +22,9 @@ func TestRelay_RelayLine(t *testing.T) {
|
||||||
args args
|
args args
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "single line",
|
name: "multiple lines",
|
||||||
args: args{
|
args: args{
|
||||||
lines: []string{"foo5:100|c|#tag1:bar,#tag2:baz"},
|
lines: []string{"foo5:100|c|#tag1:bar,#tag2:baz", "foo2:200|c|#tag1:bar,#tag2:baz"},
|
||||||
expected: "foo5:100|c|#tag1:bar,#tag2:baz\n",
|
expected: "foo5:100|c|#tag1:bar,#tag2:baz\n",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -67,17 +67,21 @@ func TestRelay_RelayLine(t *testing.T) {
|
||||||
|
|
||||||
metricNames := map[string]float64{
|
metricNames := map[string]float64{
|
||||||
"statsd_exporter_relay_long_lines_total": 0,
|
"statsd_exporter_relay_long_lines_total": 0,
|
||||||
|
"statsd_exporter_relay_lines_relayed_total": float64(len(tt.args.lines)),
|
||||||
}
|
}
|
||||||
for metricName, expectedValue := range metricNames {
|
for metricName, expectedValue := range metricNames {
|
||||||
firstMetric := getFloat64(metrics, metricName, prometheus.Labels{"target": "localhost:1160"})
|
metric := getFloat64(metrics, metricName, prometheus.Labels{"target": "localhost:1160"})
|
||||||
|
|
||||||
if firstMetric == nil {
|
if metric == nil {
|
||||||
t.Fatalf("Could not find time series with first label set for metric: %s", metricName)
|
t.Fatalf("Could not find time series with first label set for metric: %s", metricName)
|
||||||
}
|
}
|
||||||
if *firstMetric != expectedValue {
|
if *metric != expectedValue {
|
||||||
t.Errorf("Expected metric %s to be %f, got %f", metricName, expectedValue, *firstMetric)
|
t.Errorf("Expected metric %s to be %f, got %f", metricName, expectedValue, *metric)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prometheus.Unregister(relayLongLinesTotal)
|
||||||
|
prometheus.Unregister(relayLinesRelayedTotal)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue