Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions lib/extensions/postgres_cdc_rls/replication_poller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,24 @@ defmodule Extensions.PostgresCdcRls.ReplicationPoller do
cancel_timer(retry_ref)

try do
Replications.list_changes(conn, slot_name, publication, max_changes, max_record_bytes)
{time, response} =
:timer.tc(Replications, :list_changes, [
conn,
slot_name,
publication,
max_changes,
max_record_bytes
])

Realtime.Telemetry.execute(
[:realtime, :replication, :poller, :query, :stop],
%{duration: time},
%{tenant: tenant}
)

response
catch
:error, reason ->
{:error, reason} ->
{:error, reason}
end
|> case do
Expand Down
28 changes: 24 additions & 4 deletions lib/realtime/monitoring/prom_ex/plugins/tenant.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ defmodule Realtime.PromEx.Plugins.Tenant do
def event_metrics(_opts) do
# Event metrics definitions
[
channel_events()
channel_events(),
replication_metrics()
]
end

Expand Down Expand Up @@ -71,9 +72,28 @@ defmodule Realtime.PromEx.Plugins.Tenant do
end
end

defp replication_metrics() do
Event.build(
:realtime_tenant_replication_event_metrics,
[
distribution(
[:realtime, :replication, :poller, :query, :duration],
event_name: [:realtime, :replication, :poller, :query, :stop],
measurement: :duration,
description: "Duration of the logical replication slot polling query for Realtime RLS.",
tags: [:tenant],
unit: {:native, :millisecond},
reporter_options: [
buckets: [125, 250, 500, 1_000, 2_000, 4_000, 8_000, 16_000, 32_000, 64_000]
]
)
]
)
end

defp channel_events() do
Event.build(
:realtime_tenant_events,
:realtime_tenant_channel_event_metrics,
[
sum(
[:realtime, :channel, :events],
Expand All @@ -91,14 +111,14 @@ defmodule Realtime.PromEx.Plugins.Tenant do
),
sum(
[:realtime, :channel, :joins],
event_name: [:realtime, :rate_counter, :channel, :events],
event_name: [:realtime, :rate_counter, :channel, :joins],
measurement: :sum,
description: "Sum of Realtime Channel joins.",
tags: [:tenant]
),
last_value(
[:realtime, :channel, :joins, :limit_per_second],
event_name: [:realtime, :rate_counter, :channel, :events],
event_name: [:realtime, :rate_counter, :channel, :joins],
measurement: :limit,
description: "Rate limit of joins per second on a Realtime Channel.",
tags: [:tenant]
Expand Down
3 changes: 1 addition & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ defmodule Realtime.MixProject do
def project do
[
app: :realtime,
# When bumping this version make sure to check
version: "2.7.1",
version: "2.9.0",
elixir: "~> 1.14.0",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand Down
Loading