Skip to main content

Observability

cmd/api, cmd/a2a and cmd/mcp follow the fleet observability standard (ADR 0005): JSON logs on stdout that carry trace_id and span_id, an OTLP/gRPC export of traces and metrics, two service counters (searches and poison messages), and the Go runtime metrics. cmd/rebuild exports the same way once, on exit. This page lists what the code emits; the dashboard and alert rules listed at the end are the ones that exist in warehouse-infra on develop. Nothing here is a captured run.

Source: internal/adapters/outbound/telemetry/ (telemetry.go, search_metrics.go, slogotel.go), internal/adapters/inbound/kafka/poison.go, cmd/api/telemetry.go, cmd/a2a/telemetry.go, cmd/mcp/telemetry.go, cmd/rebuild/main.go.

Exporter and resource​

ItemValue
ProtocolOTLP/gRPC for both traces and metrics, to OTEL_EXPORTER_OTLP_ENDPOINT (host:port or a URL; default localhost:4317; a bare host:port becomes plaintext http://)
Blockingnever: the exporters connect lazily, so an unreachable Collector costs telemetry and never availability or boot. Exporter errors are logged at DEBUG as opentelemetry error
Metric push interval15 s (PeriodicReader)
Trace sampling and batchingSDK defaults with a batch span processor
PropagationW3C traceparent / tracestate and baggage
service.nameOTEL_SERVICE_NAME; default product-discovery (api), product-discovery-a2a (agent), product-discovery-mcp (MCP server), product-discovery-rebuild (job)
service.versionSERVICE_VERSION, default dev
deployment.environment.nameENVIRONMENT, default local
Extra resource attributesOTEL_RESOURCE_ATTRIBUTES is honoured by the SDK default resource
Flushon shutdown with a 5 s deadline; a failed flush is logged as WARN telemetry flush failed on shutdown and never changes the exit code

The chart renders OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_SERVICE_NAME when otel.enabled is true (the default); see Configuration and the Runbook.

Metrics​

InstrumentTypeUnitAttributesEmitted byMeaning
discovery.searches.servedInt64 counter{search}outcome = served, empty or failed; reason = validation-failed or internal-error (only when outcome is failed)cmd/api, cmd/a2a and cmd/mcp, once per SearchProducts call (REST GET /products, the search_products skill and the search_products MCP tool)served: a page with hits, or a continuation page; empty: a first page that found nothing even after the trigram retry; failed: the search answered an error. A rising empty share means shoppers look for products the storefront does not show (check the projection feeds); failed with internal-error means the search itself is failing; validation-failed is a client sending bad queries
discovery.kafka.poison_messagesInt64 counter{message}consumer = offer-availability, product-content or pricing; disposition = skipped or dead-lettered; reason = invalid-envelope, unknown-type or unappliable-payloadcmd/api only (the three Kafka consumers; cmd/a2a, cmd/mcp and cmd/rebuild run no consumer)Adds 1 for each message a consumer can never apply, so the paths that used to leave only a log line (or nothing) are countable. skipped + invalid-envelope: the value is not a CloudEvents 1.0 message, committed past (WARN skipping a message that is not a valid CloudEvent). skipped + unknown-type: a type this consumer has no handler for, committed past with no log line. dead-lettered + unappliable-payload: a handled type whose data cannot be decoded or folded, sent at once to <topic>.dlq without retry (WARN dead-lettering an event that can never be applied). skipped + unappliable-payload is the same payload case when dead-lettering is off, which the production constructor never does. A message that failed transiently and was dead-lettered after its 5 attempts is not counted here. Anything on skipped means the message is gone from the projection for good
http.server.request.durationFloat64 histogramshttp.method, http.scheme, http.route (the chi pattern, for example /products/{catalogItemId})cmd/api only (otelchi metric middleware)Request duration; bucket bounds 5 ms to 10 s (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)
Go runtime metricsvariousvariousnone of its owncmd/api, cmd/a2a, cmd/mcp, cmd/rebuildThe OpenTelemetry contrib runtime instrumentation (goroutines, heap, GC). The dashboard reads them as go_goroutine_count and go_memory_used_bytes (with a fallback to the older runtime_go_* names)

The search counter is defined in internal/adapters/outbound/telemetry/search_metrics.go under the meter name github.com/IQVO/product-discovery; its Prometheus name on the fleet dashboard is discovery_searches_served_total. The poison counter is defined in internal/adapters/inbound/kafka/poison.go under the same meter name; it binds to the real meter provider because the composition root builds the consumers after telemetry setup, and it is a no-op until then. The dashboard has no panel for it. The use case calls exactly one of SearchServed, SearchEmpty, SearchFailed per search (internal/application/usecases/queries_metrics.go). The other Tier-2 instruments of the fleet convention do not exist here because the service has no outbox, no relay and no write API: there is no lag or backlog gauge to export. There is no /metrics endpoint and no Prometheus scrape; everything leaves over OTLP.

cmd/a2a has no HTTP request histogram: its router is a plain net/http mux (cmd/a2a/router.go) with no otelchi and no access log.

Traces​

SpanCreated byKindAttributes
<chi route pattern> (for example GET /products)otelchi in the REST router (internal/adapters/inbound/http/server.go)serverthe otelchi HTTP semantic attributes; the span is named after the route pattern, so there is one name per route and not one per catalogue item
<topic> process (for example retailnetwork.pricing.events process)the Kafka consumer, once per handling attempt (internal/adapters/inbound/kafka/tracing.go)consumermessaging.system=kafka, messaging.destination.name=<topic>, messaging.operation.name=process. Parented to the trace in the message's traceparent header when the producer sent one, otherwise a new trace. A returned error is recorded on the span and sets its status to error
a2a.skill <skill>the A2A adapter (internal/adapters/inbound/a2a/skills.go)internala2a.skill = search_products or get_product; the status is set to error when the skill answers a problem. An unknown skill name gets no span (client-chosen text must not become a span name)

There are no database spans (the Postgres adapter is not instrumented) and no spans for the rebuild's HTTP reads.

Logs​

JSON via log/slog on stdout, one object per line with time, level and msg. LOG_LEVEL picks the level (debug, info, warn/warning, error; default info). The handler is wrapped so that every record written with a span-carrying context also gets trace_id and span_id (only the *Context slog variants carry a context; plain slog.Info lines at boot and shutdown have none). Probe requests (/healthz, /readyz) are not access-logged.

WhereLevelmsgFields
Access log (cmd/api)INFO / WARN (4xx) / ERROR (5xx)http requestmethod, route (the pattern, never the raw path, which holds ids), status, duration_ms, bytes, request_id, trace_id, span_id
RESTERRORrequest failed (an unmapped error, answered as 500 internal-error with a fixed detail)error, method, path (CR and LF are stripped from error and path before logging, logsafe.go)
A2AERRORa2a skill failederror
BootINFOtelemetry configuredservice_name, otlp_endpoint
BootINFOpostgres adapters configured (api) / postgres read side configured (agent)none
BootINFOconsumer running (one per consumer)consumer (offer-availability, product-content, pricing), topic, group_id, brokers
BootINFOhttp server listening (api) / a2a agent listening (agent)addr
Boot retryWARN / INFOretrying / succeeded after retryop (run migrations, ping postgres), attempt, in, err
Boot failureERRORservice exited with error (the process exits 1)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 deadlinedrain_delay / value, default / worker
ReadinessWARNreadiness: dependency is not ready (at most once per 3 s round)dependency (postgres or kafka), error
ConsumerWARNskipping a message that is not a valid CloudEventconsumer, topic, error
ConsumerWARNdead-lettering an event that can never be appliedconsumer, type, event_id, error
ConsumerWARNlisting state fact skipped: listing unknown (a ListingSuppressed or ListingRestored for a listing the service never saw, ADR 0002 A1)listingId, eventId
ConsumerWARN<consumer> broker connection stalled or lost; fetching again after the backofferror, attempt, backoff
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 messageerror, partition, offset, attempts
ConsumerERROR<consumer> message can never be applied; dead-lettering it without retryerror, partition, offset
ConsumerERROR<consumer> offset commit failed; retrying the same message, <consumer> dead-letter publish failed; retrying the same messageerror, partition, offset, attempt, retry_in
ConsumerERRORconsumer stopped (a consumer returned on its own; the process then exits non-zero)consumer, error
RebuildINFO / ERRORrebuild finished / rebuild faileditems, listings, prices, contents, categories / error
RebuildWARNrebuild skipped a row that cannot be foldedkey, error
RebuildWARNtelemetry disabled (setup failed; the run goes on)error

<consumer> is the consumer name: offer-availability, product-content or pricing.

REST errors are application/problem+json documents with type /problems/<slug>; the slug and status table is in Troubleshooting. The detail of an unmapped error is the fixed text an unexpected error occurred: the real error is only in the request failed line.

Probes​

GET /healthz (liveness, always 200 while the process runs) and GET /readyz (200 only while Postgres answers and a Kafka broker answers a topic-less metadata request) are described in the Runbook. The cause of a failed dependency is only in the WARN line above; the response body names the dependency.

Dashboard and alerts that exist​

Only what warehouse-infra has on develop is listed.

ArtifactFile in warehouse-infraWhat it shows
Grafana dashboard warehouse-product-discovery ("Warehouse - Product Discovery")terraform/dashboards/contexts/product-discovery.jsonKong request rate, 5xx ratio and p95 latency (request vs upstream) of the context's routes; service HTTP RED from http_server_request_duration_seconds filtered on service_name=~"product-discovery.*" (rate and p95 by route/process); the business panel discovery_searches_served_total by outcome; Go goroutines and memory; Loki panels on {app="product-discovery"} (live stream, volume by level, errors and warnings only)
Alert WarehouseKong5xxRatioHigh (warning)terraform/alerting/warehouse-alert-rules.json, group warehouse-product-discoverymore than 5 % of a Kong route's requests answer 5xx over 5 minutes, for 5 minutes
Alert WarehousePodRestarting (warning)same groupa product-discovery-* container restarted twice or more in 15 minutes (boot-retry exhaustion, a failed migration, a consumer that stopped on purpose, an OOM kill)
Alerts WarehouseApiAvailabilityBurnFast / WarehouseApiLatencyBurnFast (critical) and ...BurnSlow (warning)group warehouse-product-discovery-slomulti-window burn rate of the 99 % availability and 95 %-under-500 ms latency SLOs on the Kong routes

The alerts are Kong-edge and pod-restart alerts only. No alert reads discovery.searches.served, discovery.kafka.poison_messages, consumer lag or the dead-letter topics: those are not covered by shipped rules.

Suggested checks that are not shipped​

These are built from data that exists; they are suggestions, not rules in the repository.

SignalHow to read itSuggested alert
Projection feed stalledconsumer-group lag of the three groups in Kafka tooling; repeated handling failed; retrying the same message for one offsetlag growing for several minutes
Poison messagesdiscovery.kafka.poison_messages, in particular any increase with disposition="skipped" (the Prometheus name is not confirmed here: no dashboard or rule in warehouse-infra reads it)any increase
Dead lettersdepth of retailnetwork.offer-availability.events.dlq, retailnetwork.product-content.events.dlq, retailnetwork.pricing.events.dlq; WARN dead-lettering an event ..., ERROR ... dead-lettering the messageany message
Empty searchessum(rate(discovery_searches_served_total{outcome="empty"}[15m])) / sum(rate(discovery_searches_served_total[15m]))a sustained jump
Failing searchesdiscovery_searches_served_total{outcome="failed",reason="internal-error"}any sustained rate
Not readyGET /readyz 503 dependency-unavailable; WARN readiness: dependency is not readynot ready for more than a minute
Table growthrow count of processed_events (one row per applied CloudEvent id, never pruned)capacity planning, see the Runbook