Skip to main content

Observability

All three binaries (cmd/api, cmd/mcp, cmd/a2a) follow the same fleet observability standard (ADR 0008): OpenTelemetry traces and metrics pushed over OTLP/gRPC to a Collector, JSON logs on stdout that carry trace_id and span_id, and no Prometheus scrape endpoint. Export never blocks boot: the gRPC exporters connect lazily, so an absent Collector costs telemetry, never availability.

Source: internal/adapters/outbound/telemetry/telemetry.go (Setup), cmd/api/telemetry.go, cmd/mcp/telemetry.go, cmd/a2a/telemetry.go.

Exporter configuration​

VariableDefaultEffect
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317Collector OTLP/gRPC endpoint (host:port or URL). Used for traces and metrics.
OTEL_SERVICE_NAMEseller-inbound (cmd/api), seller-inbound-mcp, seller-inbound-a2aservice.name resource attribute and the otelchi server name.
SERVICE_VERSIONdevservice.version resource attribute.
ENVIRONMENTlocaldeployment.environment.name resource attribute.
LOG_LEVELinfoLog threshold; the OTel SDK's own diagnostics go through the same slog handler (exporter errors at debug).

Metrics are pushed every 15 s by a periodic reader. Traces use a batch span processor. The W3C traceparent and baggage propagators are installed globally. Full tables per binary: Configuration.

Metrics​

InstrumentTypeUnitAttributesEmitted bySource
seller_inbound.shipment.shippedcounter (Int64){shipment}outcome = shipped or rejected; reason (only when rejected) = the problem slug, for example shipment-not-labelled, seller-suspended, node-cannot-receive, internal-errorcmd/apiinternal/adapters/outbound/telemetry/shipment_metrics.go, internal/application/usecases/shipment_metrics.go
http.server.request.durationhistogram (Float64)shttp.method, http.scheme, http.route (chi route pattern, never the raw path); no status codeall three binariesotelchi metric package, wired in internal/adapters/inbound/http/server.go, cmd/mcp/router.go, cmd/a2a/router.go
Go runtime metrics (go.goroutine.count, go.memory.used, GC and heap series)gauges / countersper the OTel Go runtime instrumentationruntime-definedall three binariesruntime.Start in telemetry.Setup (go.opentelemetry.io/contrib/instrumentation/runtime)

Explicit histogram buckets of http.server.request.duration (seconds): 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10.

seller_inbound.shipment.shipped counts every attempt to ship an inbound shipment. A falling shipped share with a rising shipment-not-labelled means sellers reach the ship step before labelling every carton; a rising node-cannot-receive means destination nodes refuse stock; a rising internal-error means the service itself fails.

What is not instrumented: consumer lag, outbox backlog and age, dead-letter counts, scorecard computations. The service has no custom instrument for them; the Runbook and Troubleshooting give the SQL and Kafka reads that replace them.

Traces​

SpanCreated byNotes
Server span per HTTP request, named after the chi route patternotelchi.Middleware in the three routersOne span name per route, not per id. Mounted before the logger so log lines carry its ids.
<topic> process (kind CONSUMER)internal/adapters/inbound/kafka/tracing.goAttributes messaging.system=kafka, messaging.destination.name, messaging.operation.name=process. Parented on the traceparent header of the message, a new trace when absent. An error from the handler records the error on the span.
a2a.skill <skill>internal/adapters/inbound/a2a/skills.goAttribute a2a.skill. Status Error when the skill answers a problem.

Trace propagation across the outbox: when a use case appends an event, internal/adapters/outbound/postgres/outbox_repository.go injects the active span's traceparent into the row's headers, and the relay puts it on the Kafka message. Consumers of this service extract it the same way, so a trace follows an event across services.

Logs​

JSON via log/slog on stdout; time, level, msg plus the fields below. The handler is wrapped by telemetry.WithTraceContext, which stamps trace_id and span_id on every record written with a context that holds a span (the *Context slog calls). Boot, shutdown and background-loop lines have none.

WhereLevelmsgFields
Request (cmd/api, cmd/mcp, cmd/a2a)INFO / WARN (4xx) / ERROR (5xx)http requestmethod, route (pattern or unmatched), status, duration_ms, bytes, request_id. /healthz and /readyz are not logged.
RESTERRORrequest failed (an unmapped error, answered 500 internal-error with the fixed detail an unexpected error occurred)error, method, path (CR and LF removed by sanitizeLog, internal/adapters/inbound/http/logsafe.go)
MCPERRORmcp tool failed with an unexpected errorerror
BootINFOtelemetry configuredservice_name, otlp_endpoint
BootINFOpostgres adapters configured, http server listeningaddr
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 / cmd/mcp / cmd/a2aINFOmcp server starting, a2a server startingversion, environment and addresses (agent_url for A2A)
Boot failureERRORservice exited with error / mcp server exited with error / a2a server exited with error (exit 1)error
ConsumersINFOconsumer runningconsumer (node consumer, catalog consumer, receipt consumer), topic, brokers
ConsumersINFOevent processed (receipt consumer only)type, event_id, subject
ConsumersWARNskipping a message that is not a valid CloudEventconsumer, topic, error
ConsumersWARNdead-lettering an event that can never be appliedconsumer, type, event_id, error
ConsumersWARN<consumer> broker connection stalled or lost; fetching again after the backofferror, attempt, backoff
ConsumersERROR<consumer> handling failed; retrying the same messageerror, partition, offset, attempt, max_attempts, retry_in
ConsumersERROR<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)
ConsumersERROR<consumer> offset commit failed; retrying the same message, <consumer> dead-letter publish failed; retrying the same messageerror, partition, offset, attempt, retry_in
ConsumersERRORconsumer stopped (the worker ends; the process then exits)consumer, error
RelayINFOoutbox relay runningpublisher, interval, max_attempts, topic
RelayERRORoutbox relay pass failederror (text starts outbox row <id> (<type>):)
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
Retention sweeperINFO / ERRORloop running, loop pass done / loop pass failedloop (retention sweeper), interval, count / error
ReadinessWARNreadiness: dependency is not ready (once per check round, cached 3 s)dependency (postgres or kafka), 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 deadline / telemetry flush failed on shutdowndrain_delay / value, default / worker / error

REST errors are application/problem+json documents whose type is the bare problem slug; the slug and status table is in Troubleshooting.

Probes​

GET /healthz (liveness, always 200) and GET /readyz on cmd/api (200 only while the drain gate is open, Postgres answers a ping and a Kafka broker answers a metadata request; 503 not_ready while draining, 503 dependency-unavailable naming the failing dependency otherwise). cmd/mcp and cmd/a2a serve /healthz only. Details in the Runbook and Runtime.

Dashboards and alerts that exist​

Read from warehouse-infra on origin/develop:

  • Grafana dashboard warehouse-seller-inbound (terraform/dashboards/contexts/seller-inbound.json, generated by scripts/gen-context-dashboards.py): Kong request rate, 5xx ratio and p95 latency for the context's routes; service RED panels from http_server_request_duration_seconds_* filtered service_name=~"seller-inbound.*" (request rate by route, request duration p95 by process, 5xx per Kong route); the business panel seller_inbound_shipment_shipped_total by outcome; Go goroutines and memory; and Loki panels (live log stream, log volume by level, errors and warnings) on {app="seller-inbound", container!~"istio-proxy|istio-init"}.
  • Alert rules (terraform/alerting/warehouse-alert-rules.json), groups warehouse-seller-inbound and warehouse-seller-inbound-slo, all from Kong metrics and kube-state: WarehouseKong5xxRatioHigh (more than 5 % 5xx on a Kong route for 5 minutes, warning), WarehousePodRestarting (two or more restarts in 15 minutes, warning), WarehouseApiAvailabilityBurnFast and WarehouseApiLatencyBurnFast (critical), WarehouseApiAvailabilityBurnSlow and WarehouseApiLatencyBurnSlow (warning). The SLO targets are 99 % availability and 95 % of requests under 500 ms (measured at the 400 ms Kong bucket).
  • Not covered by any alert or panel: outbox backlog, consumer lag, dead letters, receipts waiting. There is no outbox lag gauge in this service.
  • Logs reach Loki through Alloy, which maps the pod label app.kubernetes.io/name to the Loki label app.

The alert annotations in warehouse-infra still link runbook_url to https://github.com/IQVO/seller-inbound/blob/develop/docs/operations/runbook.md, a path this site's scaffold moved to docs/docs/operations/runbook.md; the link is owned by warehouse-infra and not changed here.

Suggested checks​

Not shipped as rules; they are the reads that replace the missing instruments.

SignalReadWorrying when
Outbox backlogSELECT count(*), min(created_at) FROM outbox_events WHERE published_at IS NULLoldest row older than a few minutes
Rows parked at the capSELECT id, event_type, attempts, 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
Consumer lagKafka consumer-group lag of the four groupsgrowing, or the same partition/offset repeating in handling failed; retrying
Dead lettersdepth of retailnetwork.node-topology.events.dlq, retailnetwork.offer-availability.events.dlq, retailnetwork.vendor-connectivity.events.dlq, retailnetwork.order-sourcing.events.dlqany message; headers x-dlq-error, x-dlq-source-offset say why
Failed ship attemptsseller_inbound_shipment_shipped_total{outcome="rejected"} by reasona rising internal-error or node-cannot-receive
Boot loopservice exited with error and the WarehousePodRestarting alertany
Table growthrow counts of outbox_events, processed_events (nothing deletes them) and idempotency_keys (purged after 24 h)capacity planning