Skip to content

fix(metrics): size the HTTP series cap for the route table, keep /metrics from workers, index the in-flight count (#398) - #506

Open
mblaauw wants to merge 1 commit into
mainfrom
fix/398-metrics-cap-and-scope
Open

mblaauw wants to merge 1 commit into
mainfrom
fix/398-metrics-cap-and-scope

Conversation

@mblaauw

@mblaauw mblaauw commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Closes #398 (items 1, 3 and 4; item 2 was fixed in #475).

Summary

Part of #398 (items 1, 3 and 4; item 2 was fixed in #475).

  • Series cap: orbit_http_requests_total and the request-duration histogram
    are keyed by route template, so the shared 200-series cap was reachable in
    normal use and new series (a route's first 5xx) were dropped. The two HTTP
    families now cap at 8192, enough for every route template x 8 method labels
    x 5 status classes; routes_fit_the_http_series_cap parses routes.rs, checks
    the bound and records every combination with orbit_metrics_dropped_series_total
    staying 0. Other families keep 200.
  • Helm: worker pods may reach the API port, so with networkPolicy.enabled an
    unauthenticated /metrics there exposed installation-wide gauges such as
    orbit_license_usage to agent code. The chart now refuses that combination
    unless monitoring.port or monitoring.token is set, or
    monitoring.allowWorkersOnApiPort=true accepts it. values-prod.example.yaml
    sets monitoring.port: 9090 (outside worker egress). CI asserts the refusal,
    the dedicated listener and that the worker NetworkPolicy omits the port.
  • Index: the in-flight count used status = ANY($1), which no partial index
    could serve, so it read the whole (org_id, status) index. Migration 0066
    adds executions_in_flight_status_idx and the query names the same literal
    statuses (a unit test keeps the constant, the query and the migration in
    step; an integration test checks the plan). On 1M rows: 803 buffers /
    4.8 ms before, 4 buffers / 0.3 ms after.

Testing

  • cargo fmt --check, clippy -D warnings: clean
  • cargo test --workspace on a fresh database: 764 passed, 0 failed
  • New: routes_fit_the_http_series_cap (all 5,040 route × method × status combinations, no dropped series); migration/query/constant consistency unit test; query-plan integration test
  • helm lint; five render variants, including the new refusal and the prod example (API port 8080 allowed for workers, 9090 not)
  • EXPLAIN ANALYZE, 1M rows: before Index Only Scan on executions_status_idx, 803 buffers, 4.8 ms; after executions_in_flight_status_idx, 4 buffers, 0.3 ms
  • pnpm docs:check: passed

Upgrade note: with networkPolicy.enabled and the default monitoring.port: 0, the chart now refuses to render until monitoring.port, monitoring.token.existingSecret or monitoring.allowWorkersOnApiPort=true is set (see changelog.d/398.changed.md). Migration 0066; #447 uses 0065.

🤖 Generated with Claude Code

…rics from workers, index the in-flight count (#398)

Part of #398 (items 1, 3 and 4; item 2 was fixed in #475).

- Series cap: orbit_http_requests_total and the request-duration histogram
  are keyed by route template, so the shared 200-series cap was reachable in
  normal use and new series (a route's first 5xx) were dropped. The two HTTP
  families now cap at 8192, enough for every route template x 8 method labels
  x 5 status classes; routes_fit_the_http_series_cap parses routes.rs, checks
  the bound and records every combination with orbit_metrics_dropped_series_total
  staying 0. Other families keep 200.
- Helm: worker pods may reach the API port, so with networkPolicy.enabled an
  unauthenticated /metrics there exposed installation-wide gauges such as
  orbit_license_usage to agent code. The chart now refuses that combination
  unless monitoring.port or monitoring.token is set, or
  monitoring.allowWorkersOnApiPort=true accepts it. values-prod.example.yaml
  sets monitoring.port: 9090 (outside worker egress). CI asserts the refusal,
  the dedicated listener and that the worker NetworkPolicy omits the port.
- Index: the in-flight count used status = ANY($1), which no partial index
  could serve, so it read the whole (org_id, status) index. Migration 0066
  adds executions_in_flight_status_idx and the query names the same literal
  statuses (a unit test keeps the constant, the query and the migration in
  step; an integration test checks the plan). On 1M rows: 803 buffers /
  4.8 ms before, 4 buffers / 0.3 ms after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant