feat(go): track gateway active connections
This commit is contained in:
@@ -27,6 +27,25 @@ func TestRegistryRendersCountersWithLabels(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegistryRendersGaugesWithLabels(t *testing.T) {
|
||||
registry := NewRegistry()
|
||||
registry.SetGauge("vehicle_gateway_connections", Labels{"protocol": "JT808"}, 2)
|
||||
registry.AddGauge("vehicle_gateway_connections", Labels{"protocol": "JT808"}, -1)
|
||||
registry.SetGauge("vehicle_gateway_connections", Labels{"protocol": "GB32960"}, 3)
|
||||
|
||||
text := registry.Render()
|
||||
|
||||
for _, want := range []string{
|
||||
`# TYPE vehicle_gateway_connections gauge`,
|
||||
`vehicle_gateway_connections{protocol="GB32960"} 3`,
|
||||
`vehicle_gateway_connections{protocol="JT808"} 1`,
|
||||
} {
|
||||
if !strings.Contains(text, want) {
|
||||
t.Fatalf("metrics missing %s:\n%s", want, text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandlerServesPrometheusText(t *testing.T) {
|
||||
registry := NewRegistry()
|
||||
registry.IncCounter("vehicle_kafka_commits_total", Labels{"service": "history"})
|
||||
|
||||
Reference in New Issue
Block a user