Skip to main content

Observability

yard-management follows the fleet observability standard (ADR 0017): every long-running binary (cmd/api, cmd/mcp, cmd/relay, cmd/yard-projector, cmd/yard-reports) calls telemetry.Setup, which exports traces and metrics over OTLP/gRPC to the OpenTelemetry Collector, and writes JSON logs whose records carry trace_id and span_id when they are written under a span. The service has no Prometheus endpoint of its own: the Collector re-publishes the metrics. Export never blocks: an unreachable Collector costs telemetry, not availability (the exporters connect lazily, and a failed flush at shutdown is logged, not an exit code).

What this page describes is the code on develop. Whether the image that runs on the k3s cluster contains it, and whether the series reach Prometheus, was not checked against a running pod.

Signals​

InstrumentKind, unitPrometheus series (after the Collector)Emitted byMeaning
http.server.request.durationhistogram, shttp_server_request_duration_seconds_{bucket,sum,count}api, mcp, yard-reports, yard-projector (admin port)Request duration, labelled http.route (the chi route pattern, /trailers/{trailerId}, never the raw path), http.method and http.scheme. It has no status attribute: request rate and duration come from it, an error rate from the gateway panels and the http request log lines.
yard.visits.checked_incounter, {visit}yard_visits_checked_in_totalapiGate check-ins by outcome (admitted, rejected, refused) and reason, see below.
Go runtime metricsgauges and countersgo_* (for example go_goroutine_count)every binaryGoroutines, heap, GC and scheduler latency, from go.opentelemetry.io/contrib/instrumentation/runtime.

Traces: every request to the api, mcp and reports routers (and the admin port of the projector) produces one server span named after the route pattern. The relay and the consumers start no span of their own.

yard.visits.checked_in​

Counts every gate check-in (CheckInVisit, behind POST /visits; the MCP server has no check-in tool), once, after its unit of work ended.

outcomereasonMeaning
admittednonea CHECKED_IN visit was recorded
rejectedseal-mismatch, carrier-suspendeda REJECTED visit was recorded: the site policy turned the truck away
refusedthe problem slug of the failure: visit-already-open, appointment-required, unknown-appointment, trailer-already-on-site, no-free-spot, invalid-carrier, validation, ... or internal-errornothing was persisted

A rising rejected share means the policy is turning trucks away; a rising refused with a client reason means the gate clients send check-ins the rules refuse; a rising internal-error or concurrent-modification means the service itself is failing. A request replayed by the idempotency middleware does not run the use case and is not counted; a rejection recorded by hand (POST /visit-rejections) is another command and is not counted by this instrument.

Resource attributes and environment​

Every signal carries service.name, service.version and deployment.environment.name.

VariableDefaultMeaning
OTEL_SERVICE_NAMEyard-management (api), yard-management-mcp, yard-management-relay, yard-management-projector, yard-management-reportsservice.name
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317Collector OTLP/gRPC endpoint, host:port or a URL
SERVICE_VERSIONdevservice.version
ENVIRONMENTlocaldeployment.environment.name

The chart renders all four on every Deployment that runs a binary (otel.enabled, otel.endpoint, otel.serviceName, environment, serviceVersion); the sweeps CronJobs run wget, not a binary, and render none. See Configuration.

What is not instrumented​

A trace started by a REST or MCP request ends at the outbox insert: the outbox table has no column for the trace context, so no traceparent travels in the Kafka headers (ADR 0017, section 4). The Kafka consumers and the outbox relay have no spans and no metrics of their own (the data-level signals below cover them), and http.server.active_requests is not wired.

Logs​

Every binary writes JSON (log/slog) to stdout. LOG_LEVEL selects debug/info/warn/error for the api, mcp, projector and reports; the relay always logs at info. A record written with a span-carrying context (the *Context slog variants, which the access log and the request failed line use) also carries trace_id and span_id; the others (startup, shutdown, the consumers and the relay loops) carry none. Fields are those of the individual calls:

Message (abridged)LevelFieldsBinary
http request (one per request; INFO, WARN for 4xx, ERROR for 5xx; /healthz and /readyz are not logged)info/warn/errormethod, route (the route pattern, not the raw path), status, duration_ms, bytes, request_id, trace_id, span_idapi, mcp, reports, projector (admin)
telemetry configuredinfoservice_name, otlp_endpointall
telemetry flush failed on shutdownwarnerrorall
http server listening / mcp server listening (Streamable HTTP) / reports server listening / projector admin server listeninginfoaddrapi, mcp, reports, projector
shutdown: readiness flipped to not-ready; waiting for traffic to draininfodrain_delayapi, mcp, reports
consumer startinginfoconsumer, topicapi
event consumedinfoconsumer, type, event_id, subjectapi, projector
skipping a message that is not a valid CloudEventwarnconsumer, topic, errorapi, projector
an event that can never be applied; dead-lettering itwarnconsumer, type, event_id, errorapi, projector
<consumer> message can never be applied; dead-lettering it without retryerrorerror, partition, offsetapi, projector
<consumer> handling failed; retrying the same message (also offset commit, dead-letter publish)errorerror, partition, offset, attempt, retry_inapi, projector
kafka reader error; retryingerrortopic, detailapi, projector
a consumer died; shutting downerrorerrorapi
analytics consumer runninginfotopic, group_id, brokersprojector
readiness: dependency is not readywarndependency (postgres, kafka, analytics), errorall with /readyz
request failed (any unexpected 5xx)errorerror, method, pathapi, reports
mcp tool failed with an unexpected errorerrorerrormcp
boot step failed; retryingwarnstep, attempt, errorapi, mcp
outbox relay: send failed, stopping this pass at the failed rowwarnoutbox_id, topic, event_type, key, attempts, errorrelay
outbox relay: row reached the attempt cap and is excluded from future claims…erroroutbox_id, topic, event_type, key, attempts, max_attempts, errorrelay
outbox relay: dead-lettered a row the encoder refuses…warnrow and causerelay
outbox relay pass failederrorerrorrelay
relay: OUTBOX_MAX_ATTEMPTS is not a non-negative integer, using the defaultwarnvalue, defaultrelay
<binary> exited with error / relay: stopped with an errorerrorerrorall

method and path in request failed are sanitised against log injection (internal/adapters/inbound/http/logsafe.go). A 5xx never leaks its cause to the client: the problem detail is an unexpected error occurred.

Sources: internal/adapters/inbound/kafka/consumer.go and loop.go, internal/adapters/outbound/postgres/outbox_relay.go, internal/adapters/inbound/http/response.go and readiness.go, internal/adapters/inbound/requestlog/requestlog.go, the five cmd/*/main.go and cmd/*/telemetry.go.

Probes​

See Runbook. /readyz is the single best health signal: a 503 problem of type dependency-unavailable names the failing dependency.

Data-level signals​

These are what answers the questions no instrument covers (the outbox, consumer lag, the read side):

QuestionWhere to look
Are events leaving?SELECT count(*), min(created_at) FROM outbox; should stay near zero; the relay deletes a row once it is sent
Is a row stuck?outbox.attempts >= OUTBOX_MAX_ATTEMPTS (default 20), outbox.last_error; the ERROR log with outbox_id
Is the analytics read side fresh?GET /reports/freshness (last event time folded into the analytics schema)
Is a consumer wedged?repeated ERROR handling failed; retrying the same message with a growing attempt; consumer-group lag on the broker
Poison traffic?messages on warehouse.yard-management.events.dlq (header dlq-reason) and on <consumed topic>.dlq (headers x-dlq-source-topic, x-dlq-cause)
Are sweeps running?kubectl get cronjob,jobs for …-sweep-dwell and …-sweep-move-leases; failed Jobs keep their logs

Edge telemetry (Kong)​

The chart can render Kong plugins on the REST route (kongPlugins.prometheus, kongPlugins.opentelemetry, kongPlugins.cors, all off by default in the chart; templates/kong-plugins.yaml). warehouse-infra's helm-values/yard-management.yaml switches all three on. When on they emit request metrics and traces at the gateway, not from the service. There is deliberately no auth plugin.

Dashboards and alerts​

Registered in warehouse-infra origin/develop by PR 193 (commit b4b827e). The api and relay pods run (read-only on 2026-11-10), so the API-route Kong panels and the log panels can have data; the MCP and reports panels select Kong routes (-mcp, -reports) and processes that do not exist while those components are off, so expect them empty. Whether the dashboard and the rules are loaded in the observability stack was not checked.

Dashboard. terraform/dashboards/contexts/yard-management.json (title "Warehouse — Yard Management", uid warehouse-yard-management, generated by scripts/gen-context-dashboards.py). Four rows:

RowPanels
API Gateway (Kong), the north-south view of this context's routesRequest rate by status code; 5xx error ratio; p95 latency, Kong request against upstream. All select the Kong services of the API, MCP and reports routes (httproute.warehouse-systems.yard-management, -mcp, -reports).
Service HTTP RED (OLTP, projector, reports, MCP)Request rate by route; 5xx rate by Kong route (API, MCP, reports); request duration p95 by process. The service panels select service_name matching yard-management.*.
Go runtimeGoroutines; Go memory used.
LogsLive log stream, log volume by level, errors and warnings only, from Loki, queried by app="yard-management" (the Istio containers are excluded).

The service panels of rows two and three query OpenTelemetry-style names (http_server_request_duration_seconds, go_goroutine_count or runtime_go_*, keyed by service_name). The instruments above are the ones that produce those names, with the five service_name values of the table in Resource attributes, all matching yard-management.*. Until a release carrying this code is deployed and the Collector pipeline is confirmed, treat them as unverified: this was not checked against a running pod. The Kong and log panels do not depend on it. No panel or alert reads yard_visits_checked_in_total yet.

Alert rules. Six, in terraform/alerting/warehouse-alert-rules.json, all labelled context=yard-management, each linking this site's runbook and the dashboard:

GroupAlertSeverityFires when
warehouse-yard-managementWarehouseKong5xxRatioHighwarningA Kong route of this context answers 5xx for more than 5 % of its requests over 5 minutes, held for 5 minutes.
warehouse-yard-managementWarehousePodRestartingwarningA container of a pod named yard-management-* in warehouse-systems restarted 2 or more times in 15 minutes.
warehouse-yard-management-sloWarehouseApiAvailabilityBurnFastcriticalThe 5xx ratio burns the one-day 99 % availability budget at 14.4 times the allowed rate or more, over both 1 hour and 5 minutes, with at least 30 requests in the hour, held for 2 minutes.
warehouse-yard-management-sloWarehouseApiLatencyBurnFastcriticalThe share of upstream responses slower than 400 ms (the nearest Kong bucket to the 500 ms target of the one-day 95 % latency objective) burns the budget at 14.4 times or more, over 1 hour and 5 minutes, with at least 30 requests in the hour, held for 2 minutes.
warehouse-yard-management-sloWarehouseApiAvailabilityBurnSlowwarningThe same availability budget burns at 3 times or more over both 6 hours and 30 minutes, with at least 30 requests in 6 hours, held for 15 minutes.
warehouse-yard-management-sloWarehouseApiLatencyBurnSlowwarningThe same latency budget burns at 3 times or more over 6 hours and 30 minutes, with at least 30 requests in 6 hours, held for 15 minutes.

The rules read Kong (kong_http_requests_total, kong_upstream_latency_ms_*) and kube-state-metrics (kube_pod_container_status_restarts_total). There is still no rule on the log lines above, outbox backlog or consumer lag; those log lines remain the stable substrings to alert on.