fix: the worker exports its metrics, and SERVICE_NAME names a process in traces, logs and metrics

Merged
HA
17d ago
+22-32

Closes #289. Fixes the service name half of #294.

The worker never called setup_metrics, so everything it records (pods, queue, sagas, DLQ, results) went to the no-op meter, and the kubernetes-pods, coordinator and DLQ panels stayed empty. app/worker.py now calls it next to setup_log_exporter, before the container builds any metrics class.

The worker needed its own name first, or its series would have mixed with the API's. Traces used TRACING_SERVICE_NAME while logs, metrics and the Kafka client id used SERVICE_NAME, and only the first had a worker override. Now there's one setting: the tracer reads SERVICE_NAME and SERVICE_VERSION, the two TRACING_SERVICE_* keys are gone, and config.worker.toml sets SERVICE_NAME = "integr8scode-worker". Jaeger names are unchanged, Loki gets service_name="integr8scode-worker" for the worker's streams, and metric series carry the same label. The collector's resource processor no longer upserts service.name from a service_name attribute that never exists. The Loki trace link regex from #294 is still open.

Tested on a local k3s in a container with the repo's collector config and VictoriaMetrics. After a backend e2e run (491 passed, 1 skipped), pod_creations_total, pod_monitor_events_total, script_executions_total, queue_enqueue_total and dlq_queue_size all have series with service_name="integr8scode-worker" and job="integr8scode/integr8scode-worker". The SDK gives every process its own service_instance_id, so the API's gunicorn processes don't collide either. The worker sat at 152 MiB of 256 with export on. Ruff, mypy, the orphan check, unit tests, the Grafana contract and the strict docs build pass.

No dashboard filters on service_name or job, so the worker's series show up in the existing panels as they are.


Summary by cubic

The worker now exports its pod, queue, saga, DLQ, and result metrics to the collector. SERVICE_NAME consistently identifies each process across traces, logs, and metrics, keeping worker telemetry separate from the API’s.

  • Remove TRACING_SERVICE_NAME and TRACING_SERVICE_VERSION; tracing now uses SERVICE_NAME and SERVICE_VERSION.
  • The collector no longer tries to set service.name from a nonexistent service_name attribute.