From b1aaec2777a5c37b16f44cc3180b0bb376a45081 Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 16 Dec 2024 17:24:22 +0100 Subject: [PATCH 1/3] fix: exclude proxy data from network consumption metrics --- lib/supavisor/client_handler.ex | 5 +++++ lib/supavisor/db_handler.ex | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/supavisor/client_handler.ex b/lib/supavisor/client_handler.ex index fa08d32e..24930c77 100644 --- a/lib/supavisor/client_handler.ex +++ b/lib/supavisor/client_handler.ex @@ -575,6 +575,11 @@ defmodule Supavisor.ClientHandler do {_, stats} = Telem.network_usage(:client, data.sock, data.id, data.stats) + {_, stats} = + if not data.local, + do: Telem.network_usage(:client, data.sock, data.id, data.stats), + else: {nil, data.stats} + Telem.client_query_time(data.query_start, data.id) {:next_state, :idle, diff --git a/lib/supavisor/db_handler.ex b/lib/supavisor/db_handler.ex index 1d7ff475..1db39af5 100644 --- a/lib/supavisor/db_handler.ex +++ b/lib/supavisor/db_handler.ex @@ -72,6 +72,7 @@ defmodule Supavisor.DbHandler do messages: "", server_proof: nil, stats: %{}, + client_stats: %{}, mode: args.mode, replica_type: args.replica_type, reply: nil, @@ -297,7 +298,10 @@ defmodule Supavisor.DbHandler do if String.ends_with?(bin, Server.ready_for_query()) do HandlerHelpers.activate(data.sock) - {_, stats} = Telem.network_usage(:db, data.sock, data.id, data.stats) + {_, stats} = + if not data.proxy, + do: Telem.network_usage(:db, data.sock, data.id, data.stats), + else: {nil, data.stats} # in transaction mode, we need to notify the client when the transaction is finished, # after which it will unlink the direct db connection process from itself. @@ -307,7 +311,13 @@ defmodule Supavisor.DbHandler do %{data | stats: stats, caller: nil, client_sock: nil, active_count: 0} else HandlerHelpers.sock_send(data.client_sock, bin) - %{data | stats: stats, active_count: 0} + + {_, client_stats} = + if not data.proxy, + do: Telem.network_usage(:client, data.client_sock, data.client_stats), + else: {nil, data.client_stats} + + %{data | stats: stats, active_count: 0, client_stats: client_stats} end {:next_state, :idle, data, {:next_event, :internal, :check_anon_buffer}} From f2fe4068e7ad74303a09e5e0dfbe9d1db8dc7f1b Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 16 Dec 2024 17:36:59 +0100 Subject: [PATCH 2/3] fix: include ID in network usage computation --- lib/supavisor/db_handler.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/supavisor/db_handler.ex b/lib/supavisor/db_handler.ex index 1db39af5..10ad872c 100644 --- a/lib/supavisor/db_handler.ex +++ b/lib/supavisor/db_handler.ex @@ -314,7 +314,7 @@ defmodule Supavisor.DbHandler do {_, client_stats} = if not data.proxy, - do: Telem.network_usage(:client, data.client_sock, data.client_stats), + do: Telem.network_usage(:client, data.client_sock, data.id, data.client_stats), else: {nil, data.client_stats} %{data | stats: stats, active_count: 0, client_stats: client_stats} From ae2e197d47da075c5ba5126d45bbda271304c469 Mon Sep 17 00:00:00 2001 From: Stas Date: Tue, 17 Dec 2024 11:21:56 +0100 Subject: [PATCH 3/3] bump version --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 09843e3b..0a692060 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.9 +2.0.10