@@ -86,7 +86,7 @@ defmodule Realtime.Extensions.CdcRlsTest do
8686 { :ok , response } = PostgresCdcRls . handle_connect ( args )
8787
8888 # Now subscribe to the Postgres Changes
89- { :ok , _ } = PostgresCdcRls . handle_after_connect ( response , postgres_extension , pg_change_params )
89+ { :ok , _ } = PostgresCdcRls . handle_after_connect ( response , postgres_extension , pg_change_params , external_id )
9090
9191 RealtimeWeb.Endpoint . unsubscribe ( Realtime.Syn.PostgresCdc . syn_topic ( tenant . external_id ) )
9292 % { tenant: tenant }
@@ -242,9 +242,9 @@ defmodule Realtime.Extensions.CdcRlsTest do
242242
243243 on_exit ( fn -> :telemetry . detach ( __MODULE__ ) end )
244244
245- :telemetry . attach (
245+ :telemetry . attach_many (
246246 __MODULE__ ,
247- [ :realtime , :tenants , :payload , :size ] ,
247+ [ [ :realtime , :tenants , :payload , :size ] , [ :realtime , :rpc ] ] ,
248248 & __MODULE__ . handle_telemetry / 4 ,
249249 pid: self ( )
250250 )
@@ -291,8 +291,19 @@ defmodule Realtime.Extensions.CdcRlsTest do
291291 Process . sleep ( 3000 )
292292 { :ok , response } = PostgresCdcRls . handle_connect ( args )
293293
294+ assert_receive {
295+ :telemetry ,
296+ [ :realtime , :rpc ] ,
297+ % { latency: _ } ,
298+ % {
299+ tenant: "dev_tenant" ,
300+ mechanism: :gen_rpc ,
301+ success: true
302+ }
303+ }
304+
294305 # Now subscribe to the Postgres Changes
295- { :ok , _ } = PostgresCdcRls . handle_after_connect ( response , postgres_extension , pg_change_params )
306+ { :ok , _ } = PostgresCdcRls . handle_after_connect ( response , postgres_extension , pg_change_params , external_id )
296307 assert % Postgrex.Result { rows: [ [ 1 ] ] } = Postgrex . query! ( conn , "select count(*) from realtime.subscription" , [ ] )
297308
298309 # Insert a record
@@ -382,7 +393,7 @@ defmodule Realtime.Extensions.CdcRlsTest do
382393 { :ok , response } = PostgresCdcRls . handle_connect ( args )
383394
384395 # Now subscribe to the Postgres Changes
385- { :ok , _ } = PostgresCdcRls . handle_after_connect ( response , postgres_extension , pg_change_params )
396+ { :ok , _ } = PostgresCdcRls . handle_after_connect ( response , postgres_extension , pg_change_params , external_id )
386397 assert % Postgrex.Result { rows: [ [ 1 ] ] } = Postgrex . query! ( conn , "select count(*) from realtime.subscription" , [ ] )
387398
388399 log =
@@ -468,7 +479,7 @@ defmodule Realtime.Extensions.CdcRlsTest do
468479 :ok = PostgresCdc . subscribe ( PostgresCdcRls , pg_change_params , external_id , metadata )
469480
470481 # Now subscribe to the Postgres Changes
471- { :ok , _ } = PostgresCdcRls . handle_after_connect ( response , postgres_extension , pg_change_params )
482+ { :ok , _ } = PostgresCdcRls . handle_after_connect ( response , postgres_extension , pg_change_params , external_id )
472483 assert % Postgrex.Result { rows: [ [ 1 ] ] } = Postgrex . query! ( conn , "select count(*) from realtime.subscription" , [ ] )
473484
474485 # Insert a record
@@ -507,6 +518,19 @@ defmodule Realtime.Extensions.CdcRlsTest do
507518 assert { :ok , % RateCounter { id: { :channel , :db_events , "dev_tenant" } , bucket: bucket } } = RateCounter . get ( rate )
508519 assert 1 in bucket
509520
521+ assert_receive {
522+ :telemetry ,
523+ [ :realtime , :rpc ] ,
524+ % { latency: _ } ,
525+ % {
526+ tenant: "dev_tenant" ,
527+ mechanism: :gen_rpc ,
528+ origin_node: _ ,
529+ success: true ,
530+ target_node: ^ node
531+ }
532+ }
533+
510534 :erpc . call ( node , PostgresCdcRls , :handle_stop , [ tenant . external_id , 10_000 ] )
511535 end
512536 end
0 commit comments