Phase 2 sections 2-6 and 8 of docs/SCALE-EXPANSION.md: - pkg/telemetry + pkg/metrics: OpenTelemetry trace propagation and Prometheus metrics across every service hop (CLI -> agent -> gateway -> card-issuance/tenant-registry/auth -> ledger-core), tracing added to ledger-core itself via services/ledger-core/src/telemetry.rs. - infra/: otel-collector + Prometheus + Grafana docker-compose stack, a Terraform ECS Fargate module + dev/staging/prod envs (plan-only, no apply — real AWS spend is an owner action), and a dev-only mTLS CA (infra/dev-ca) wired through pkg/mtls + services/ledger-core/src/mtls.rs. - services/audit-log (from the prior commit) gets its async mirror writer in services/ledger-core/src/audit_mirror.rs, and services/gateway gets a per-tenant token-bucket rate limiter (internal/ratelimit). - Test depth: a Rust proptest suite proving concurrent ApplyEntry never breaches the reserve floor (tests/apply_entry_proptest.rs, passing), a Go fuzz seed corpus for the policy envelope (rules_fuzz_test.go), a libFuzzer harness for the C WAL frame parser (services/wal/fuzz, deliberately not wired into `make test` per its own Makefile comment - needs a libFuzzer-bundled clang), and a real chaos test (scripts/chaos/kill-ledger-mid-write.sh) that SIGKILLs ledger-core mid-write under concurrent load and verifies via ListEntries that nothing was lost or double-applied. - docs/formal/ledger.tla: a TLA+ spec of the ledger state machine (balance >= reserve_floor safety, HOLD-eventually-resolves liveness) plus a TLC model config - not run through TLC in this pass, that's a precise documented TODO, not faked. - docs/adr/0001-0004, docs/RUNBOOK.md, docs/SLO.md, docs/THREAT-MODEL.md. Verified: `make build && make test` clean (C WAL, Rust incl. the new proptest suite, all 10 Go modules) from a cold target. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
89 lines
3.4 KiB
YAML
89 lines
3.4 KiB
YAML
# OpenTelemetry Collector config for Ration's local observability stack —
|
|
# docs/SCALE-EXPANSION.md section 2.
|
|
#
|
|
# Every service's trace exporter (pkg/telemetry.Setup on the Go side,
|
|
# ledger_core::telemetry::init in Rust) sends OTLP over gRPC to this
|
|
# collector by default (OTEL_EXPORTER_OTLP_ENDPOINT /
|
|
# RATION_OTEL_EXPORTER_ENDPOINT default to this container's address in
|
|
# docker-compose.yml). This collector's only job is traces: metrics are
|
|
# each service's own Prometheus /metrics endpoint (pkg/metrics), scraped
|
|
# directly by Prometheus (infra/prometheus/prometheus.yml) — not routed
|
|
# through here — so there is deliberately no `prometheus` receiver or
|
|
# exporter in this pipeline.
|
|
#
|
|
# Run standalone (outside docker-compose) with:
|
|
# otelcol --config infra/otel-collector/config.yaml
|
|
|
|
receivers:
|
|
# Accepts both gRPC (what every service in this project actually uses)
|
|
# and HTTP (kept enabled for ad-hoc debugging with curl/otel CLI tools
|
|
# against the same collector without extra config).
|
|
otlp:
|
|
protocols:
|
|
grpc:
|
|
endpoint: 0.0.0.0:4317
|
|
http:
|
|
endpoint: 0.0.0.0:4318
|
|
|
|
processors:
|
|
# Batches spans before export so a burst of ledger writes doesn't turn
|
|
# into one OTLP export call per span; bounded timeout keeps end-to-end
|
|
# trace visibility latency low enough for interactive debugging.
|
|
batch:
|
|
timeout: 5s
|
|
send_batch_size: 512
|
|
|
|
# Caps collector memory so a runaway span volume (e.g. a chaos test,
|
|
# scripts/chaos/kill-ledger-mid-write.sh, hammering ApplyEntry) degrades
|
|
# by dropping spans under backpressure rather than OOMing the collector
|
|
# container and taking the whole observability stack down.
|
|
memory_limiter:
|
|
check_interval: 1s
|
|
limit_mib: 200
|
|
spike_limit_mib: 50
|
|
|
|
exporters:
|
|
# Jaeger (and Tempo, which also speaks OTLP natively) both accept
|
|
# traces directly over OTLP — the "jaeger" container in
|
|
# docker-compose.yml runs jaeger-all-in-one with its OTLP receiver
|
|
# enabled (COLLECTOR_OTLP_ENABLED=true), listening on this same
|
|
# 4317/4318 pair inside its own container.
|
|
otlp/jaeger:
|
|
endpoint: jaeger:4317
|
|
tls:
|
|
insecure: true
|
|
|
|
# Always-on stdout exporter: lets `docker compose logs otel-collector`
|
|
# confirm spans are actually flowing end to end even before anyone
|
|
# opens Grafana/Jaeger's UI — genuinely useful when standing the stack
|
|
# up for the first time or debugging "my traces aren't showing up".
|
|
debug:
|
|
verbosity: basic
|
|
|
|
service:
|
|
pipelines:
|
|
traces:
|
|
receivers: [otlp]
|
|
processors: [memory_limiter, batch]
|
|
exporters: [otlp/jaeger, debug]
|
|
|
|
telemetry:
|
|
logs:
|
|
level: info
|
|
metrics:
|
|
# Default is 127.0.0.1:8888 — loopback *inside this container's own
|
|
# network namespace*, unreachable from infra/prometheus/
|
|
# prometheus.yml's `otel-collector:8888` scrape target on another
|
|
# container. Verified empirically: Prometheus reported this job
|
|
# permanently "down" until this override was added. `readers` (not
|
|
# the simpler `metrics.address` key) because this collector version
|
|
# (0.116.1) logs `metrics::address is being deprecated in favor of
|
|
# metrics::readers` — using the current form rather than shipping a
|
|
# config that already warns on its way out.
|
|
readers:
|
|
- pull:
|
|
exporter:
|
|
prometheus:
|
|
host: 0.0.0.0
|
|
port: 8888
|