Skip to main content

Observability

All four binaries call telemetry.Setup (internal/adapters/outbound/telemetry/telemetry.go). It installs one TracerProvider and one MeterProvider, and both push over OTLP/gRPC (insecure) to OTEL_EXPORTER_OTLP_ENDPOINT (default localhost:4317; chart default otel-collector.observability.svc.cluster.local:4317). Metrics are exported every 30 s (metricExportInterval). No pod exposes a /metrics scrape endpoint. The OTel Collector re-exports to Prometheus, which turns dots into underscores and adds unit suffixes (circuit_breaker.state → circuit_breaker_state). Propagation is W3C traceparent plus baggage.

The resource attributes on everything are service.name (OTEL_SERVICE_NAME: workforce-management, workforce-management-mcp, workforce-projector or workforce-reports), service.version and deployment.environment.name (ENVIRONMENT). A collector that cannot be reached never blocks startup. The data is dropped, and the final flush logs telemetry shutdown did not flush cleanly or opentelemetry shutdown failed.

Metrics​

Service-owned instruments​

InstrumentTypeUnitAttributesEmitted bySource
workforce.labor_assignmentsInt64Counter{assignment}workforce.path.id; outcome = accepted|rejected; reason (rejected only) = uncertified, on_break, shift_ended, max_hours_exceeded, associate_not_found, internal_errorcmd/workforce (REST AssignLabor) and cmd/mcp (assign_labor)internal/adapters/outbound/telemetry/labor_metrics.go, reasons in internal/application/usecases/metrics.go
workforce.outbox.lag_secondsFloat64ObservableGaugesnonecmd/workforce, only with EVENT_PUBLISHER=kafka (the relay owner)internal/adapters/outbound/postgres/outbox_metrics.go
circuit_breaker.stateInt64Gauge{state}dependency = labor-performance|fulfillment-executioncmd/workforce, only for clients in http modeinternal/adapters/outbound/telemetry/circuit_breaker_metrics.go
  • workforce.outbox.lag_seconds is the age of the oldest unpublished outbox_events row (now() - created_at), and 0 when the outbox is drained. Each collection runs one SELECT … WHERE published_at IS NULL ORDER BY id LIMIT 1. A growing value means the relay is behind or stuck on one row. It does not say which.
  • circuit_breaker.state is gobreaker's state: 0 closed, 1 half-open, 2 open. It is recorded on each transition only, so a breaker that never tripped has no series.
  • Before the 2026-10 ADR-0015 conformance pass, the labor counter's attributes were workforce.assignment.outcome/.reason. They are now outcome/reason (ADR 0015).

Library instruments​

InstrumentTypeAttributesEmitted bySource
http.server.request.durationFloat64Histogram, s (buckets 5 ms … 10 s)http.method, http.scheme, http.route (semconv v1.20). No status-code attribute.cmd/workforce (REST router), cmd/mcp (/healthz, /mcp, /), cmd/workforce-reportsotelchi v0.12.3 metric.NewServerRequestDuration, wired in internal/adapters/inbound/http/router.go, reports_handler.go, cmd/mcp/router.go
go.memory.used, go.goroutine.count and the other Go runtime instrumentsvariousnoneall four binariesgo.opentelemetry.io/contrib/instrumentation/runtime v0.71.0 (runtime.Start in telemetry.Setup)
pgxpool.acquires, pgxpool.acquire_duration, pgxpool.acquired_connections, pgxpool.idle_connections, pgxpool.total_connections, pgxpool.max_connections, pgxpool.empty_acquire, pgxpool.empty_acquire_wait_time, pgxpool.canceled_acquires, pgxpool.constructing_connections, pgxpool.new_connections, pgxpool.max_idle_destroys, pgxpool.max_lifetime_destroysobservable counters and gaugesdb.system.name=postgresql, db.client.connection.pool.nameonly cmd/workforce-projector and cmd/workforce-reports (analyticsstore.RecordPoolStats)otelpgx v0.12.0 RecordStats

The OLTP pool (cmd/workforce, cmd/mcp) is traced by otelpgx but does not record pgxpool.* stats. The projector's admin server has no HTTP instrumentation.

Traces​

Span nameKindWhereAttributes
chi route pattern, e.g. /associates/{id}/shift-startsserverotelchi middleware on every REST, reports and MCP requestHTTP semconv
otelpgx query spansclientevery Postgres round-trip (OLTP and analytics pools)sanitized SQL statement
kafka.publish warehouse.workforce.eventsproducerdirect (no-database) integration publishermessaging.system=kafka, messaging.operation.name=publish, messaging.destination.name, messaging.batch.message_count
kafka.publish warehouse.workforce.analyticsproducerdirect analytics publishersame
kafka.publish outboxproduceroutbox relay sink (internal/adapters/outbound/kafka/relay_sink.go)messaging.system, messaging.operation.name, messaging.batch.message_count
kafka.consume warehouse.workforce.analyticsconsumerprojector, per message (analytics_consumer.go)messaging.system, messaging.destination.name, messaging.operation.name=process
mcp.tool <tool name>, e.g. mcp.tool assign_laborinternalevery MCP tool call (internal/adapters/inbound/mcp/tools.go)mcp.tool.name. Error status on failure.

In outbox mode the W3C trace context is captured when the use case raises the event and stored in the row's headers. The relay forwards it untouched, so the projector's kafka.consume span becomes a child of the originating HTTP or MCP request, not of the relay pass. A row written without an active span relays with no traceparent. Gap fix D27 pins both halves end to end (real Postgres and Kafka): TestOutboxTrace_TraceparentCrossesTheOutboxToKafka and TestOutboxTrace_RowWithoutTraceHeadersRelaysUnchanged in internal/adapters/outbound/postgres/outbox_trace_integration_test.go.

Logs​

JSON to stdout through slog.NewJSONHandler, wrapped in telemetry.NewTraceHandler. Every *Context log call made while a span is active gets trace_id and span_id. Standard keys are time, level, msg. LOG_LEVEL sets the level (see Configuration).

Messages worth searching for:

MessageBinaryMeaning
retrying (op, attempt, in, err) / succeeded after retryallBoot retry around the first Postgres or Kafka dial.
service exited with error with invalid configuration: DATABASE_URL is required: … / KAFKA_BROKERS is required: …workforce, mcpMandatory configuration missing; every problem is listed at once. Exit 1 (ADR 0038).
readiness: dependency is not ready (dependency = postgres or kafka, error) at WARNworkforce/readyz answers 503 dependency-unavailable until it recovers.
kafka topics (produces, consumes)workforceThe topics this process uses; it creates none (the broker auto-creates on first write).
fulfillment-execution installed capacity client configured at WARN with mode=permissiveworkforceEvery shift-plan commit will fail.
waiting for the process-path catalogue to replay … / process-path catalogue is readyworkforce, mcpKafka catalogue boot gate.
outbox relay pass failedworkforceA relay pass hit an error. The row is retried next pass.
housekeeping sweep / housekeeping sweep failedworkforceSweeper results (idempotency_keys_deleted, outbox_events_deleted).
readiness flipped to not-ready; draining before closing the listenerworkforceSIGTERM received.
… skipping message that is not a valid CloudEvents 1.0 eventworkforce, mcpCatalogue or labor-performance cache skipped a message.
analytics: exhausted retries, sending to dead-letter topic (topic, dlq_topic, attempts, error)projectorA message went to warehouse.workforce.analytics.dlq.
outbox relay: row reached the attempt cap and is no longer claimed (outbox_id, topic, event_type, key, attempts, max_attempts, error)workforceAn outbox row failed OUTBOX_MAX_ATTEMPTS times and is parked; later rows overtake it. Re-arm after the fix (ADR 0036). Alert on it.
analytics consumer stopped; exiting so the pod restartsprojectorThe consumer loop exited (commit or DLQ write failure, or any return without a shutdown signal). The process shuts its admin server down and exits non-zero, so Kubernetes restarts it (gap fix D13).

Dashboard​

warehouse-infra ships the Grafana dashboard "Warehouse — Workforce Management" (terraform/dashboards/contexts/workforce-management.json). Its rows:

  • Kong north-south: request rate, 5xx rate, p95 latency.
  • Service HTTP RED on http_server_request_duration_seconds.
  • workforce_labor_assignments_total.
  • Go runtime (goroutines, memory).
  • Loki log panels.

Two of its queries do not match what the code emits:

  • The labor panel groups by workforce_assignment_outcome. The attribute has been outcome since the ADR-0015 conformance pass, so the panel shows one unlabelled series.
  • The "Error rate (HTTP 5xx, by process)" panel filters on http_response_status_code / http_status_code. otelchi v0.12.3 records neither, so the panel is always empty. Use the Kong 5xx panel or traces instead.

There are no panels yet for workforce.outbox.lag_seconds, circuit_breaker.state or the analytics pgxpool.* series.

Suggested alerts​

AlertExpression (Prometheus names after the collector)Why
Outbox stuckmax(workforce_outbox_lag_seconds) > 60 for 5 mThe relay is behind or a row is failing. Downstream contexts stop seeing events.
Breaker openmax by (dependency) (circuit_breaker_state) == 2 for 2 mlabor-performance open: proposals lose the measured rate (fail-open). fulfillment-execution open: every shift-plan commit fails.
Assignment rejections climbingsum(rate(workforce_labor_assignments_total{outcome="rejected"}[15m])) / sum(rate(workforce_labor_assignments_total[15m])) > 0.5The floor is being asked to staff paths it cannot.
Analytics DLQ growthbroker-side end offset of warehouse.workforce.analytics.dlq increasingPoison events are being skipped. The report under-counts.
Analytics consumer lagconsumer-group lag of workforce-analytics on warehouse.workforce.analyticsThe projector is slow, or restarting: a stopped consumer loop ends the process (pod restarts count up).
Report stalenesspoll GET /reports/labor/freshness → lagSeconds above your SLOSame symptom, seen from the read side.
Slow APIhistogram_quantile(0.95, sum by (le, http_route) (rate(http_server_request_duration_seconds_bucket{service_name="workforce-management"}[5m]))) > 0.5Latency SLO.