A small ledger REST service (accounts + idempotent transfers) in Go, built as a portfolio piece to demonstrate production-style observability and reliability-engineering practice: OpenTelemetry tracing/metrics, RED dashboards, a multi-window burn-rate SLO alert with a promtool-verified unit test, a scripted incident + blameless postmortem, and GCP packaging (Cloud Run + Cloud SQL via Terraform, plus GKE manifests) that is written but not deployed.
- Not deployed anywhere. No live URL, no real traffic, no cloud spend.
- The Terraform in
deploy/terraform/and the manifests indeploy/k8s/are packaging, meant to demonstrate GCP/K8s deployment shape — they have not beenterraform apply'd orkubectl apply'd against a real cluster. - The code was written and reasoned about carefully, but not compiled or
run locally — this environment had no Go toolchain, Docker, Terraform,
or gcloud installed. CI (
.github/workflows/ci.yml) is the first place everything actually gets vetted, linted, built, and tested. Seego.sumbelow — it doesn't exist yet; rungo mod tidybefore building. docs/postmortem-001.mddocuments a scripted incident (triggered deliberately via the fault-injection endpoint against the local docker-compose stack), not a real production outage.
flowchart LR
client[Client] -->|HTTP| api[ledger-api\nnet/http + slog]
api -->|pgx v5| pg[(PostgreSQL)]
api -->|OTLP gRPC| otelc[OTel Collector]
otelc --> tempo[(Tempo\ntraces)]
otelc --> prom[(Prometheus\nmetrics)]
api -->|/metrics scrape| prom
prom --> grafana[Grafana\nRED dashboard]
prom -->|burn-rate rules| alerts[Alertmanager-style\nalert rules]
tempo --> grafana
subgraph GCP packaging - not deployed
cloudrun[Cloud Run]
cloudsql[(Cloud SQL Postgres)]
artifact[Artifact Registry]
monitoring[Cloud Monitoring\nalert + uptime check]
end
| Route | Method | Purpose |
|---|---|---|
/accounts |
POST | Create an account (owner, currency) |
/accounts/{id} |
GET | Fetch an account |
/transfers |
POST | Create a transfer; requires Idempotency-Key header |
/healthz |
GET | Liveness probe |
/readyz |
GET | Readiness probe (pings the store) |
/metrics |
GET | Prometheus metrics |
/admin/fault |
GET/PUT | Fault injection (latency/error-rate); only registered when LEDGER_FAULT_INJECTION_ENABLED=true |
Storage backend is chosen via LEDGER_STORE_BACKEND (memory or
postgres); see internal/config/config.go for every environment
variable and its default.
docker compose -f deploy/local/docker-compose.yml up --buildThis starts the API, Postgres, an OTel Collector, Prometheus (with the burn-rate alert rules loaded), Grafana (pre-provisioned RED dashboard at http://localhost:3000, anonymous viewer access enabled), and Tempo.
Generate some traffic:
./scripts/load.sh http://localhost:8080 60 5go mod tidy # generates go.sum (not committed — see Status)
go vet ./...
go test -race -cover ./... # unit tests (memory store, handlers, idempotency)
go test -tags=integration ./internal/store/... # requires a live Postgres via LEDGER_TEST_POSTGRES_DSNCI runs the promtool unit test proving the burn-rate alert fires on a simulated incident:
docker run --rm -v "$PWD/deploy/local/prometheus:/rules" \
prom/prometheus:v2.54.0 promtool test rules /rules/alerts_test.yml99.9% availability over a rolling 30-day window (0.1% error budget). Alerted
via a two-tier multi-window burn-rate rule (14.4x over 5m+1h -> page, 6x
over 30m+6h -> ticket). Full SLI definition and error-budget math in
docs/slo.md; the incident that exercises it is in
docs/postmortem-001.md; operational response is
in docs/runbook.md.
Go 1.23 (stdlib net/http), pgx v5, OpenTelemetry Go SDK (OTLP export),
Prometheus client_golang, Grafana, Tempo, Terraform (Cloud Run / Cloud SQL /
Artifact Registry / Cloud Monitoring), Kubernetes/GKE manifests
(Deployment/Service/HPA/ServiceMonitor), GitHub Actions CI.
MIT — see LICENSE.