feat(go): expose kafka consumer lag metrics
This commit is contained in:
@@ -46,6 +46,24 @@ func TestRegistryRendersGaugesWithLabels(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegistryRecordsKafkaLagGauge(t *testing.T) {
|
||||
registry := NewRegistry()
|
||||
|
||||
registry.SetKafkaLag("vehicle_history_kafka_lag", "vehicle.raw.go.jt808.v1", 3, 101, 130)
|
||||
registry.SetKafkaLag("vehicle_history_kafka_lag", "vehicle.raw.go.gb32960.v1", 0, 9, 9)
|
||||
|
||||
text := registry.Render()
|
||||
for _, want := range []string{
|
||||
`# TYPE vehicle_history_kafka_lag gauge`,
|
||||
`vehicle_history_kafka_lag{partition="0",topic="vehicle.raw.go.gb32960.v1"} 0`,
|
||||
`vehicle_history_kafka_lag{partition="3",topic="vehicle.raw.go.jt808.v1"} 28`,
|
||||
} {
|
||||
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