ADR-0019: OTLP trace and metric export for the API process
Status: Accepted (2026-10-08)
Context
network-fulfillment had no OpenTelemetry SDK. Its only metric,
circuit_breaker_state{dependency} (ADR 0004), lives on a private Prometheus
registry served at GET /metrics, and nothing in the cluster scrapes it. The
Helm chart already passed OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_SERVICE_NAME,
SERVICE_VERSION and ENVIRONMENT (and says "traces and metrics are PUSHED
over OTLP/gRPC"), but no code read them, so the chart described a behaviour the
binary did not have.
The consequence was visible once the per-context Grafana dashboard was added
(warehouse-infra scripts/gen-context-dashboards.py): Prometheus held no
service_name series for this context, so every HTTP rate / error / latency
and Go-runtime panel was empty.
Every other HTTP context in the fleet exports OTLP through the OTel Collector
with the same small adapter (internal/adapters/outbound/telemetry, first
written in warehouse-planning, copied into product-master).
Decision
- Add
internal/adapters/outbound/telemetry/telemetry.go(fleet convention) next to the existing circuit-breaker registry.Setupinstalls aTracerProviderand aMeterProviderexporting over OTLP/gRPC, the W3C trace-context propagator and Go runtime metrics. It never blocks on the Collector: with none reachable the service starts and serves as before and telemetry is dropped. cmd/netfulfilcallsSetupbefore anything is wired, withservice.nametaken fromOTEL_SERVICE_NAME(the chart sets it tonetwork-fulfillment) and falling back toinboundhttp.DefaultServiceName. Setup failure refuses to boot, like a bad database URL. It must run beforeRoutes()is built.Routes()wraps theServeMuxinotelhttp, inside the CORS middleware. This recordshttp.server.request.durationlabelled with the ServeMux pattern ashttp.route; a test pins that, because the dashboards depend on it.- The existing
circuit_breaker_stateregistry andGET /metricsare left as they are. Whether to move that gauge onto the OTel pipeline (and drop the unscraped endpoint) is a separate decision.
Out of scope
The mcp, netfulfil-projector and netfulfil-reports binaries are not
instrumented here. The dashboard's (network-fulfillment|netfulfil).* service
regex already covers them once they call the same Setup.
No business-metric counters are added: there is no agreed metric to export yet, and the dashboard declares none.
Consequences
- The request-rate / error-rate / p95 and Go-runtime panels of the network-fulfillment dashboard fill in for the API process once the new image is deployed.
- Adds the OTel SDK, OTLP gRPC exporters and gRPC to
go.mod.