Skip to main content

Observability

Synced from task-interleaving

This page is a copy of docs/docs/operations/observability.md on develop, derived from that repository's code. Edit it there, then re-sync.

Short version: today the service emits structured logs and nothing else. There is no metrics endpoint, no OpenTelemetry instrument, no span and no exporter in cmd/api or anywhere under internal/. This page says what exists, proves the absence, and gives the signals an operator can build on.

Metrics: none​

QuestionAnswerEvidence
OTel metric instruments registered0no Meter, Int64Counter, Float64Histogram or similar call exists in non-test Go code; go.opentelemetry.io/otel/metric is only an indirect dependency in go.mod
/metrics (Prometheus) endpointnonethe router in internal/adapters/inbound/http/server.go registers exactly /healthz, /readyz and the six API routes
OTLP exporter or OTEL_* variablesnonecmd/api reads only the variables in Configuration
Runtime or HTTP server metrics (otelchi, otelhttp, runtime)none wiredotelhttp appears in go.mod as an indirect dependency only; no middleware uses it
Grafana dashboard for this contextnonewarehouse-infra origin/develop has no reference to task-interleaving

Nothing in the audit sense (instrument name, type, unit, attributes) can be listed because there is no instrument. If metrics are added later, this table is the place to list them.

Traces: none​

No tracer provider and no propagator are installed by the binary, and no span is created. The only OpenTelemetry code is in internal/adapters/outbound/postgres/outbox_repository.go: when an outbox row is inserted it injects the W3C trace context of the request context into the row's headers (traceparent, and tracestate / baggage when present) so a relay copy carries it onto the Kafka message. With no provider installed the context holds no span, so no trace header is ever written today; an integration test installs a propagator itself to prove the mechanism (outbox_integration_test.go). Kafka consumers do not extract a trace context.

Logs​

Logs are JSON (log/slog) on stdout, one object per line with time, level, msg and the fields below. The level comes from LOG_LEVEL (default info). There is no access log: the HTTP router has no request-logging middleware, so a successful request leaves no line. There are no correlation or trace-id fields.

WhereLevelmsg (abridged)Fields
BootINFOpostgres adapters configured, kafka topics (informational; the broker auto-creates them on first write, the service never creates them through an admin API)brokers, consumes, produces (the last two are the topic lists); topics play no part in /readyz
BootINFOhttp server listeningaddr
BootINFOconsumer runningconsumer (fulfillment consumer or layout consumer), topic, group_id, brokers
BootINFOoutbox relay runninginterval, max_attempts, brokers
BootINFOhint expiry worker runninginterval
Boot retryWARN / INFOretrying / succeeded after retryop (run migrations, ping postgres), attempt, in, err
BootWARNinvalid OUTBOX_RELAY_INTERVAL; using the default, invalid OUTBOX_MAX_ATTEMPTS; using the defaultvalue, default
Boot failureERRORservice exited with error (process exits 1)error
ShutdownINFO / WARNshutdown: readiness flipped to not-ready; waiting for traffic to drain / ignoring invalid SHUTDOWN_DRAIN_DELAY / worker did not stop before the shutdown drain deadlinedrain_delay / value, default / worker
ConsumerINFOevent processedtype, event_id, subject, outcome (applied, duplicate, stale, ignored)
ConsumerWARNskipping a message that is not a valid CloudEventconsumer, topic, error
ConsumerWARNdead-lettering an event that can never be applied / skipping an event that can never be appliedconsumer, type, event_id, error
ConsumerERROR<consumer> handling failed; retrying the same messageerror, partition, offset, attempt, max_attempts, retry_in
ConsumerERROR<consumer> handling failed after the maximum attempts; dead-lettering the message and <consumer> message can never be applied; dead-lettering it without retryerror, partition, offset (and attempts)
ConsumerERRORkafka reader error; retrying (kafka-go retrying a group join, a consumed topic that does not exist yet because its producer has not written, or an unreachable broker; without this logger it would be silent. Not a readiness failure: the consumer recovers by itself)consumer, topic, detail
ConsumerERROR<consumer> offset commit failed; retrying the same message, <consumer> dead-letter publish failed; retrying the same message, consumer stopped; restarting (the reader failed; the consumer runs again after 1 s), consumer close failederror, partition, offset, attempt, retry_in / consumer, restart_in
ReadinessWARNreadiness: dependency is not ready (once per round of checks, at most every 3 s)dependency (postgres or kafka), error (the cause)
RelayERRORoutbox relay pass failederror (text starts outbox row <id> (<type>):)
RelayERRORoutbox relay: row reached the attempt cap and is excluded from future claims; ...outbox_id, topic, event_type, key, attempts, max_attempts, error
RelayERRORoutbox relay stopped, kafka relay sink close failederror
Expiry workerINFOhints expiredexpired
Expiry workerERRORhint expiry sweep failed, hint expiry worker stoppedexpired, error
HTTPERRORrequest failed (an unmapped error, answered as 500 internal-error), handler panickederror or panic, method, path
HTTPWARNidempotency: answer not storederror

<consumer> is the consumer's name, fulfillment consumer or layout consumer (internal/adapters/inbound/kafka).

REST errors are application/problem+json documents whose type is https://errors.task-interleaving.warehouse-systems.dev/<slug>; the slug and status table is in Troubleshooting. The detail of an unmapped error is the fixed text an unexpected error occurred; the real error is only in the request failed log line.

Probes​

GET /healthz (liveness, always 200) and GET /readyz (200 only while Postgres answers and a Kafka broker answers a metadata request, never topics; 503 once shutdown starts or Postgres or the Kafka broker is unreachable) are described in the Runbook. The cause of a failed dependency is only in the WARN log line above; the response body names the dependency.

Suggested checks and alerts​

These are suggestions built from the data that exists, not alert rules that ship with the repo. Without metrics they are log searches and SQL probes against the service database.

SignalHow to read itSuggested alert
Outbox backlogSELECT count(*), min(created_at) FROM outbox_events WHERE published_at IS NULLoldest unpublished row older than a few minutes
ReadinessGET /readyz 503 with dependency-unavailable; WARN readiness: dependency is not readynot ready for more than a minute
Outbox rows stuck at the capSELECT id, event_type, last_error FROM outbox_events WHERE published_at IS NULL AND attempts >= 20 (use your OUTBOX_MAX_ATTEMPTS)any row; also the ERROR line row reached the attempt cap
Relay failinglog outbox relay pass failedrepeated for more than a minute
Consumer dead letterslogs dead-lettering at ERROR, and the depth of warehouse.fulfillment.events.dlq / warehouse.facility.events.dlqany message
Consumer stuck on one messagerepeated handling failed; retrying the same message with the same partition and offsetmore than the 5 attempts' worth, or consumer-group lag on the source topic
Stale hintsSELECT count(*) FROM hints WHERE state = 'Active' AND expires_at < now() - interval '1 minute'non-zero for several sweeps means the expiry worker is not running or failing (hint expiry sweep failed)
Boot loopservice exited with error and restartsany
5xxrequest failed / handler panickedany
Table growthrow counts of outbox_events, idempotency_keys, processed_events (nothing deletes them)capacity planning, see the Runbook

Adding real instruments (outbox backlog and age, consumer outcomes, hint issued/consumed/expired counts, request duration) is the obvious next step; none exists on develop.