Repository navigation
feat(observability): add Prometheus metrics, structured logging, OpenAPI, compose & k8s manifests - #2
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f02c746d4a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if path == "" { | ||
| path = r.URL.Path |
There was a problem hiding this comment.
Collapse unmatched request paths before recording metrics
For requests that do not match a ServeMux route, such as random 404 probes or method-mismatch 405s like POST /pdf/<id>, r.Pattern is empty, so this fallback records the raw URL path as a Prometheus label. Because RecordHTTP stores each label combination in maps for the lifetime of the process, arbitrary unique paths can create unbounded metric cardinality and memory growth; use a fixed label like unknown/not_found for empty patterns instead.
Useful? React with 👍 / 👎.
Motivation
Description
internal/observabilitypackage withMetrics(Prometheus text exposition writer, HTTP middleware, histogram buckets, queue/storage hooks) andNewLogger(structured JSONlog/slog) and expose/metricsvia a handler.GET /openapi.yamldescribing the public endpoints and schemas.Len(),Cap()andStats()helpers so metrics can report queue depth and storage breakdown.k8s/to deploy ChromaFlow plus Prometheus/Grafana/Loki/Promtail (Ingress, Services, Deployments/DaemonSet, ConfigMaps and notes).README.md,AGENTS.md,IMPROVEMENTS.md,Makefileand tests to document and wire the new features and to addcompose-up/k8s-applytargets.Testing
gofmt -wand the repo checktest -z "$(gofmt -l $(git ls-files '*.go'))"which succeeded.GOCACHE=/tmp/chromaflow-gocache go test ./...which passed for the repo packages.GOCACHE=/tmp/chromaflow-gocache go vet ./...which completed without findings.GOCACHE=/tmp/chromaflow-gocache CGO_ENABLED=0 go build -trimpath -o /tmp/chromaflow-build ./cmd/serverwhich succeeded.rubyYAML load) which confirmed the files parse;docker compose configcould not be run here because Docker is not installed in this environment.Codex Task