Skip to main content

Observability

What each process emits, where it goes, and what to watch. Read from internal/adapters/outbound/telemetry/, internal/adapters/inbound/http/, the four main.go files and the OTel modules pinned in go.mod (otelchi v0.12.3, contrib/instrumentation/runtime v0.72.0, otel v1.47.0). Dashboards are in warehouse-infra, see below.

Signals per process​

ProcessTracesMetricsLogs
netfulfilOTLP/gRPC push (ADR 0019, 0020)OTLP/gRPC push every 30 s, plus a Prometheus GET /metricsJSON to stdout, one line per request, level from LOG_LEVEL
mcpOTLP/gRPC push (ADR 0020)OTLP/gRPC push every 30 sJSON to stdout, level from LOG_LEVEL
netfulfil-projectornoneOTLP/gRPC push every 30 s (Go-runtime only, ADR 0020)JSON to stdout, level from LOG_LEVEL
netfulfil-reportsOTLP/gRPC push (ADR 0020)OTLP/gRPC push every 30 sJSON to stdout, one line per request, level from LOG_LEVEL

All four processes now call telemetry.Setup (ADR 0019 scoped this to netfulfil only; ADR 0020 closes that gap for the other three). netfulfil-projector's admin HTTP surface stays unwired to otelchi — it serves nothing besides GET /healthz — so it reports Go-runtime metrics but no HTTP RED metrics; see ADR 0020 for why.

OpenTelemetry export (all four processes)​

telemetry.Setup (internal/adapters/outbound/telemetry/telemetry.go) runs first in main, before the HTTP handler is built:

  • One TracerProvider (batching) and one MeterProvider (periodic reader, 30 s), both exporting OTLP/gRPC, insecure, to OTEL_EXPORTER_OTLP_ENDPOINT (default localhost:4317; chart default otel-collector.observability.svc.cluster.local:4317).
  • The exporters dial lazily. A missing Collector drops telemetry; it never delays or fails boot.
  • Propagators: W3C traceparent plus baggage.
  • Resource: the SDK defaults, then service.name (OTEL_SERVICE_NAME, default network-fulfillment), service.version (SERVICE_VERSION, default dev) and deployment.environment.name (ENVIRONMENT, default local).
  • Shutdown flushes both providers with a 5 s budget.

Traces​

otelchi.Middleware wraps the chi router (Server.Routes in netfulfil; NewReportsRouter in netfulfil-reports; newRouter in mcp), with otelchi.WithChiRoutes so the span/metric route label is the chi pattern up front rather than once per concrete path. Every request becomes one server span named <METHOD> <route pattern>, for example GET /network-orders/{networkRef} or POST /network-orders/{networkRef}/shipment-confirmation. An incoming traceparent header is honoured.

There are no other spans. The order-management and inventory-storage HTTP clients use a plain http.Client, so outbound calls are not traced and no trace context is sent to order-management. The poller, the tickers, the outbox relay and the Kafka publishers open no spans.

Trace context across the outbox (ADR 0022). In outbox mode OutboxPublisher.Publish injects the active span's W3C traceparent (and tracestate / baggage when present) into each outbox_events.headers row, after the CloudEvents content-type; the relay sends the stored headers with the Kafka message, so a consumer that extracts them continues the producer's trace. Today that covers events raised inside a REST request span (NetworkOrderShipmentConfirmed from the shipment-confirmation endpoint). Events raised by the poller and the tickers carry no traceparent, because those passes open no span. Direct mode (no DATABASE_URL) adds no trace header. This service's own consumers open no spans, so they do not extract.

Metric instruments​

From otelchi/metric v0.12.3 (ADR-0013 Tier 1 item 2; server side, one set per request, on netfulfil, netfulfil-reports and mcp):

InstrumentTypeUnitAttributes
http.server.request.durationhistogramshttp.request.method, http.route, http.response.status_code, and other OTel HTTP semantic-convention attributes
http.server.active_requestsup-down counter{request}http.request.method

From contrib/instrumentation/runtime v0.72.0 (runtime.Start; all are asynchronous (observable) instruments, read on each 30 s collection):

InstrumentTypeUnitNotes
go.memory.usedup-down counterByattribute go.memory.type = stack or other
go.memory.limitup-down counterByonly when a GOMEMLIMIT is set
go.memory.allocatedcounterBy
go.memory.allocationscounter{allocation}
go.memory.gc.goalup-down counterBy
go.goroutine.countup-down counter{goroutine}
go.processor.limitup-down counter{thread}
go.config.gogcup-down counter%

No business metric is defined for orders received, acknowledged or rejected: those numbers come from the analytics report and from GET /inbound-status (below). The one business counter is the orphaned-hold sweep's.

Node profile metrics​

internal/adapters/outbound/telemetry/node_profile_metrics.go (ADR 0027 §8, same convention and transport as the sweep metric below: the global MeterProvider, OTLP, not on GET /metrics). Live mode only; a stub deployment emits nothing.

InstrumentTypeUnitAttributes
network_fulfillment.node_profile.declarationscounter{declaration}outcome = declared, confirmed, pending, unchanged, failed, skipped_no_node, skipped_no_schedule or skipped_incomplete
network_fulfillment.node_profile.revisiongauge{revision}site; the revision last declared or settled, only recorded when an attempt concerned one

One data point per site per pass (DeclareNodeProfiles through ports.ProfileMetrics). A healthy steady state is unchanged on every pass; a stuck skipped_* or failed is the signal (see the node profile).

Orphaned-hold sweep metric​

internal/adapters/outbound/telemetry/orphan_hold_metrics.go (ADR 0024 §7, following the fleet's Tier 2 business-counter convention that ADR 0020 adopts), built on the global MeterProvider that telemetry.Setup installs and pushed over OTLP like the instruments above. It is not on GET /metrics, which serves only the breaker gauge.

InstrumentTypeUnitAttributes
network_fulfillment.orphaned_holds.sweptcounter{hold}outcome = cancelled, already_released or failed

One data point per hold per pass, added by SweepOrphanedHolds through ports.OrphanHoldMetrics: cancelled = order-management cancelled the hold or answered 404; already_released = it answered 409 or 422; failed = the cancel or the save failed and the hold stays open for the next pass, so a hold that keeps failing adds one failed per pass. A healthy fleet emits nothing at all, so there is no series until the first hold is swept. Before Setup runs (or in a test) the instrument is OTel's no-op. Behind the Collector the Prometheus name has not been checked here; the usual OTel rules would give network_fulfillment_orphaned_holds_swept_total with an outcome label.

In Prometheus, behind the fleet Collector, these names become http_server_request_duration_seconds_*, go_goroutine_count, go_memory_used_bytes and so on, with service_name as a label.

Prometheus GET /metrics (netfulfil)​

internal/adapters/outbound/telemetry/circuit_breaker_metrics.go registers one gauge on its own registry (no Go or process collectors):

MetricTypeLabelsValues
circuit_breaker_stategaugedependency="order-management"0 closed, 1 half-open, 2 open

The series appears after the breaker's first state change; before that the endpoint returns no sample for it. ADR 0019 records that nothing in the cluster scrapes this endpoint, so read it by hand:

kubectl -n <apps namespace> port-forward deploy/network-fulfillment 8080:8080
curl -s localhost:8080/metrics

Inbound status​

GET /inbound-status (internal/adapters/inbound/http/dto.go, inboundStatusResponse) is the operator's view of the inbound leg. The poller's failure mode is silence, so this is the endpoint to alert on.

FieldMeaning
networkModethe gateway mode actually in force (stub or live)
pollspoll passes started since boot
receiveddemand units the use case handled without error (a rejection counts as handled)
faileddemand units whose ReceiveNetworkDemand returned an error; a failed PollDemand call does not count here, it is only logged
sincethe watermark the next poll uses; absent until one pass has fully succeeded
unansweredorders in NEW
overdueNEW orders past their 24 h acknowledgeBy

The counters live in process memory and reset on restart; each replica has its own.

Logs​

Every process uses log/slog with a JSON handler on stdout, at Info and above by default. All four honour LOG_LEVEL (debug, info, warn/warning, error; anything else is Info). netfulfil now logs one http request line per request (RequestLogger, same shape netfulfil-reports already used), stamped with the chi request id from middleware.RequestID; there is still no OTel trace id in log lines (the slog handler is plain, not trace-correlated).

Messages worth knowing, with their fields (all from the code):

MessageLevelFieldsProcessMeaning
network gateway wiredINFOmode, baseURLnetfulfilmode in force at boot
no PRODUCT_TRANSLATION_FILE set; every network order will be rejected as untranslatableWARNnetfulfilempty ACL dictionary
product translation loaded / stub demand seededINFOfile, products / demandsnetfulfilcurated files loaded
order repository wiredINFObackend (memory or postgres)netfulfil, mcppersistence mode
retrying / succeeded after retryWARN / INFOop, attempt, in, errnetfulfilboot retry
event publisher configuredINFOpublisher, mode (direct/outbox), integration_topic, analytics_topic, brokersnetfulfilKafka wiring
poll demand failedERRORerr, sincenetfulfilthe gateway call failed; retried next tick
receive network demand failedERRORnetworkRef, errnetfulfilone unit failed; the watermark will not advance
poll pass had failures; watermark not advancedWARNfailures, of, sincenetfulfil
acknowledgement deadlines at riskWARNexamined, atRisknetfulfilsweep found overdue NEW orders
overdue orders rejectedWARNexamined, rejectednetfulfil
orphaned holds sweptWARNexamined, cancelled, alreadyReleased, failednetfulfilthe orphaned-hold sweep acted on at least one hold; not logged on a pass that found nothing to do (runbook)
orphaned-hold sweep failedERRORerrnetfulfilthe sweep could not list the open holds; retried next tick
orphaned-hold sweep disabled by ORPHAN_HOLD_SWEEP_ENABLED: a hold nobody decides stays reserved in order-managementWARNnetfulfilonce at boot, when the sweep is switched off
invalid ORPHAN_HOLD_SWEEP_ENABLED, keeping the orphaned-hold sweep on / invalid ORPHAN_HOLD_GRACE, using the defaultWARNvalue, error (and default for the grace)netfulfilat boot, for an unparseable or (grace) negative value
submitted orders reconciledINFOexamined, confirmed, failed, pendingnetfulfil
capability offer recompute completedINFOexamined, throughput_constrainednetfulfil
capability offer: usable inventory lookup failedERRORsku, errnetfulfilinventory-storage call failed for one SKU
outbox relay pass failedERRORerrornetfulfila database failure of a relay pass (begin, claim, mark published); rows stay unpublished and are retried. Send failures are logged by the two lines below instead
outbox relay: send failed, stopping this pass at the failed rowWARNoutbox_id, topic, event_type, attempts, errornetfulfilthe broker rejected a row below the attempt cap; the next pass retries it
outbox relay: row reached the attempt cap and is excluded from future claims; re-arm it with attempts = 0 after fixing the causeERRORoutbox_id, topic, event_type, key, attempts, max_attempts, errornetfulfilonce per row, when it reaches OUTBOX_MAX_ATTEMPTS (ADR 0021); consumers never got that event (runbook)
outbox relay runningINFOtopic, analytics_topic, max_attemptsnetfulfiloutbox mode is on, with the attempt cap in force
stub network acknowledgementINFOnetworkRef, acceptednetfulfilwhat the stub gateway was told
analytics: message is not a valid CloudEvent, sending to dead-letter topicWARNtopic, partition, offset, errorprojector
analytics: exhausted retries, sending to dead-letter topicWARNtopic, dlq_topic, phase, ce_id, ce_type, attempts, errorprojector
analytics consumer stoppedERRORerrorprojectorthe consumer loop exited; the process keeps serving /healthz
http requestINFO, ERROR for 5xxmethod, path, status, duration_ms, bytes, request_idnetfulfil, reportsone line per request

Dashboards​

warehouse-infra provisions one Grafana dashboard for this context, terraform/dashboards/contexts/network-fulfillment.json (uid warehouse-network-fulfillment), generated by scripts/gen-context-dashboards.py. As read on warehouse-infra develop it has:

  • Kong edge panels on kong_http_requests_total, kong_request_latency_ms_bucket and kong_upstream_latency_ms_bucket for the httproute.warehouse-systems.network-fulfillment.* services: rate by code, 5xx ratio, p95 latency.
  • RED panels on http_server_request_duration_seconds_* filtered to service_name=~"(network-fulfillment|netfulfil).*": rate by route, 5xx rate, p95.
  • go_goroutine_count and go_memory_used_bytes.
  • Loki panels on {app="network-fulfillment"}: the log stream, volume by level, and ERROR/WARN lines.

Only netfulfil exports a Prometheus GET /metrics endpoint, so that panel group stays netfulfil-only. The RED panels on http_server_request_duration_seconds_*, filtered to service_name=~"(network-fulfillment|netfulfil).*", now have data from netfulfil, netfulfil-reports and mcp (ADR 0020); the projector contributes only the Go-runtime panels.

Suggested alerts​

None of these exist yet; they follow from the code above.

AlertExpression ideaWhy
Overdue acknowledgements/inbound-status overdue > 0, or WARN acknowledgement deadlines at risk in Lokithe 24 h SLA is being missed
Poller stalledpolls not growing for 3 x POLL_INTERVAL, or since absent 5 min after startthe poller's failure mode is silence
Demand failingfailed growing, or ERROR receive network demand failedorders stay NEW until rejected as overdue
Breaker opencircuit_breaker_state{dependency="order-management"} == 2 (needs a scrape job first)every hold, release and cancel is refused
Everything rejectedreport ordersRejectedUntranslatableSku close to ordersReceivedempty or wrong product dictionary
Analytics staleGET /reports/acknowledgement/freshness lagSeconds high while orders are arrivingprojector stopped; note the lag also grows when no event is published at all
5xx on the APIhttp_server_request_duration_seconds_count{http_response_status_code=~"5.."}
DLQ growthmessage count on warehouse.network-fulfillment.analytics.dlqpoison or failing projection
Outbox row excludedany ERROR outbox relay: row reached the attempt cap ... (log alert), or SELECT count(*) FROM outbox_events WHERE published_at IS NULL AND attempts >= 20 > 0an event consumers never received; re-arm it after fixing the cause (ADR 0021)
Outbox backlogSELECT count(*), min(created_at) FROM outbox_events WHERE published_at IS NULL growing for > 5 minthe relay is stuck on a failing row below the cap, or the broker is down
Orphaned holds failingnetwork_fulfillment.orphaned_holds.swept{outcome="failed"} increasing, or WARN orphaned holds swept with failed > 0 on consecutive passes, or a row of the runbook's open-holds query older than ORPHAN_HOLD_GRACE + SWEEP_INTERVALa hold nobody decided cannot be freed (order-management down, breaker open, an unexpected status); stock stays reserved (runbook)
A hold had leakedany OrphanedHoldCancelled event, or network_fulfillment.orphaned_holds.swept{outcome="cancelled"} increasingthe normal cancel path failed first; worth finding out why
Sweep switched offWARN orphaned-hold sweep disabled by ORPHAN_HOLD_SWEEP_ENABLED at bootnothing frees a hold that RejectOverdueOrders missed
Node profile not declared (live)network_fulfillment.node_profile.declarations{outcome=~"skipped_.*|failed"} on every pass, or ERROR the network failed a node profile declaration, or WARN node profile declaration disabled by NETWORK_PROFILE_INTERVAL=0 at bootthe network keeps an old (or no) handling time and cutoffs, and judges our acknowledgement deadlines by them (runbook)
Inventory not fed (live)ERROR the network failed an inventory feed, refused an inventory feed or refused a listing as not on the node, WARN inventory feed disabled by NETWORK_INVENTORY_INTERVAL=0 at boot, or no inventory fed line while capability_offers change (the feed has no metric: logs and the INVENTORY rows of network_submissions are the signal)the network keeps selling against the stock it was last told (runbook)