ADR 0010: Standard metrics convention across the fleet
Status
Accepted
Date: 2026-09-05
Context
Every service in the fleet installs the same OTel pipeline (service pods
--OTLP/gRPC--> otel-collector --OTLP/gRPC--> Jaeger, with a prometheus
exporter re-publishing metrics for Prometheus/Grafana — see
warehouse-infra/terraform/observability.tf). That pipeline is a real,
enforced contract: the Collector's DNS name and OTLP port are hard-coded in
every repo's Helm values, and Grafana ships one dashboard
(go-runtime.json) built from the Go-runtime metrics
go.opentelemetry.io/contrib/instrumentation/runtime emits — the one thing
every instrumented service already reports identically.
Past that shared plumbing, nothing was standard. An audit across all eight services found:
- Two services (
order-management,labor-performance) had notelemetry.Setupat all — no MeterProvider, no TracerProvider, not even the Go-runtime metrics every other service gets for free.order-managementadditionally had no HTTP RED instrumentation (otelchi). - Of the six services that do call
telemetry.Setup, HTTP request rate/error/duration (RED) instrumentation viaotelchiwas present in five and absent in one (labor-performance). - Every service that emits a business metric invented its own instrument
name, unit, and attribute keys independently:
inventory.reservations(attroutcome),workforce.labor_assignments(attrsoutcome,reason,path.id... — actually the assignment attr key wasworkforce.path.id, not namespaced underpath_idthe waywes-work-planningnames its ownpath_idattribute),fulfillment.tasks.claimed/fulfillment.tasks.completed(attrtask.type),facility.location_slot.registrations. No two services agree on whether the bounded-context prefix is<context>.<noun>or<context>.<aggregate>.<verb>, whether an attribute key uses a dot or an underscore, or whether an outcome is spelled as an attribute on one instrument or as two separate instruments.
A metric no dashboard-builder can predict the shape of in advance is a metric nobody actually queries across services. The Go-runtime dashboard being the fleet's only dashboard, eleven weeks into having Prometheus running, is the visible symptom.
Decision
Every service's metrics fall into two tiers. Tier 1 is mechanical and the same for all eight services. Tier 2 is business-specific per bounded context but follows one shared naming/attribute convention so a human or a dashboard can find any service's metrics without reading that service's source first.
Tier 1 — mandatory baseline, identical across every service
- Runtime metrics.
telemetry.Setupinstalls the MeterProvider and callsruntime.Start(runtime.WithMeterProvider(...))(go.opentelemetry.io/contrib/instrumentation/runtime). Already the fleet's de facto standard; this ADR makes it load-bearing — a service without it is non-compliant, not merely incomplete. - HTTP RED metrics. Every service that serves HTTP wires
otelchi.Middlewarefor tracing ANDotelchimetric.NewServerRequestDurationfor the duration histogram, in that order, ahead of the request logger:This is the ONLY sanctioned way to get request rate/error/duration — no service hand-rolls its own HTTP counter.r.Use(middleware.RequestID)r.Use(otelchi.Middleware(serviceName, otelchi.WithChiRoutes(r)))r.Use(otelchimetric.NewServerRequestDuration(otelchimetric.NewBaseConfig(serviceName)))r.Use(RequestLogger(logger))r.Use(middleware.Recoverer) - Health endpoint.
GET /healthzreturning{"status":"ok"}. Already universal; noted here because Prometheus's own liveness assumptions and the Kong route depend on it existing, so it is now part of the same contract as the metrics above, not a separate one.
Tier 2 — business metrics: naming convention, not a fixed metric set
A service picks whichever business events actually matter to it (this ADR does not mandate what to measure — that stays a domain decision per bounded context), but every business instrument follows this shape:
- Instrument name:
<bounded_context>.<aggregate_or_noun>.<verb_or_state>, all lowercase, dot-separated, no abbreviations (inventory.reservations.created, notinv.rsv.create). Prefer ONE counter with anoutcomeattribute over two separately-named counters for the success/failure split of the same event —inventory.reservationswithoutcome=created|revokedis the fleet's best existing example of this and is the pattern to copy, not to rename away from. - Attribute keys: dot-separated, matching OTel semantic-convention style
(
task.type, nottaskTypeortask_type). An attribute that identifies why something happened is always namedreason; an attribute that identifies what happened to it is always namedoutcome. Don't invent a third word for either concept. - Unit: every counter declares
metric.WithUnit(...)using UCUM curly- brace instrument syntax ({reservation},{task},{assignment}) — this is what already differs least across the fleet and should stay that way. - Description: every instrument's
metric.WithDescription(...)states what business condition the metric is a proxy for (seeinventory-storage'sreservationCounterNamecomment for the standard this ADR expects: not just what the number counts, but what a human should conclude when it moves). - Placement: the instrument lives in the SAME adapter tier as
telemetry.Setup(an outboundtelemetryadapter implementing an application-layer port, e.g.ports.ReservationMetrics), never called directly frominternal/domain. A use case takes the port as a dependency and calls it once per outcome, exactly the shapeinventory-storage'sReservationMetricsalready establishes.
This ADR does NOT require renaming metrics that already fit the shape
(inventory.reservations, fulfillment.tasks.claimed,
facility.location_slot.registrations are compliant as written). It DOES
require:
order-managementandlabor-performanceto gain atelemetry.Setup(Tier 1, item 1) andotelchiHTTP instrumentation (Tier 1, item 2), and at least one Tier-2 business counter each, following the shape above.labor-performance(which already hastelemetry.Setupbut nootelchi) to gain Tier 1, item 2.- Any NEW business metric added anywhere in the fleet from this point on to follow the Tier 2 convention, reviewed the same way the RFC 7807 error shape or the Kafka envelope format are reviewed — a metric name is a public contract with every dashboard and alert built on it, not internal detail a PR reviewer can wave through unchecked.
warehouse-ops-agent is exempt from the Tier-2 business-metrics
requirement by design: it is a read-only decision-support Customer of the
other bounded contexts' analytics/report endpoints (see ADR-0001 and
ADR-0003), holds no database of its own, and owns no domain aggregate that
a business counter could be measured against. Its Tier-1 baseline (this
section) is fully in place — telemetry.Setup, the Go-runtime metrics,
and otelchi/otelchimetric RED instrumentation covering BOTH REST and
/mcp (mounted on the same chi router; see ADR-0010's own cross-reference
in internal/adapters/inbound/http/router.go). Past Tier 1 it does carry
real instruments of its own, ADR-0004's — not a Tier-2 business counter in
this ADR's sense (they measure the LLM arbitration mechanism, not a
domain event), but worth naming here so "stops at Tier 1" is not read as
"has no other instruments":
ops_agent.llm.arbitrations{use.case,mode,source}— OTel instrument name (unit{arbitration}); exported to Prometheus unchanged asops_agent_llm_arbitrations_total{use_case,mode,source}ops_agent.llm.agreement{use.case,mode,agree}— OTel instrument name (unit{agreement}); exported to Prometheus unchanged asops_agent_llm_agreement_total{use_case,mode,agree}circuit_breaker.state{dependency}gauge (ADR-0011, the Anthropic Messages API breaker); exported ascircuit_breaker_state{dependency}
No Tier-2 counter is owed now or later unless its architecture changes.
ADR-0013 Tier-2 naming conformance (2026-10 fix). The two LLM-arbitration
instruments above were renamed from the Prometheus-exported underscore form
(ops_agent_llm_arbitrations_total, ops_agent_llm_agreement_total) to the
dot-separated OTel instrument names shown, and the use_case attribute key
was renamed use.case, per ADR-0013's Tier-2 convention
(wes-work-planning's path_id -> path.id is the fleet's precedent for
this exact transform). This is non-breaking: the OTel Collector's
Prometheus exporter converts . to _ and appends _total to a counter
name that doesn't already end in it, so both instruments still export as
the same Prometheus series/labels as before — verified empirically with
go.opentelemetry.io/otel/exporters/prometheus before merging. The second
instrument is kept singular (agreement, not agreements) specifically
because the plural form would export as a different series name
(ops_agent_llm_agreements_total) and break that guarantee. See
arbitration_metrics.go's package doc comment for the full detail.
Consequences
- A new service added to the fleet has an unambiguous starting checklist:
copy
telemetry.Setupfrom any compliant repo verbatim, wire the threeotelchimiddleware lines, and name its first business counter<context>.<noun>.<verb>with anoutcome/reasonattribute pair where applicable. - Grafana can eventually get a second, genuinely cross-service dashboard (e.g. "fleet throughput") because instrument names are predictable rather than requiring per-service tribal knowledge to query.
- This is additive: no existing instrument is renamed, no existing
dashboard breaks, and both gap-closing services keep failing OPEN on a
missing Collector exactly like every other service (
Setup's exporters are non-blocking; seeinventory-storage'stelemetry.goheader comment on why a service must not fail to start over absent telemetry). - The convention is documentation and review discipline, not a CI gate. Nothing currently enforces instrument-name shape mechanically (unlike the hexagonal dependency rule, which arch-go does enforce) — a future ADR could add a lint if drift recurs, but is not scoped here.