Skip to content

Wire hub OTel metric recorders to Cloud Monitoring #238

@ptone

Description

@ptone

Problem

Hub-side OTel recorders (dbmetrics, dispatchmetrics) are created with NewDisabled() at cmd/server_foreground.go:1174. The SetDBMetrics() and SetDispatchMetrics() methods on hub.Server exist but are never called from any entrypoint. All hub operational metrics — pg LISTEN/NOTIFY latency, notifications published/delivered/dropped, subscriber lag, dispatch lifecycle, pool stats — silently record to no-op sinks.

Solution

Create a GCP Cloud Monitoring MeterProvider during hub server startup and wire the existing recorders to it. This is Phase 1 of the metrics-delivery project.

Changes

  • New: pkg/observability/hubmetrics/hubmetrics.go — creates a MeterProvider with a GCP metric exporter and periodic reader (60s)
  • Modified: cmd/server_foreground.go — wire SetDBMetrics() and SetDispatchMetrics() after initHubServer(), pass real recorder to newEventPublisher()
  • Metric groups (db-notify, db-pool, dispatch, hub-auth, hub-gcp) can be independently disabled via env vars
  • Graceful degradation when GCPProjectID is empty

Verification

  • Unit tests pass for all observability packages
  • Build succeeds
  • Live infrastructure verification pending (metrics should appear in Cloud Monitoring when deployed with a valid GCP project ID)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions