Skip to main content

Observability

All five long-running binaries (everything but the short-lived cmd/sweep) share one telemetry setup, internal/observability/telemetry.go (observability.Setup), following the fleet metrics convention (ADR-0019).

How telemetry leaves the process​

  • Push, not scrape. Traces and metrics are exported over OTLP/gRPC to OTEL_EXPORTER_OTLP_ENDPOINT (default localhost:4317; a bare host:port is turned into http://host:port, and the connection is insecure). There is no /metrics endpoint on any binary. In the cluster the chart points it at otel-collector.observability.svc.cluster.local:4317, and the Collector re-exports to Prometheus (dots become underscores, counters gain _total).
  • Never fatal. The exporters dial lazily. With no Collector the services start and serve normally; each failed export logs a WARN opentelemetry error line.
  • Resource attributes: service.name (OTEL_SERVICE_NAME; defaults fulfillment-execution, fulfillment-execution-mcp, fulfillment-projector, fulfillment-reports), service.version (SERVICE_VERSION, default dev), deployment.environment.name (ENVIRONMENT, default local).
  • Propagation: W3C traceparent plus baggage, over HTTP headers and over Kafka message headers (internal/observability/kafkacarrier.go).

Metrics​

Service-defined instruments​

InstrumentTypeUnitAttributesRecorded byEmitted from
fulfillment.tasks.claimedInt64 counter{task}task.type (PICK, PACK, SLAM, REBIN)ClaimNext, once per won claimcmd/execution (internal/observability/metrics.go)
fulfillment.tasks.completedInt64 counter{task}task.typeCompleteTask, once per completioncmd/execution (REST) and cmd/mcp (complete_task)
circuit_breaker.stateInt64 gauge{state}dependency (facility-layout)the facility-layout breaker's state changes: 0 closed, 1 half-open, 2 opencmd/execution, only when LOCATION_ROLE_MODE=http (internal/observability/circuit_breaker_metrics.go)

In Prometheus these appear as fulfillment_tasks_claimed_total, fulfillment_tasks_completed_total and circuit_breaker_state. The gauge is written only on a transition, so it has no series until the breaker first changes state.

Library instruments​

Instrument(s)TypeUnitAttributesSourceEmitted from
http.server.request.durationFloat64 histogram (buckets 5ms … 10s)shttp.method, http.scheme, http.route (the chi pattern). No status-code attribute.github.com/riandyrn/otelchi/metric v0.12.3cmd/execution, cmd/fulfillment-reports, cmd/mcp routers. The projector's admin server is not instrumented.
pgxpool.acquires, pgxpool.acquire_duration, pgxpool.acquired_connections, pgxpool.canceled_acquires, pgxpool.constructing_connections, pgxpool.empty_acquire, pgxpool.empty_acquire_wait_time, pgxpool.idle_connections, pgxpool.max_connections, pgxpool.max_idle_destroys, pgxpool.max_lifetime_destroys, pgxpool.new_connections, pgxpool.total_connectionsobservable counters / up-down counters / gauge––github.com/exaring/otelpgx v0.12.0 RecordStatscmd/execution (with DATABASE_URL), cmd/fulfillment-projector, cmd/fulfillment-reports. cmd/mcp does not register pool stats.
go.memory.used, go.memory.limit, go.memory.allocated, go.memory.allocations, go.memory.gc.goal, go.goroutine.count, go.processor.limit, go.config.gogcruntime observablesvarious–go.opentelemetry.io/contrib/instrumentation/runtime v0.71.0all five long-running binaries

There is no metric for consumer lag, outbox backlog or DLQ volume. Use the broker's consumer-group lag, the SQL in the Runbook and the log lines below.

Traces​

Span nameKindWhereNotes
<METHOD> <route pattern>, for example POST /tasks/{id}/completionsserverevery chi router (otelchi with WithChiRoutes and the method in the name)Low-cardinality: the route pattern, not the raw path.
kafka.consume warehouse.work-planning.eventsconsumerWorkReleased consumerParent is the producer's span from the message headers, so a release in wes-work-planning and the task created here share one trace. The span covers all in-process retries. Attributes messaging.system=kafka, messaging.destination.name, messaging.operation.name=process.
kafka.consume warehouse.product-master.eventsconsumerProductClassified consumer and the pack-level consumerSame attributes.
kafka.consume warehouse.fulfillment.analyticsconsumerprojectorSame attributes.
kafka.publish warehouse.fulfillment.events, kafka.publish warehouse.fulfillment.analyticsproducerpublishers in direct mode only (EVENT_PUBLISHER=kafka without DATABASE_URL)With the outbox, the trace context of the request's span is written into the stored headers at encode time, so the downstream consumer span still joins the request's trace, but no publish span is recorded.
mcp.tool <tool name>, for example mcp.tool complete_taskinternalevery MCP tool callAttribute mcp.tool.name; status Error with the message when the tool fails.
SQL spans (query SELECT ... and friends)clientevery pgx pool (otelpgx)Statements are recorded in parameterised form; parameter values are not recorded.

The outbox relay, the process-path catalogue consumer and the sweeps' CronJob pods create no spans of their own (the sweep requests are traced server-side as POST /task-lease-expirations and POST /cpt-miss-sweeps).

Trace continuity across the outbox (gap fix D27). Both encoders inject the W3C traceparent/tracestate of the writing use case's context into the message headers at encode time (observability.InjectKafkaTrace); the OutboxPublisher stores them in outbox_events.headers (JSONB, migration 0009) in the same transaction; the relay sends the stored headers unchanged, even though its own pass runs without the request's context; and every consumer that starts a span extracts first (observability.ExtractKafkaTrace). A row written without an active span has no traceparent and relays with exactly its stored headers. Pinned by the integration tests TestOutboxTrace_TraceparentCrossesTheOutboxToKafka and TestOutboxTrace_RowWithoutTraceHeadersRelaysUnchanged (internal/adapters/outbound/postgres/outbox_trace_integration_test.go).

Logs​

JSON lines on stdout (log/slog JSON handler), level from LOG_LEVEL. Every record has time, level, msg; a record logged with a context that carries an active span also has trace_id and span_id (internal/observability/slogotel.go), which is how a log line links to its trace.

The request logger writes one http request line per request on cmd/execution and cmd/fulfillment-reports, with method, path (CR/LF stripped), status, duration_ms, bytes and request_id; status 5xx logs at ERROR, everything else at INFO. Example from a local run:

{"time":"2026-10-12T14:04:12.358153-03:00","level":"INFO","msg":"http request","method":"POST","path":"/tasks/20261012T170412.355825000/completions","status":204,"duration_ms":0,"bytes":0,"request_id":"claudioeds-MacBook-Pro.local/YYHwzrf60N-000010","trace_id":"cb33b6f3f5af6bc4e8d63e56024c25f7","span_id":"81fb421a6c10c93e"}

Messages worth searching for or alerting on:

msgLevelMeaning
kafka message handling failed after retriesERRORA WorkReleased failed 3 attempts and went to the DLQ (topic, attempts, error). Never logged for a message a shutdown interrupted (ADR-0046).
kafka commit failed; the message will be redelivered and deduplicatedWARNThe WorkReleased offset commit failed after the message was settled (topic, partition, offset, error); the redelivery is absorbed by the processed-events claim.
kafka message is not a valid CloudEvent; dead-letteringWARNPoison message on warehouse.work-planning.events.
failed to publish message to dead-letter topicERRORThe DLQ write itself failed; the message is now only in this log.
kafka read failed; retrying / kafka fetch failed; retryingWARNBroker unreachable; the consumer backs off (up to 30s) and keeps trying.
applying ProductClassified failed; retrying the same messageERRORTransient failure; that partition is blocked until it succeeds.
skipping ProductClassified with an invalid payloadWARNContract violation from product-master; committed past.
analytics message handling failedERRORProjector could not apply an event; it moves on.
outbox relay pass failedERRORA send or SQL failure in the relay; the row keeps published_at NULL and is retried.
outbox relay: send failed, stopping this pass at the failed rowWARNOne failed send below the attempt cap (outbox_id, topic, attempts).
outbox relay: row reached the attempt cap and is excluded from future claims; re-arm it with attempts = 0 after fixing the causeERRORA row failed OUTBOX_MAX_ATTEMPTS sends and is now skipped (ADR-0042); fields outbox_id, topic, event_type, key, attempts, max_attempts, error. Alert on it.
outbox relay did not stop before the shutdown deadline / kafka consumer did not stop before the shutdown deadlineWARNGraceful shutdown hit its 10s bound.
retrying (with op, attempt, in)WARNA boot-time dial (migrations, ping, catalogue) is being retried.
http listener up; /readyz stays not ready until the process-path catalogue has replayed its initial historyINFOPATH_CATALOGUE_SOURCE=kafka: the listener is serving and /readyz answers 503 while the catalogue replays (ADR-0044).
process-path catalogue is ready (with paths) then readiness: warm-up finished; /readyz now reports readyINFOThe replay reached the startup watermark; /readyz turns 200 and the Kafka consumers start. Missing 60s after the line above means the boot exits with process-path catalogue did not become ready within 1m0s.
domain event published (with event_name, occurred_at)INFOThe log publisher (EVENT_PUBLISHER=log): the event went nowhere else.
opentelemetry errorWARNAn export to the Collector failed.

Dashboard​

warehouse-infra ships a Grafana dashboard for this context: terraform/dashboards/contexts/fulfillment-execution.json, titled "Warehouse — Fulfillment Execution" (uid warehouse-fulfillment-execution). Its rows:

  1. API Gateway (Kong): request rate, 5xx ratio and p95 latency for the httproute.warehouse-systems.fulfillment-execution.* Kong service.
  2. Service HTTP RED: request rate by http_route, 5xx rate and p95 of http_server_request_duration_seconds for the fulfillment-(execution|projector|reports).* service names (this regex also matches fulfillment-execution-mcp).
  3. Business metrics: fulfillment_tasks_claimed_total and fulfillment_tasks_completed_total rates by task_type.
  4. Go runtime: goroutines and memory used.
  5. Logs (Loki): live stream, volume by level, and ERROR/WARN lines for {app="fulfillment-execution"} (Istio containers excluded).

The row-2 error panel filters on http_response_status_code / http_status_code, which otelchi v0.12.3 does not emit, so it stays empty. Use the Kong 5xx panel or the http request log lines with status>=500 for service errors.

Suggested alerts​

None of these exist yet; they are built only from signals listed above.

AlertSignalWhy
Completions stalledsum(rate(fulfillment_tasks_completed_total[15m])) == 0 while sum(rate(fulfillment_tasks_claimed_total[15m])) > 0Stations claim but nothing completes: leases will expire and churn the pool.
Queue backing upGET /queues/{taskType}/depth growing across checks (MCP get_queue_status gives the same number)Too few stations pulling.
Facility-layout breaker openmax(circuit_breaker_state{dependency="facility-layout"}) == 2 for 5mStation registrations are being accepted unchecked.
Work landing in the DLQLoki: count of kafka message handling failed after retries or kafka message is not a valid CloudEvent > 0 in 10mReleased work did not become a task.
Outbox not drainingLoki: outbox relay pass failed repeating; SQL: oldest outbox_events.created_at with published_at IS NULL older than a few minutesDownstream contexts stop seeing completions, CPT misses and manifests.
Classification partition blockedLoki: applying ProductClassified failed; retrying the same message repeatingThe local hazmat copy goes stale.
Analytics staleGET /reports/throughput/freshness returns lagSeconds above the 30s SLA for 10mProjector down or lagging.
Latencyhistogram_quantile(0.95, sum by (le, http_route) (rate(http_server_request_duration_seconds_bucket{service_name="fulfillment-execution"}[5m]))) > 0.5claim-next and complete are on the station's critical path.