Skip to main content

Observability

Logs, metrics and traces follow the fleet observability standard (ADR 0006): JSON logs on stdout (shipped by the cluster's log agent to Loki), OTLP/gRPC metrics and traces to the Collector (Prometheus and Jaeger behind it). Export never blocks: the gRPC exporters connect lazily and no blocking dial is set, so a Collector that is absent or down costs telemetry and nothing else.

All three binaries (cmd/api, cmd/mcp, cmd/a2a) call the same telemetry.Setup (internal/adapters/outbound/telemetry/telemetry.go) before building their HTTP router and flush it last on shutdown (bounded to 5 s).

Exporter and resource variables​

VariableDefaultEffect
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317Collector OTLP/gRPC endpoint. A bare host:port is turned into http://host:port. In the chart: otel.endpoint, default otel-collector.observability.svc.cluster.local:4317.
OTEL_SERVICE_NAMEcheckout (checkout-mcp, checkout-a2a)service.name on every span and metric; the chart derives <name>-mcp and <name>-a2a.
SERVICE_VERSIONdevservice.version. The chart sets the image tag.
ENVIRONMENTlocaldeployment.environment.name. The chart sets production.
OTEL_RESOURCE_ATTRIBUTESnonemerged by the SDK's default resource.
LOG_LEVELinfolog level (the OpenTelemetry SDK's own diagnostics are routed through the same logger; exporter errors are logged at DEBUG).

Metrics are pushed every 15 seconds. The propagator is W3C traceparent plus baggage.

Metrics​

InstrumentTypeUnitAttributesEmitted by
checkout.sessions.confirmedcounter (int64){session}outcome, reason (set only when there is one)cmd/api, one increment per ConfirmSession attempt (internal/adapters/outbound/telemetry/session_metrics.go, meter github.com/IQVO/checkout)
http.server.request.durationhistogram (float64)sHTTP method, route pattern and status, as set by otelchi's metric middlewareall three binaries (otelchimetric); buckets 5 ms to 10 s. Prometheus exposes it as http_server_request_duration_seconds_*.
Go runtime (go.* / runtime.go.*)gauges and countersvariousnoneOTel Go runtime instrumentation (goroutines, heap, GC)

outcome is one of completed, declined, requote-required, failed, in-doubt or refused. reason says why when the outcome is not a success:

outcomeMeaningTypical reason
completedthe order was placednone
requote-requiredthe network re-quoted; the authorization is voidednone
declinedpayment refused, or the authorized amount was not the quote totalpayment-declined, authorization-mismatch, or authorization-rejected: <slug>
failedthe place-order step rejected the request (or the session had already failed)the failure code, place-order-rejected
in-doubtthe outcome is unknown and a policy resolves itplacement-in-doubt (PLACING) or authorization-unknown (AUTHORIZING)
refusedthe confirm was refused before or after the sagasession-closed, price-quote-expired, not-found, concurrent-update, illegal-transition, validation-failed, internal-error

Reading it (from the instrument's own description): a falling completed share with rising declined means payment is refusing shoppers; rising requote-required means offers expire or change before shoppers confirm; rising in-doubt means the place-order step is slow or failing and orders may be unaccounted for; rising refused with internal-error means the service itself is failing.

There is no gauge for outbox depth or session-state counts: use the SQL in the Runbook.

Traces​

  • HTTP server span per request on every binary, from otelchi, named after the chi route pattern (POST /checkout-sessions, not the session id). The request logger runs inside the span, so its record carries trace_id and span_id.
  • a2a.skill <skill> (internal/adapters/inbound/a2a/skills.go): one span per skill call in cmd/a2a, attribute a2a.skill; status Error with the problem detail when the skill answers a problem.
  • The outbound HTTP calls to the five siblings use a plain net/http client without OpenTelemetry instrumentation, so they are not child spans and the siblings do not receive a traceparent.
  • Trace to Kafka. traceparent and tracestate of the active span are stamped into the outbox row's headers inside the same transaction (internal/adapters/outbound/postgres/outbox_trace.go), and the relay publishes them as ordinary Kafka headers; a consumer can parent its span on the request that caused the event.
  • The MCP adapter has no span of its own beyond the HTTP server span.

Logs​

JSON, one object per line on stdout, written by log/slog. Records written with a span-carrying context also carry trace_id and span_id.

Request line​

One line per HTTP request on every binary (/healthz and /readyz excluded):

{"time":"2026-10-31T11:28:59.066321-03:00","level":"INFO","msg":"http request","method":"POST","route":"/checkout-sessions/{sessionId}/confirmations","status":200,"duration_ms":22,"bytes":530,"request_id":"host/6PjAIOZFQZ-000005","trace_id":"766e93aad4b6a5d1c52e413bbd667a19","span_id":"f621fd37e5f0d148"}

Fields: method, route (the matched pattern, unmatched when nothing matched, never the raw path), status, duration_ms, bytes, request_id. Level: 5xx is ERROR, 4xx WARN, everything else INFO.

Messages​

LevelmsgWhereFields
INFOtelemetry configuredallservice_name, otlp_endpoint
INFOpostgres adapters configured / postgres repositories configuredapi / mcp, a2a
INFOsucceeded after retrybootop, attempt
WARNretryingboot (migrations, Postgres ping)op, attempt, in, err
INFOscheduler runningapijob, interval
INFOoutbox relay runningapiinterval, max_attempts, events_topic, analytics_topic
INFOhttp server listening / mcp server listening (Streamable HTTP) / a2a agent listening (JSON-RPC over HTTP)alladdr
INFOscheduled sweep doneapi, only when a tick handled somethingjob, handled
ERRORscheduled sweep failed; trying again at the next tickapijob, handled, error
ERRORoutbox relay pass failedapierror
ERRORoutbox relay: row reached the attempt cap and is excluded from future claims; re-arm it with attempts = 0 after fixing the causeapioutbox_id, topic, event_type, key, attempts, max_attempts, error
WARNreadiness: dependency is not readyapidependency (postgres or kafka), error
WARNauthorization outcome unknown, the session stays AUTHORIZINGapisessionId, error
WARNvoid failed, it stays owed / recording the void failedapisessionId, error
WARNalertapicode, sessionId, detail (companion of every ERROR ALERT)
WARNrequoted offer time zone unusable; delivery dates fall back to UTCapithe zone and the offer
WARNinvalid <VAR>; using the default / ignoring invalid SHUTDOWN_DRAIN_DELAYapivalue, default
ERRORrequest failedapierror, method, path (an unmapped error answered 500)
ERRORmcp tool failed with an unexpected error / a2a skill failed with an unexpected errormcp, a2aerror
INFOshutdown: readiness flipped to not-ready; waiting for traffic to drainapidrain_delay
WARNworker did not stop before the shutdown drain deadlineapiworker
ERRORservice exited with error / mcp server exited with error / a2a agent exited with errorallerror

Alerts​

The saga raises named alerts as ERROR lines through internal/adapters/outbound/alerts:

{"level":"ERROR","msg":"ALERT","alert":"placement-in-doubt-20h","sessionId":"sess-...","detail":"in doubt for 20h0m0s"}
alertRaised when
placement-in-doubt-20ha session has been PLACING for 20 h (once)
placement-given-up-22hthe 22 h give-up fired: FAILED with the void owed
place-order-rejectedcustomer-ordering answered 400 or 422 (a contract bug on this side)
authorization-mismatchcustomer-payments authorized an amount or currency that is not the quote total
sibling-contract-violationsibling data cannot form a consistent session (HTTP 502 upstream-contract-violation)

No rule in warehouse-infra matches these alert codes today (see below); they are visible in Loki.

Dashboards and alerts that exist​

Only what is in warehouse-infra develop:

  • Dashboard terraform/dashboards/contexts/checkout.json, "Warehouse — Checkout" (http://localhost:3000/d/warehouse-checkout on the local cluster). Panels: Kong request rate by code, Kong 5xx error rate, Kong latency p95 (request vs upstream), request rate by route and request duration p95 per process (http_server_request_duration_seconds_* for service_name=~"checkout.*"), Go runtime goroutines and memory, and Loki log panels for {app="checkout"} (live stream, volume by level, errors and warnings). No panel queries checkout.sessions.confirmed.
  • Alert rules terraform/alerting/warehouse-alert-rules.json, groups warehouse-checkout and warehouse-checkout-slo: WarehouseKong5xxRatioHigh (5xx ratio above 5 %, per Kong route), WarehousePodRestarting (two or more restarts of checkout-.+ in 15 min), and the SLO burn-rate rules WarehouseApiAvailabilityBurnFast, WarehouseApiLatencyBurnFast, WarehouseApiAvailabilityBurnSlow, WarehouseApiLatencyBurnSlow (availability objective 99 %, latency objective 95 % under 400 ms). All link to docs/operations/runbook.md of this repository (runbook_url).
  • There is no outbox-lag rule for checkout (WarehouseOutboxLagHigh exists for other contexts only) and no rule on the ALERT log codes or on checkout.sessions.confirmed.