Skip to content

fix: emit realtime_replication_poller_changes_dispatch when the poller broadcasts rows - #2422

Open
hsusul wants to merge 2 commits into
supabase:mainfrom
hsusul:fix/poller-dispatch-metric
Open

hsusul wants to merge 2 commits into
supabase:mainfrom
hsusul:fix/poller-dispatch-metric

Conversation

@hsusul

@hsusul hsusul commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • the replication poller emits [:realtime, :replication, :poller, :changes, :dispatch] with the number of rows it broadcast, so realtime_replication_poller_changes_dispatch shows up on /tenant-metrics
  • adds a poller test that asserts the event fires with count: 2 when a poll returns two rows

Why

realtime_replication_poller_changes_dispatch is documented in OBSERVABILITY_METRICS.md ("Number of Postgres Changes rows the poller broadcast to subscribers") and defined in the Tenant PromEx plugin, but nothing in lib/ emitted its telemetry event. Peep only exports series that have been written, so the metric never appeared for any tenant. #1928 added it together with realtime_replication_poller_changes_skip, and emitted only the :skip event in the rate-limited branch of handle_list_changes_result/4. The poller test module already attaches a handler for :dispatch, but no test asserted on it.

This emits the event right after the broadcast loop, counting rows the same way the :skip event does.

Validation

  • the new test failed on origin/main (ce84f7d7): the poller polled and broadcast both rows, but no :dispatch event arrived
  • with the fix, the new test passes, and test/extensions/postgres_cdc_rls/replication_poller_test.exs with synchronous_commit_delivery_test.exs: 52 passed, 2 excluded
  • test/realtime/monitoring/prom_ex/plugins/tenant_test.exs passes. Its existing test already maps the event to realtime_replication_poller_changes_dispatch
  • mix format --check-formatted, MIX_ENV=test mix credo --strict on the changed files, git diff --check
  • mix compile --force --warnings-as-errors, MIX_ENV=test mix compile --warnings-as-errors and mix format --check-formatted with the CI-pinned Elixir 1.19.5 / OTP 28 (elixir:1.19.5-otp-28 container)

I didn't run the full suite or dialyzer locally, and I didn't scrape a live /tenant-metrics endpoint.

…r broadcasts rows

The metric is defined in the Tenant PromEx plugin and documented in
OBSERVABILITY_METRICS.md, but the poller never fired its telemetry event,
so the series never appeared on /tenant-metrics.
@edgurgel

Copy link
Copy Markdown
Member

@leandrocp can you remember what happened here? I think you were the last one that touched the PG changes metrics. I'm not sure if we should remove the docs about this metric or add the telemetry event.

@edgurgel
edgurgel requested a review from leandrocp October 27, 2026 20:51

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants