0029. Analytics binaries get telemetry and exit when the consumer loop dies
Status
Accepted. Amends ADR 0007's statement that the analytics publisher and consumer are trace-free "because this service has no observability package for them"; extends the projector shutdown sequence of ADR 0012 without changing its order.
Context
The analytics data product (ADR 0007) ships two extra binaries:
cmd/pathmgmt-projector (the single writer: consumes
warehouse.process-path-management.analytics and projects into the
analytical database) and cmd/pathmgmt-reports (the read-only REST reader).
The 2026-10-12 ecosystem-gaps review found two problems in them.
- A dead projector looks healthy. The consumer loop runs in a
goroutine. When
AnalyticsConsumer.Runreturns on its own (an offset commit fails, a dead-letter write fails, the broker goes away), the goroutine loggedanalytics consumer stoppedand the process carried on:/healthzand/readyzkept answering 200, so Kubernetes never restarted the pod while the report silently stopped moving. The only signal was one log line. - The analytics binaries have no telemetry. ADR 0007 justified this
with "this service has no observability/OTel package for them". That
is no longer true:
internal/adapters/outbound/telemetryis used bycmd/pathmgmtandcmd/mcp, and the chart already injectsOTEL_EXPORTER_OTLP_ENDPOINT,OTEL_SERVICE_NAME,SERVICE_VERSIONandENVIRONMENTinto the projector and reports pods, which the binaries ignored. The reports pod gotENVIRONMENTonly whenotel.enabled=true. Every other projector/reports pair in the fleet sets up telemetry.
Decision
- Projector liveness (gap fix D13). The consumer goroutine reports
Run's result on a channel.run()waits for either a shutdown signal (SIGINT/SIGTERM: a normal stop, no error) or the consumer exit. A consumer exit is always an error (analytics consumer loop exited, wrapping the consumer's own error; anilreturn without cancellation is just as dead). The projector then runs the same shutdown sequence as a SIGTERM (ADR 0012: readiness to not-ready first, drain the admin server, wait for the consumer, close the reader/DLQ writer and the pool last) andrun()returns the error, somainexits 1 and Kubernetes restarts the pod. Committed offsets make the restart resume where the loop stopped. - Telemetry parity (gap fix D21). Both binaries call
telemetry.Setupexactly likecmd/pathmgmt(service namespathmgmt-projectorandpathmgmt-reportsby default, overridable withOTEL_SERVICE_NAME), defer the bounded flush, logtelemetry configuredand log throughtelemetry.NewTraceHandler. Export stays non-blocking: an unreachable Collector only drops telemetry. The consumer and the reports router still open no spans; this record does not add instrumentation, only the providers, the propagator and Go runtime metrics. - Chart. The projector and reports Deployments always set
LOG_LEVEL,ENVIRONMENTandSERVICE_VERSION;OTEL_EXPORTER_OTLP_ENDPOINTandOTEL_SERVICE_NAMEstay behindotel.enabled, as for the api and mcp.
Consequences
Easier
- A broken broker or analytics database now shows up as pod restarts and,
if it persists,
CrashLoopBackOff: the standard Kubernetes alerts catch it without a log-based rule. - The analytics pods appear in the Collector with a service name, version and environment, and report Go runtime metrics like the other binaries.
- Tests:
TestAwaitStop_ConsumerLoopExitIsAnError,TestAwaitStop_ConsumerLoopReturningNilIsStillAnError,TestAwaitStop_SignalIsAGracefulStop,TestShutdown_FlipsReadinessAndReleasesEverythingandTestSetupTelemetry_InstallsTheSDKProviders(projector and reports).
Harder
- A projector whose broker is down for a long time now restart-loops instead of idling. That is the intended signal; the backoff is Kubernetes'.
- Two more processes export to the Collector (runtime metrics every 30 s).
- Spans for the consumer and the reports routes remain a separate, future decision.