Skip to main content

Observability

Pricing follows the fleet observability standard (ADR 0005): JSON logs on stdout correlated with traces, OTLP/gRPC export of traces and metrics to the OpenTelemetry Collector, one business counter and the HTTP RED metrics from otelchi. Export never blocks: the gRPC exporters connect lazily with no blocking dial, so a Collector that is down or absent costs telemetry and nothing else (exporter failures are logged at DEBUG as opentelemetry error).

Source: internal/adapters/outbound/telemetry/ (telemetry.go, quote_metrics.go, slogotel.go), cmd/api/telemetry.go, cmd/a2a/telemetry.go, cmd/mcp/telemetry.go, internal/adapters/inbound/requestlog/requestlog.go.

Exporter configuration​

Variablecmd/api defaultcmd/a2a defaultcmd/mcp defaultMeaning
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317localhost:4317localhost:4317Collector OTLP/gRPC endpoint, host:port or URL; a bare host:port is turned into http://host:port
OTEL_SERVICE_NAMEpricingpricing-a2apricing-mcpservice.name of spans, metrics and the Loki app label source
SERVICE_VERSIONdevdevdevservice.version
ENVIRONMENTlocallocallocaldeployment.environment.name

Traces are batched; metrics are pushed every 15 seconds by a periodic reader. Propagation is W3C tracecontext plus baggage. The chart renders the OTLP variables only when otel.enabled is true (default), with endpoint otel-collector.observability.svc.cluster.local:4317.

Metric instruments​

NameTypeUnitAttributesEmitted by
pricing.quotes.issuedInt64 counter{quote}outcome = issued | rejected; reason (only when rejected) = the problem slug, for example item-not-priced, no-charge-schedule, no-tax-table, empty-quote, internal-errorIssuePriceQuote (internal/application/usecases/quote_metrics.go), once per attempt; only cmd/api
http.server.request.durationhistogram (via otelchimetric)sroute pattern, method (as exported by riandyrn/otelchi/metric)all three binaries, every non-probe HTTP request
go.* / runtime metricsvariousvariousOTel Go runtime instrumentation, started in telemetry.Setup

pricing.quotes.issued is exposed to Prometheus as pricing_quotes_issued_total. The fleet dashboard states what the series mean: a falling issued share together with a rising item-not-priced means shoppers cart items that have no active price (a catalogue or pricing gap); a rising no-charge-schedule or no-tax-table means a schedule or table was never published, so every checkout fails until one is; a rising internal-error means the service itself is failing.

There is no outbox-lag gauge, no consumer-lag metric and no dead-letter counter: those signals are log lines and SQL queries only (see Troubleshooting).

Spans​

SpanKindCreated byNotes
server span per requestserverotelchi.Middleware in all three routersNamed after the chi route pattern (for example /item-prices/{catalogItemId}, via WithChiRoutes), so one name per route and not per item id
<topic> processconsumerConsumer.handleTraced (internal/adapters/inbound/kafka/tracing.go)Parented to the producer's traceparent header when the message carries one, else a new trace. Attributes messaging.system=kafka, messaging.destination.name, messaging.operation.name=process. A returned error is recorded and sets the span status
a2a.skill <skill>internalanswer in internal/adapters/inbound/a2a/skills.goAttribute a2a.skill; status Error when the skill answers a problem

The trace continues across Kafka: when a use case appends events, the outbox repository injects the active span context into each row's headers (traceparent, tracestate, baggage through the global propagator), and the relay publishes them as ordinary Kafka headers. Consumers of retailnetwork.pricing.events therefore see the request that raised the event as their parent.

Log fields​

Logs are JSON from log/slog on stdout; LOG_LEVEL sets the level. A record written with a span-carrying context (the *Context slog variants) also carries trace_id and span_id (telemetry.WithTraceContext).

Access log (requestlog.RequestLogger, cmd/api and cmd/mcp), message http request:

FieldMeaning
methodHTTP method
routematched chi pattern, unmatched when none; never the raw path
statusresponse status (5xx logs at ERROR, 4xx at WARN, otherwise INFO)
duration_mshandling time
bytesresponse bytes
request_idchi RequestID

/healthz and /readyz are not logged. Other fields in use: consumer, topic, group_id, brokers (consumer start), partition, offset, attempt, max_attempts, retry_in (consumer retries), event_id, type (dead-lettered payloads), outbox_id, event_type, key, attempts, max_attempts (relay attempt cap), policy, handled (policy passes), catalog_item_id, quote_id (skipped policy items), op, attempt, in, err (boot retry).

Key messages, in boot order for cmd/api: retrying / succeeded after retry (op = run migrations or ping postgres), postgres adapters configured, telemetry configured, consumer running, outbox relay running (interval, max_attempts, topic), policies running (interval), http server listening. At shutdown: shutdown: readiness flipped to not-ready; waiting for traffic to drain. Warnings and errors worth alerting on:

MessageLevelMeaning
outbox relay pass failedERRORA relay pass failed; rows stay unpublished and retry after the interval
outbox relay: row reached the attempt cap and is excluded from future claims; re-arm it with attempts = 0 after fixing the causeERRORA poison outbox row was parked
outbox relay stopped / consumer stoppedERRORThe worker returned; the process exits non-zero
<consumer> handling failed; retrying the same messageERRORTransient consumer failure, with attempt and retry_in
<consumer> handling failed after the maximum attempts; dead-lettering the messageERRORFive attempts used
<consumer> message can never be applied; dead-lettering it without retryERRORPoison payload
<consumer> broker connection stalled or lost; fetching again after the backoffWARNTransient fetch failure (up to 10 in a row)
skipping a message that is not a valid CloudEventWARNCommitted past
policy pass failedERRORA clock-driven pass failed; retried on the next tick
boundary publication skipped / quote expiry skippedWARNA concurrent writer got in; the next pass sees the item again
invalid OUTBOX_RELAY_INTERVAL; using the default and the sibling POLICY_INTERVAL, OUTBOX_MAX_ATTEMPTS, SHUTDOWN_DRAIN_DELAY messagesWARNA malformed tuning value
telemetry flush failed on shutdownWARNThe final export (bounded to 5 s) failed
a2a skill failedERRORA skill hit an unexpected error; the answer is a generic 500 problem
mcp tool failed with an unexpected errorERRORA tool hit an unexpected error; the answer is the generic internal-error: an unexpected internal error occurred tool error (cmd/mcp)

cmd/mcp also logs mcp server starting (version, environment), postgres read side configured and mcp server listening (Streamable HTTP) (addr) at boot, and mcp server exited with error (exit 1) on a boot failure.

<consumer> is offer-availability.

Dashboards and alerts​

Seen in warehouse-infra (branch develop):

  • Dashboard warehouse-pricing (terraform/dashboards/contexts/pricing.json, generated by scripts/gen-context-dashboards.py): Kong rows for the context's routes, request rate by route and p95 duration for service_name=~"pricing.*", the pricing_quotes_issued_total panel by outcome, Go runtime, and the Loki log panels for app="pricing". The Kong rows stay empty until the chart attaches a Kong prometheus plugin.
  • Alerts (terraform/alerting/warehouse-alert-rules.json, groups warehouse-pricing and warehouse-pricing-slo): WarehouseKong5xxRatioHigh (over 5% 5xx for 5 minutes), WarehousePodRestarting (two restarts in 15 minutes for pods matching pricing-.+) and the four SLO burn-rate alerts WarehouseApiAvailabilityBurnFast, WarehouseApiAvailabilityBurnSlow, WarehouseApiLatencyBurnFast and WarehouseApiLatencyBurnSlow.
  • No WarehouseOutboxLagHigh rule exists for Pricing because the service exports no outbox-lag gauge. The alert annotations link https://github.com/IQVO/pricing/blob/develop/docs/operations/runbook.md, a path that no longer exists now that the runbook lives in this site (see Runbook); the link needs updating in warehouse-infra.