Skip to main content

Observability

All four binaries call the same telemetry.Setup (internal/adapters/outbound/telemetry/telemetry.go): a TracerProvider and a MeterProvider exporting over OTLP/gRPC to OTEL_EXPORTER_OTLP_ENDPOINT (default localhost:4317), a W3C traceparent + baggage propagator, and Go runtime metrics. Metrics are pushed every 15 s.

  • There is no /metrics route. Nothing is scraped from the pods. The OTel Collector receives OTLP and its Prometheus exporter re-publishes each instrument, turning dots into underscores and adding unit and _total suffixes (order.orders.received becomes order_orders_received_total).
  • Export never blocks. The exporters connect lazily. With no collector reachable, telemetry is dropped and the failure is logged at DEBUG only (opentelemetry error).
  • Resource attributes: service.name (OTEL_SERVICE_NAME; defaults order-management, order-management-mcp, order-projector, order-reports), service.version (SERVICE_VERSION), deployment.environment.name (ENVIRONMENT), plus whatever OTEL_RESOURCE_ATTRIBUTES adds (read by the SDK's default resource).

Metrics​

Service instruments​

InstrumentTypeUnitAttributesEmitted byMeaning
order.orders.receivedInt64Counter{order}outcome = accepted or rejectedcmd/order, ReceiveOrder (internal/adapters/outbound/telemetry/metrics.go)One increment per intake. accepted is counted once the order is persisted and OrderReceived raised, before the best-effort allocation. rejected is counted when the use case refuses the intake: a held order that allows partial shipment, a line with no eligible path, an invalid line (for example a non-positive quantity), a resolved path the catalogue does not know, or order.New refusing the lines. Requests the HTTP adapter refuses first (malformed JSON, empty lines, empty SKU) are not counted.
circuit_breaker.stateInt64Gauge{state}dependency = inventory-storagecmd/order with INVENTORY_STORAGE_MODE=http (telemetry/circuit_breaker_metrics.go)0 closed, 1 half-open, 2 open. Recorded on each state change only, so the series does not exist until the breaker first changes state. Prometheus name circuit_breaker_state.
order.outbox.lag_secondsFloat64ObservableGaugesnonecmd/order with DATABASE_URL and EVENT_PUBLISHER=kafka (internal/adapters/outbound/postgres/outbox_metrics.go)Age of the oldest outbox_events row with published_at IS NULL; 0 when the outbox is drained. Sampled by a query on every collection.
order.release_confirmation.eventsInt64Counter{event}outcome = confirmed, late_confirmed, duplicate, ignored_no_reference or ignored_unknown_linecmd/order with RELEASE_CONFIRMATION_MODE=kafka (telemetry/release_confirmation_metrics.go, ADR 0043)One increment per WorkUnitCreated the release-confirmation consumer handled. confirmed: a PENDING line became CONFIRMED. late_confirmed: an UNCONFIRMED line was admitted after all. duplicate: a redelivered id, or a second event for an already CONFIRMED line. ignored_no_reference: no reference or no positive line_no (a transfer, RELOCATE or legacy work unit, or a producer that does not stamp the fields; a steady climb right after enabling means the producer is not stamping them). ignored_unknown_line: not a line this service opened a row for. Prometheus name order_release_confirmation_events_total. Absent while the mode is off.
order.release_confirmation.unconfirmedInt64Counter{line}nonecmd/order with RELEASE_CONFIRMATION_MODE=kafka, from the housekeeping sweep (same file)One increment per released line flagged UNCONFIRMED: wes-work-planning did not confirm the work within RELEASE_CONFIRMATION_TIMEOUT. Any increase is an order line to look at (see the runbook). Prometheus name order_release_confirmation_unconfirmed_total. Counted after the batch commits, once per line.

The service meters are scoped github.com/claudioed/order-management (the intake counter, the breaker gauge and the two release-confirmation counters) and github.com/claudioed/order-management/internal/adapters/outbound/postgres (outbox lag).

HTTP instruments (otelchi v0.12.3)​

InstrumentTypeUnitAttributesBinaries
http.server.request.durationFloat64Histogram, buckets 5 ms to 10 sshttp.method, http.scheme, http.route (the chi pattern, for example /orders/{id})cmd/order, cmd/order-reports, cmd/mcp
http.server.active_requestsInt64UpDownCounter{request}samecmd/order-reports, cmd/mcp only (the OLTP router does not register it)

otelchi records no status-code attribute on these metrics. Error rates have to come from Kong (kong_http_requests_total{code=~"5.."}), from the span status, or from the status field of the request log line. cmd/order-projector serves only /healthz on a plain net/http mux and emits no HTTP metrics.

Go runtime (contrib runtime v0.71.0)​

go.memory.used, go.memory.limit, go.memory.allocated, go.memory.allocations, go.memory.gc.goal, go.goroutine.count, go.processor.limit, go.config.gogc, from every binary.

Traces​

Span nameKindWhereNotable attributes
<route pattern> such as /orders/{id}serverotelchi on the cmd/order, cmd/order-reports and cmd/mcp routershttp.route, HTTP request semconv
kafka.publish warehouse.order-management.eventsproducerPublisher.Publish, the direct path (EVENT_PUBLISHER=kafka without DATABASE_URL)messaging.system=kafka, messaging.destination.name, messaging.operation.name=publish, messaging.message.id, cloudevents.event_type
kafka.publish warehouse.order-management.analyticsproducerAnalyticsPublisher.Publish, direct pathsame
kafka.consume warehouse.fulfillment.eventsconsumerre-promise consumerparent extracted from the message headers; messaging.message.id, cloudevents.event_type, cloudevents.event_source
kafka.consume warehouse.warehouse-planning.eventsconsumerplanned-capacity consumersame shape
kafka.consume warehouse.product-master.eventsconsumerproduct-classification consumersame shape
kafka.consume warehouse.work-planning.eventsconsumerrelease-confirmation consumer (RELEASE_CONFIRMATION_MODE=kafka, ADR 0043)parent extracted from the message headers; messaging.system, messaging.destination.name, messaging.operation.name=process, messaging.message.id, cloudevents.event_type, cloudevents.event_source
kafka.consume warehouse.outbound-shipping.eventsconsumeroutbound-shipping consumer (OUTBOUND_SHIPPING_CONSUMER_MODE=kafka, ADR 0051)parent extracted from the message headers (otel.GetTextMapPropagator().Extract)
kafka.consume warehouse.order-management.analyticsconsumeranalytics consumer in cmd/order-projectorparent extracted from the headers; messaging.system, messaging.destination.name, messaging.operation.name=process
mcp.tool get_order, mcp.tool get_promise_healthinternalcmd/mcp, internal/adapters/inbound/mcp/tools.gomcp.tool.name; status Error with the message when the tool fails

With the transactional outbox there is no publish span. The encoder injects the trace context of the request that wrote the outbox row into the stored headers, and the relay sends those headers unchanged. A consumer's span is therefore parented on the original HTTP request, not on the relay pass. The trace context lives in outbox_events.headers (traceparent, tracestate when present, next to content-type); a row written without an active span relays without a traceparent. This is the fleet's D27 reference (ADR 0041), pinned end to end against real Postgres and Kafka by TestOutboxTrace_TraceparentCrossesTheOutboxToKafka and TestOutboxTrace_RowWithoutTraceHeadersRelaysUnchanged.

Postgres, the inventory-storage HTTP client and the Kafka replay caches (kafkacatalog, kafkacptschedule, kafkapathcapacity) are not instrumented.

Logs​

Every binary writes JSON lines to stdout through log/slog, at LOG_LEVEL. Standard fields are time, level, msg. The log lines do not carry trace_id/span_id: correlate by request_id or by time.

MessageFieldsSource
http requestmethod, route (chi pattern; the sanitised raw path for a 404), status, bytes, duration_ms, request_id (chi RequestID)internal/adapters/inbound/http/logging.go, on the cmd/order and cmd/order-reports routers
domain event publishedevent_name, payloadlog publisher (EVENT_PUBLISHER=log)
outbox relay pass failederroroutbox relay, ERROR
outbox relay: row reached the attempt cap and is no longer claimedoutbox_id, topic, event_type, key, attempts, max_attempts, error, rearmoutbox relay, ERROR, once per row that reaches OUTBOX_MAX_ATTEMPTS (ADR 0040)
housekeeping sweep / housekeeping sweep failedidempotency_keys_deleted, outbox_events_deleted, release_confirmations_pruned, releases_unconfirmed, errorsweeper
release unconfirmedorder_id, line_no, path_id, work_unit_id, released_at, timeouthousekeeping sweep (FlagUnconfirmedReleases), ERROR, once per line flagged UNCONFIRMED (ADR 0043)
release confirmed late: the line flagged unconfirmed was admitted after allorder_id, line_no, work_unit_id, released_at, unconfirmed_atrelease-confirmation consumer, WARN, when a WorkUnitCreated clears an UNCONFIRMED line
release confirmation: kafka unavailable, retryingstage, retry_in, error, partition, offsetrelease-confirmation consumer, WARN
release confirmation: non-CloudEvents message, sending to dead-letter topic / …invalid work unit event, … / …exhausted retries, …topic, partition, offset, dlq_topic, error, ce_id/ce_type when it was a CloudEventrelease-confirmation consumer, WARN
release confirmation consumer configuredtopic, group_id, timeoutcmd/order boot, INFO, only with RELEASE_CONFIRMATION_MODE=kafka
outbound shipping consumer configuredtopic, group_idcmd/order boot, INFO, only with OUTBOUND_SHIPPING_CONSUMER_MODE=kafka
outbound shipping: kafka unavailable, retrying / outbound shipping: …, sending to dead-letter topicstage, retry_in, error, partition, offset / topic, dlq_topic, erroroutbound-shipping consumer, WARN
shipment confirmation names an unknown order, skipping / …names an order with no released lines, skipping / …already processed, skipping / …re-delivered under a new id, order already shipped / …names no orders, skippingthe event id, load id and order idConfirmShipment, WARN, one record per non-shipped outcome
repromise: kafka unavailable, retryingstage, retry_in, error, partition, offsetre-promise consumer
repromise: non-CloudEvents message, sending to dead-letter topictopic, partition, offset, dlq_topic, errorre-promise consumer
repromise: exhausted retries, sending to dead-letter topictopic, dlq_topic, ce_id, ce_type, attempts, errorre-promise consumer
retrying / succeeded after retryop, attempt, in, errinternal/bootretry, at boot
shutdown: readiness flipped to not-ready; waiting for traffic to draindrain_delaycmd/order shutdown
telemetry configuredservice_name, service_version, environment, otlp_endpointcmd/order boot

The startup warnings that say which integrations are off are listed in Troubleshooting.

Dashboard​

warehouse-infra provisions the Grafana dashboard "Warehouse — Order Management" (uid warehouse-order-management) from terraform/dashboards/contexts/order-management.json. Its rows:

  • API Gateway (Kong): request rate by status code, 5xx error ratio, p95 request vs upstream latency for this context's HTTPRoute.
  • Service HTTP RED: http_server_request_duration_seconds rate by service_name and http_route, 5xx rate by process, p95 duration by process, filtered on service_name=~"order-management.*".
  • Business metrics: sum by (outcome) (rate(order_orders_received_total[5m])).
  • Go runtime: go_goroutine_count and go_memory_used_bytes.
  • Logs (Loki): live stream, volume by level, and WARN/ERROR only, for {app="order-management"} without the Istio containers.

Two limits of that dashboard, both from the code above: the projector and reports processes report service.name order-projector and order-reports, which the order-management.* regex does not match; and the per-process 5xx panel filters on http_response_status_code, which otelchi does not emit. Use the Kong row for error rates. No panel shows order_outbox_lag_seconds or circuit_breaker_state yet.

Suggested alerts​

These are suggestions built on the instruments above. None of them is provisioned today.

AlertExpression (Prometheus names)Why
Outbox stuckmax(order_outbox_lag_seconds) > 60 for 5 mA growing lag means Kafka is unreachable or one row cannot be sent. The relay retries the head row up to OUTBOX_MAX_ATTEMPTS (20) times, then parks it (ERROR outbox relay: row reached the attempt cap and is no longer claimed) so later events publish; the parked row keeps the lag growing until an operator re-arms it (ADR 0040).
Inventory breaker openmax(circuit_breaker_state{dependency="inventory-storage"}) == 2 for 2 mEvery allocation fails with downstream-unavailable (503) while open.
Intake rejections climbingsum(rate(order_orders_received_total{outcome="rejected"}[15m])) / sum(rate(order_orders_received_total[15m])) > 0.2A caller or upstream integration is sending orders the domain refuses.
API 5xxsum(rate(kong_http_requests_total{service=~"httproute\\.warehouse-systems\\.order-management\\..*", code=~"5.."}[5m])) > 0 for 10 m503 is how downstream outages and permissive mode surface.
Analytics staleprobe GET /reports/funnel/freshness and alert on lagSeconds > 300The report's SLA is p95 event-to-report lag under 30 s.
DLQ trafficbroker-side end offset of warehouse.fulfillment.events.dlq, warehouse.warehouse-planning.events.dlq or, with the release-confirmation loop on, warehouse.work-planning.events.dlq increasingA dead-lettered message is a re-promise, a capacity window or a work-unit confirmation that was not applied.
Consumer lagbroker-side lag of groups order-management-repromise, order-management-analytics and the planned-capacity, classification and release-confirmation groupsThe service exports no consumer-lag metric of its own.
Release unconfirmedincrease(order_release_confirmation_unconfirmed_total[15m]) > 0A released order line that wes-work-planning never confirmed. A signal, not proof: see the runbook.
Confirmations not matchingsum(rate(order_release_confirmation_events_total{outcome="ignored_no_reference"}[15m])) > 0 right after enabling the loopThe producer does not stamp reference/line_no on WorkUnitCreated, so every line will be flagged. Transfer and legacy work also count here, so judge it by the trend.