feat(T1.2): implement structured logging and Prometheus metrics

- Add internal/logging package with zap-based structured JSON logging
- Support development (colored) and production (JSON) modes via ENVIRONMENT env var
- Add logging helpers: Info(), Error(), Warn(), Debug(), Fatal()
- Add field helpers: String(), Int(), Int64(), Err()
- Add internal/metrics package with 16 comprehensive Prometheus metrics
- Track workflows: starts, completions, duration by type/status
- Track activities: starts, completions, duration, retries by type
- Track LLM calls: total calls and latency by model
- Track git operations: total and duration by operation type
- Track judge decisions: decisions by type
- Track Temporal errors: connection errors by type
- Track cache efficiency: hits and misses by cache type
- Track tasks in progress: gauge metric by task type
- Metrics exported on /metrics endpoint (Prometheus text format)
- Integrate structured logging in cmd/worker and cmd/starter
- Replace all log.Printf/log.Fatalf with structured logging
- Add /metrics endpoint to health check server
- 8/8 logging tests passing, 13/13 metrics tests passing
- All verification criteria met

Dependencies added:
- go.uber.org/zap v1.28.0 (structured logging)
- github.com/prometheus/client_golang v1.24.1 (metrics export)

Closes T1.2
This commit is contained in:
Test
2026-08-23 16:33:49 -07:00
parent 90fcd6a9df
commit 59a1eeed85
11 changed files with 808 additions and 66 deletions
+4
View File
@@ -3,6 +3,8 @@ package health
import (
"encoding/json"
"net/http"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
// Handler provides HTTP endpoints for health checks
@@ -22,6 +24,8 @@ func (h *Handler) RegisterRoutes(mux *http.ServeMux) {
mux.HandleFunc("/health", h.handleHealth)
mux.HandleFunc("/health/live", h.handleLive)
mux.HandleFunc("/health/ready", h.handleReady)
// Prometheus metrics endpoint
mux.Handle("/metrics", promhttp.Handler())
}
// handleHealth returns full health report