Skip to main content

Observability

Logs, metrics and traces follow the fleet standard (ADR 0005). Everything below is read from the code on this branch and from warehouse-infra develop.

Exporter configuration​

internal/adapters/outbound/telemetry/telemetry.go (Setup) builds a TracerProvider and a MeterProvider that export over OTLP/gRPC to a Collector, installs the W3C traceparent + baggage propagator and starts the Go runtime metrics. Metrics are pushed every 15 s. Export is non-blocking: the exporters connect lazily, so a missing Collector costs telemetry, never availability (exporter errors are logged at DEBUG as opentelemetry error). A flush of at most 5 s runs last on shutdown.

VariableDefaultAll binaries?
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317 (bare host:port or URL; a bare value gets http://)yes
OTEL_SERVICE_NAMEproduct-content (cmd/api), product-content-mcp (cmd/mcp), product-content-a2a (cmd/a2a)yes, different defaults
SERVICE_VERSIONdevyes
ENVIRONMENTlocal (deployment.environment.name)yes
LOG_LEVELinfoyes

The chart renders OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_SERVICE_NAME from otel.endpoint (otel-collector.observability.svc.cluster.local:4317) and otel.serviceName when otel.enabled is true (the default); the MCP pod gets <serviceName>-mcp and the A2A pod <serviceName>-a2a. See Configuration.

Metrics​

InstrumentTypeUnitAttributesEmitted bySource
content.products.published (Prometheus content_products_published_total)counter (Int64){publication}outcome = published | rejected; reason (on rejected only) = a problem slug: not-found, content-retired, unknown-catalog-item, item-discontinued, incomplete-content, unknown-category, concurrent-update, illegal-transition, validation-failed, internal-errorcmd/apiinternal/adapters/outbound/telemetry/content_metrics.go, internal/application/usecases/content_metrics.go
http.server.request.durationhistogramsroute (chi pattern), method (otelchi metric defaults)all three binariesotelchimetric.NewServerRequestDuration 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 others)variousvariousvariousall three binariesgo.opentelemetry.io/contrib/instrumentation/runtime, started in telemetry.Setup

The business counter is incremented once per PublishContent attempt: a revision that was saved counts outcome=published; a refusal counts outcome=rejected with the reason. A publish with nothing new to publish (idempotent no-op) counts neither. The counter binds to the global MeterProvider after telemetry.Setup (NewContentMetrics is called after it in cmd/api/main.go). The status code is not an attribute of the HTTP histogram in this fleet; use Kong's kong_http_requests_total for 5xx.

Traces​

SpanKindCreated byAttributes
<METHOD> <chi route pattern> (one name per route, not per item id)serverotelchi.Middleware in the REST router, in cmd/mcp and in cmd/a2aHTTP semantic attributes
<topic> process (for example retailnetwork.offer-availability.events process)consumerinternal/adapters/inbound/kafka/tracing.gomessaging.system=kafka, messaging.destination.name, messaging.operation.name=process; errors are recorded on the span
a2a.skill <skill id>internalinternal/adapters/inbound/a2a/skills.goa2a.skill; status Error with the problem detail when the skill answers a problem

Trace context crosses Kafka: when a use case enqueues an event, the active span context is injected as traceparent/tracestate into the outbox row's headers in the same transaction (internal/adapters/outbound/postgres/outbox_trace.go), the relay publishes them as Kafka headers, and the consumer (this service or product-discovery) extracts them as the parent of its <topic> process span. A message without the headers starts a new trace. The outbox relay and the Postgres calls create no spans of their own.

Logs​

JSON on stdout (log/slog), level from LOG_LEVEL. The handler is wrapped by telemetry.WithTraceContext (internal/adapters/outbound/telemetry/slogotel.go), so a record written with a span-carrying context gets trace_id and span_id.

Log line (msg)LevelFieldsSource
http request (one per call; /healthz and /readyz are skipped)INFO (2xx/3xx), WARN (4xx), ERROR (5xx)method, route (pattern, never the raw path), status, duration_ms, bytes, request_id, trace_id, span_idinternal/adapters/inbound/requestlog/requestlog.go
telemetry configuredINFOservice_name, otlp_endpointcmd/api/telemetry.go, cmd/mcp/telemetry.go, cmd/a2a/main.go
readiness: dependency is not readyWARNdependency (postgres or kafka), errorinternal/adapters/inbound/http/readiness.go
postgres adapters configured / postgres read side configured / postgres repositories configuredINFOnonecmd/api/main.go, cmd/a2a/main.go, cmd/mcp/main.go
mcp server starting / mcp server listening (Streamable HTTP)INFOversion, environment / addrcmd/mcp/main.go
retrying, succeeded after retry (boot migrations / first ping)WARN / INFOop, attempt, in, errinternal/bootretry/bootretry.go
consumer runningINFOconsumer, topic, group_id, brokerscmd/api/main.go
outbox relay runningINFOinterval, max_attempts, topiccmd/api/main.go
outbox relay pass failedERRORerrorinternal/adapters/outbound/outbox/relay.go
outbox relay: row reached the attempt cap and is excluded from future claims; re-arm it with attempts = 0 after fixing the causeERROR, once per rowoutbox_id, topic, event_type, key, attempts, max_attempts, errorrelay.go (AttemptCapReachedMsg)
<consumer> handling failed; retrying the same messageERRORerror, partition, offset, attempt, max_attempts, retry_ininternal/adapters/inbound/kafka/kafka.go
<consumer> message can never be applied; dead-lettering it without retry / ... handling failed after the maximum attempts; dead-lettering the messageERRORerror, partition, offset, attemptskafka.go
<consumer> broker connection stalled or lost; fetching again after the backoffWARNerror, attempt, backoffkafka.go
skipping a message that is not a valid CloudEventWARNconsumer, topic, errorinternal/adapters/inbound/kafka/consumer.go
dead-lettering an event that can never be applied / skipping an event that can never be appliedWARNconsumer, type, event_id, errorconsumer.go
shutdown: readiness flipped to not-ready; waiting for traffic to drainINFOdrain_delaycmd/api/main.go
<worker> stopped unexpectedly: ... / consumer stopped / outbox relay stoppedERRORconsumer, errorcmd/api/main.go
a2a skill failedERRORerrorinternal/adapters/inbound/a2a/skills.go
mcp tool failed with an unexpected errorERRORerrorinternal/adapters/inbound/mcp/errors.go
invalid OUTBOX_RELAY_INTERVAL; using the default, invalid OUTBOX_MAX_ATTEMPTS; using the default, ignoring invalid SHUTDOWN_DRAIN_DELAYWARNvalue, defaultcmd/api/config.go

Dashboards and alerts (warehouse-infra develop)​

ArtifactWhereWhat it shows
Grafana dashboard warehouse-product-content ("Warehouse - Product Content")terraform/dashboards/contexts/product-content.jsonKong request rate, 5xx ratio and p95 latency (request vs upstream) for the context's routes; service HTTP RED by route (http_server_request_duration_seconds_count, p95 by process, 5xx by Kong route); the business panel sum by (outcome) (rate(content_products_published_total[5m])); Go goroutines and memory; Loki live log stream, log volume by level and an errors-and-warnings stream for {app="product-content"}
Alert group warehouse-product-contentterraform/alerting/warehouse-alert-rules.jsonWarehouseKong5xxRatioHigh (5xx ratio above 5%), WarehousePodRestarting (two or more container restarts of product-content-.+ pods in 15 min)
Alert group warehouse-product-content-slosame filemulti-window burn-rate alerts WarehouseApiAvailabilityBurnFast, WarehouseApiLatencyBurnFast, WarehouseApiAvailabilityBurnSlow, WarehouseApiLatencyBurnSlow (availability: 1 % 5xx budget; latency: at most 5 % of requests slower than 400 ms upstream; fast windows 1 h and 5 m at burn rate 14.4, slow windows 6 h and 30 m at burn rate 3)

All alert annotations point their runbook_url at this repo's runbook (docs/operations/runbook.md on develop, now served at Runbook) and their dashboard_url at the dashboard above. There is no alert on outbox lag for this context (the WarehouseOutboxLagHigh rule exists only for other contexts), none on consumer lag, and no panel for the MCP or A2A pod beyond the shared service_name=~"product-content.*" selectors (the MCP server's product-content-mcp falls under that pattern). When this page was written the dashboard and the Kong selectors also mentioned -mcp and -reports routes; -mcp now has a counterpart in this repo (off until warehouse-infra switches it on), -reports has none.

Debugging pointers: Troubleshooting.