feat(observability): slog-backed logging, Prometheus metrics, grpc health
- internal/logging now wraps log/slog; logging.format json/text finally works (json is the documented default). Same exported API. - New internal/metrics: /metrics on the configured metrics port with notification gauges by status/type, queue depth, and HTTP request count/duration labeled by mux route pattern; sampled from service stats so the service layer stays metrics-agnostic. - Standard grpc.health.v1 health service registered (k8s gRPC probes); gRPC MaxRecvMsgSize bounded to match the REST 1 MB body limit. - Dedicated health listener on health_check.port serving /health and /readyz (probes now work in grpc-only mode); metrics, health, and REST servers all shut down gracefully. - main wires retry backoff, CORS, readiness checks, and TLS from config. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
// currentRoute returns the gorilla/mux path template for the request, if the
|
||||
// request was matched by a mux router.
|
||||
func currentRoute(r *http.Request) string {
|
||||
route := mux.CurrentRoute(r)
|
||||
if route == nil {
|
||||
return ""
|
||||
}
|
||||
if tmpl, err := route.GetPathTemplate(); err == nil {
|
||||
return tmpl
|
||||
}
|
||||
return ""
|
||||
}
|
||||
Reference in New Issue
Block a user