Skip to content

feat(observability): expose supervisor app-listener and service-discovery metrics via Prometheus and OTLP #6211

Backlog

Description

@TaylorMutch

User Story

I need to monitor services exposed through OpenShell supervisor app listeners: how many services are currently registered, when services are added or removed, and whether service-discovery advertisements and lease renewals are succeeding. I want to scrape supervisor metrics with Prometheus and use the same metric conventions and optional OTLP export patterns as the gateway.

Problem Statement

The gateway has a separate Prometheus /metrics listener and optional OTLP metric export. Supervisors need equivalent visibility for app-listener service registration and discovery lifecycle state. Gateway relay and gRPC metrics do not reveal the supervisor's installed service inventory, registration churn, or advertisement continuity.

PR #5720 adds supervisor decision and latency metrics through OTLP, but does not provide a supervisor Prometheus scrape endpoint. This proposal complements that work with service-discovery instrumentation and direct scraping.

Impact / Why This Matters

Without these signals, operators must inspect logs and query discovery snapshots to distinguish a registration failure, an expired advertisement, and a discovery-consumer problem. A service can remain installed locally while its accepted advertisement expires, so a registered-service count alone does not establish discoverability. Aggregate metrics should support dashboards and alerts for unexpected inventory drops, registration churn, failed renewals, and stalled discovery reporting.

Proposed Design

Expose an opt-in supervisor GET /metrics endpoint on a separately configurable listener. Follow the gateway's patterns for configuration, Prometheus naming and types, bounded labels, histogram buckets, initialization, deployment integration, and optional OTLP export. Coordinate with #5720 so both export paths expose consistent measurements without double-counting or introducing competing metric conventions.

Start with the following proposed metric catalog. Names and exact label vocabularies are subject to review; names below include the openshell_supervisor_ prefix.

Metric suffix Type Observable behavior
app_listener_services_registered Gauge Services currently installed in the app listener's routing table.
app_listener_service_additions_total Counter Newly installed services.
app_listener_service_removals_total{reason} Counter Removed services, with bounded reasons such as explicit withdrawal, sandbox teardown, or assignment removal.
app_listener_service_updates_total Counter Effective target or configuration changes to an existing service.
app_listener_service_registration_failures_total{reason} Counter Failed service installation attempts, categorized by bounded reason.
app_listener_services_advertised Gauge Locally installed services covered by an unexpired, gateway-accepted advertisement, where the supervisor can determine this state.
service_discovery_reports_total{operation,outcome,reason} Counter Initial advertisement and renewal report outcomes; distinguish preparation timeout, rejection, and acceptance timeout.
service_discovery_report_duration_seconds{operation,outcome} Histogram Advertisement/renewal processing time through acceptance or failure.
service_discovery_last_accepted_timestamp_seconds Gauge Most recent successful report acceptance; document scope and the no-success-yet state.

Counting semantics:

  • Count logical services, not hostname aliases. Define the service identity and apply it consistently across dedicated and shared supervisors.
  • Renewals and identical configuration replays do not count as additions. Effective changes to an existing service count as updates.
  • Actual withdrawals and teardown remove services and increment removal counters exactly once. Rejected installation attempts do not increase the registered gauge.
  • An advertisement expiring must not imply that a locally installed service was removed. Document registered versus advertised state and do not infer acceptance from an attempted send.
  • Counters reset on process restart; gauges reflect current state after reconstruction. Replays and reconnects must not inflate registration churn.
  • Aggregate metrics per supervisor process. Do not label series with service names, hostnames, route IDs, sandbox IDs, or workspace names. Scrape targets identify supervisor instances; logs provide individual identities.
  • A recent successful report does not prove that every service is advertised. Document this limitation and ensure partial failures remain observable.

Related supervisor signals worth coordinating with the existing metrics work include control-stream connectivity/reconnects, active app-listener connections, and connection-limit rejections. Reuse metrics already supplied by related work where applicable.

Suggested UX

Notional configuration for review, not an existing supported field:

[openshell.supervisor]
metrics_bind_address = "0.0.0.0:9091"

Operators enable the listener and scrape each supervisor's /metrics. Provide Helm port/configuration support and a PodMonitor or scrape-configuration example for shared and dedicated supervisor deployments. Document endpoint access restrictions using the gateway's existing metrics guidance. Prometheus scraping and optional OTLP export should be independently configurable.

Acceptance Criteria

  • Supervisors provide an opt-in Prometheus /metrics endpoint on a configurable listener, following gateway conventions.
  • Operators can observe current registered-service count and additions, removals, updates, and registration failures with documented counting rules.
  • Operators can distinguish locally registered services from services with current accepted discovery advertisements.
  • Advertisement and renewal outcomes, latency, and last successful acceptance are observable, including timeouts and rejections.
  • Renewals, aliases, idempotent replays, reconnects, target changes, withdrawals, assignment removal, and restart reconstruction produce the documented gauge/counter behavior.
  • Dedicated and shared supervisors use consistent semantics and bounded labels without per-service or per-sandbox series.
  • Prometheus and optional OTLP export use consistent measurements and can be enabled independently, coordinated with feat(observability): supervisor decision and latency metrics #5720.
  • Helm integration, scrape examples, metric catalog, configuration, and example alerts are documented; relevant contributor/operator skills are reviewed.
  • Focused verification covers registration lifecycle and export behavior; relevant deployment e2e validation demonstrates successful supervisor scraping.

Alternatives Considered

  • Gateway metrics only: useful for discovery RPC and relay setup outcomes, but do not describe the supervisor's local app-listener inventory or service registration lifecycle.
  • OTLP only (feat(observability): supervisor decision and latency metrics #5720): a useful export option, but direct Prometheus scraping is also needed to follow the gateway's existing operating model. A collector translating OTLP to Prometheus remains an alternative deployment choice.
  • Logs and discovery API polling: useful for diagnosing individual routes, but require custom aggregation for fleet-wide churn and continuity alerts.
  • Middleware or gateway interceptors: can observe some requests, but cannot reliably account for supervisor-local installation, teardown, or accepted advertisement expiry.

Related Work and Investigation

Gateway patterns to follow are documented in docs/observability/gateway-metrics.mdx and implemented in crates/openshell-server/src/gateway_metrics.rs, including its OTLP recorder integration. Relevant supervisor and discovery surfaces include the supervisor app listener, shared-host assignment lifecycle, service advertisement handling, and service discovery snapshot/watch processing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions