Skip to content

Commit

Permalink
fix: exclude proxy data from network consumption metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
abc3 committed Dec 16, 2024
1 parent f90e674 commit b1aaec2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/supavisor/client_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 12 additions & 2 deletions lib/supavisor/db_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand All @@ -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}}
Expand Down

0 comments on commit b1aaec2

Please sign in to comment.