package observability import ( "context" "testing" ) // TestMetricsInit confirms Init returns nil and every counter/vec is wired. // We deliberately do not assert on Prometheus exposition format — that's an // integration concern handled when the /metrics endpoint lands in Phase 5. func TestMetricsInit(t *testing.T) { m := &Metrics{} if err := m.Init(context.Background()); err != nil { t.Fatalf("Init: %v", err) } if m.Registry == nil { t.Fatal("Registry is nil") } if m.HTTPRequests == nil { t.Fatal("HTTPRequests is nil") } if m.HTTPDuration == nil { t.Fatal("HTTPDuration is nil") } if m.IngestLinesAccepted == nil { t.Fatal("IngestLinesAccepted is nil") } if m.IngestLinesErrored == nil { t.Fatal("IngestLinesErrored is nil") } if m.IngestChunksCommitted == nil { t.Fatal("IngestChunksCommitted is nil") } // Sanity: increments/observations don't panic. m.HTTPRequests.WithLabelValues("GET", "/healthz", "200").Inc() m.HTTPDuration.WithLabelValues("GET", "/healthz").Observe(0.001) m.IngestLinesAccepted.Inc() m.IngestLinesErrored.Inc() m.IngestChunksCommitted.Inc() }