Skip to main content

Observability

Logs, metrics and traces follow the fleet standard (ADR 0008). All three binaries export OTLP/gRPC to the Collector; logs are JSON on stdout for Alloy and Loki. Export never blocks: the gRPC exporters connect lazily and no blocking dial option is set, so a Collector that is down or absent costs telemetry and nothing else.

Source: internal/adapters/outbound/telemetry/ (telemetry.go, slogotel.go, sourcing_metrics.go), cmd/*/telemetry.go, internal/adapters/inbound/requestlog/requestlog.go.

Exporter variables​

VariableDefaultApplies to
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317all; bare host:port becomes http://host:port, a URL is used as is. The chart sets otel-collector.observability.svc.cluster.local:4317
OTEL_SERVICE_NAMEorder-sourcing (cmd/api), order-sourcing-mcp, order-sourcing-a2aall; the resource attribute service.name
SERVICE_VERSIONdevall; service.version (the chart passes the image tag)
ENVIRONMENTlocalall; deployment.environment.name
LOG_LEVELinfoall; debug, info, warn or warning, error

Metrics are pushed by a periodic reader every 15 s. OTEL_RESOURCE_ATTRIBUTES is honoured through the SDK default resource. SDK diagnostics (for example "no collector listening") are logged at DEBUG, so they do not appear at the default level. A flush failure on shutdown is logged at WARN telemetry flush failed on shutdown (5 s bound).

Metrics​

InstrumentTypeUnitAttributesEmitted byMeaning
sourcing.groups.sourced (Prometheus: sourcing_groups_sourced_total)Int64Counter, meter github.com/claudioed/order-sourcing{group}outcome: queued, released, unsourceable or failed; reason (only when outcome=failed): concurrent-update, duplicate-group, validation-failed, internal-errorcmd/apiOne count per shipment group that QueueAssignment turned into an assignment, labelled with the state it was created in; one failed count per command that stored nothing. A rolled-back attempt never counts a group and a replayed event (nothing created) records nothing
ordersourcing.budget.preferred (Prometheus: ordersourcing_budget_preferred_total)Int64Counter, meter github.com/claudioed/order-sourcing{release}kind: regioncmd/apiOne count per release whose winner the sourcing policy's cost-deviation budget changed relative to the pure cheapest ordering (ADR 0014). Counted after the commit; single_node does not exist because order-sourcing plans no order-level split
ordersourcing.sourcing.policy.version (Prometheus: ordersourcing_sourcing_policy_version)Int64ObservableGauge, same meter{version}nonecmd/apiThe sourcing policy version the last search read or publish stored; 0 = the default policy (nothing published)
http.server.request.duration (Prometheus: http_server_request_duration_seconds_*)Float64Histogram (otelchi metric middleware)sthe otelchi base attributes; no status-code attribute in this fleetall threeRequest duration per route; /healthz and /readyz are included in the metric but not in the access log
Go runtime metrics (go.goroutine.count, go.memory.used, GC and heap series)from go.opentelemetry.io/contrib/instrumentation/runtimeper seriesper seriesall threeGoroutines, memory and GC

cmd/mcp and cmd/a2a register no business instrument. Because http.server.request.duration has no status attribute, 5xx rates come from Kong (kong_http_requests_total) in the dashboard and alerts, not from the service.

Traces​

SpanKindCreated byAttributes
<METHOD> <chi route pattern> (one name per route, not per assignment id)serverotelchi middleware in all three routersotelchi defaults
<topic> process (for example retailnetwork.customer-ordering.events process)consumerinternal/adapters/inbound/kafka/tracing.go, one per handling attempt, parented to the producer's span from the traceparent header (a message without one starts a new trace)messaging.system=kafka, messaging.destination.name, messaging.operation.name=process; errors are recorded on the span
a2a.skill <skill id>internalcmd/a2a, around each skill run that parseda2a.skill; status Error on a problem answer

The trace continues across Kafka: when an event is appended to outbox_events, the active span's W3C traceparent (and tracestate, baggage when present) is stored in the row's headers, and the relay copies it onto the Kafka message. Consumers of this service extract it. The MCP adapter creates no tool span of its own: an MCP call is visible only as the HTTP server span. (A comment in internal/adapters/inbound/a2a/skills.go:25 mentions "mcp.tool spans"; no such span exists in this repository.)

Logs​

JSON via log/slog on stdout, one object per line with time, level, msg and the fields below. Records written with a span-carrying context (the *Context slog calls) also carry trace_id and span_id; boot, shutdown and background-worker records written with plain slog.Info do not.

WhereLevelmsg (abridged)Fields
Access log (all three)INFO / WARN (4xx) / ERROR (5xx)http requestmethod, route (the pattern, never the raw path), status, duration_ms, bytes, request_id. /healthz and /readyz are skipped
Boot (api)INFOtelemetry configured; consumer running; outbox relay running; queue sweep running; http server listeningservice_name, otlp_endpoint; consumer, topic, group_id, brokers; publisher, interval, max_attempts, topics; interval; addr
Boot (mcp, a2a)INFOmcp server starting / a2a agent starting; postgres repositories configured; mcp server listening (Streamable HTTP)service_version, environment; addr
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 default, invalid SWEEP_INTERVAL; using the default, ignoring invalid SHUTDOWN_DRAIN_DELAYvalue, default
Boot failureERRORservice exited with error / mcp server exited with error / a2a agent exited with error (exit 1)error
ShutdownINFO / WARNshutdown: readiness flipped to not-ready; waiting for traffic to drain; worker did not stop before the shutdown drain deadlinedrain_delay; worker
ReadinessWARNreadiness: dependency is not ready (once per check round, at most every 3 s)dependency (postgres or kafka), error
ConsumerWARNskipping a message that is not a valid CloudEvent; dead-lettering an event that can never be applied; skipping an event the aggregate can no longer takeconsumer, topic, 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; <consumer> message can never be applied; dead-lettering it without retryerror, partition, offset (and attempts)
ConsumerERROR<consumer> offset commit failed; retrying the same message; <consumer> dead-letter publish failed; retrying the same messageerror, partition, offset, attempt, retry_in
ConsumerWARN<consumer> broker connection stalled or lost; fetching again after the backofferror, attempt, backoff
ConsumerERRORconsumer stopped (the reader failed for good; the process then exits)consumer, error
RelayERRORoutbox relay pass failederror
RelayERRORoutbox relay: row reached the attempt cap and is excluded from future claims; re-arm it with attempts = 0 after fixing the causeoutbox_id, topic, event_type, key, attempts, max_attempts, error
RelayERRORoutbox relay stopped, kafka relay sink close failederror
SweepINFOqueue sweep (only when it did something)released, reoptimised, skipped
SweepERRORqueue sweep pass failederror
MCPERRORmcp tool failed with an unexpected errorerror
A2AERRORa2a skill failed with an unexpected errorerror

<consumer> is the consumer name, the short topic name: customer-ordering, delivery-promise, last-mile-delivery, linehaul-transportation, node-performance, node-topology, offer-availability, shipping-and-tracking or vendor-connectivity (the worker that supervises it is reported as <name> consumer when it exits).

REST errors are application/problem+json documents whose type is https://errors.order-sourcing.retail-network.example/<slug>; the slug and status table is in Troubleshooting.

Dashboards and alerts that exist​

From warehouse-infra origin/develop (nothing else was found there):

ArtifactWhereContent
Grafana dashboard warehouse-order-sourcingterraform/dashboards/contexts/order-sourcing.jsonKong request rate, 5xx ratio and p95 latency (request versus upstream); service request rate by route and p95 by process (http_server_request_duration_seconds); sum by (outcome) (rate(sourcing_groups_sourced_total[5m])); Go goroutines and memory; Loki log stream, log volume by level, errors and warnings
Alert group warehouse-order-sourcingterraform/alerting/warehouse-alert-rules.jsonWarehouseKong5xxRatioHigh (warning, 5 m, 5xx ratio above 0.05), WarehousePodRestarting (warning, at least 2 restarts in 15 m of a pod named order-sourcing-.+)
Alert group warehouse-order-sourcing-slosame fileWarehouseApiAvailabilityBurnFast and WarehouseApiLatencyBurnFast (critical, 2 m), WarehouseApiAvailabilityBurnSlow and WarehouseApiLatencyBurnSlow (warning, 15 m); availability SLO 99 percent, latency SLO 400 ms upstream at 95 percent

There is no alert on outbox backlog, consumer lag, dead-letter volume or the unsourceable share of sourcing_groups_sourced_total. The alert annotations link a runbook_url on the pre-site path docs/operations/runbook.md.

Suggested checks​

Built from the data that exists, not shipped as rules:

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
Rows parked at the capERROR row reached the attempt cap; ... WHERE published_at IS NULL AND attempts >= 20any row
Dead lettersERROR dead-lettering lines; depth of the <topic>.dlq topicsany message
Consumer stuck on one messagerepeated handling failed; retrying the same message with the same partition and offsetmore than the 5 attempts' worth
Unsourceable sharesourcing_groups_sourced_total{outcome="unsourceable"} against the totala rising share means stock, lanes or service areas are missing for what is promised
Service failingsourcing_groups_sourced_total{outcome="failed",reason="internal-error"}any sustained rate: orders are not being sourced
ReadinessGET /readyz 503 dependency-unavailable; WARN readiness: dependency is not readynot ready for more than a minute
Table growthrow counts of outbox_events, idempotency_keys, processed_events (nothing deletes outbox_events or processed_events; expired idempotency_keys rows are purged hourly)capacity planning