Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: exclude proxy data from network consumption metrics #520

Merged
merged 3 commits into from
Dec 17, 2024
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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.9
2.0.10
5 changes: 5 additions & 0 deletions lib/supavisor/client_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@

key = {:secrets, tenant_or_alias, user}

case auth_secrets(info, user, key, :timer.hours(24)) do

Check warning on line 280 in lib/supavisor/client_handler.ex

View workflow job for this annotation

GitHub Actions / Code style

Function body is nested too deep (max depth is 2, was 3).
{:ok, auth_secrets} ->
Logger.debug("ClientHandler: Authentication method: #{inspect(auth_secrets)}")

Expand Down Expand Up @@ -336,7 +336,7 @@
Cachex.get(Supavisor.Cache, key) == {:ok, nil} do
case auth_secrets(info, data.user, key, 15_000) do
{:ok, {method2, secrets2}} = value ->
if method != method2 or Map.delete(secrets.(), :client_key) != secrets2.() do

Check warning on line 339 in lib/supavisor/client_handler.ex

View workflow job for this annotation

GitHub Actions / Code style

Function body is nested too deep (max depth is 2, was 4).
Logger.warning("ClientHandler: Update secrets and terminate pool")

Cachex.update(
Expand Down Expand Up @@ -573,8 +573,13 @@

db_pid = handle_db_pid(data.mode, data.pool, data.db_pid)

{_, stats} = Telem.network_usage(:client, data.sock, data.id, data.stats)

Check warning on line 576 in lib/supavisor/client_handler.ex

View workflow job for this annotation

GitHub Actions / Dialyze

variable "stats" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 576 in lib/supavisor/client_handler.ex

View workflow job for this annotation

GitHub Actions / Run integration tests

variable "stats" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 576 in lib/supavisor/client_handler.ex

View workflow job for this annotation

GitHub Actions / Run tests

variable "stats" is unused (if the variable is not meant to be used, prefix it with an underscore)

{_, stats} =
if not data.local,

Check warning on line 579 in lib/supavisor/client_handler.ex

View workflow job for this annotation

GitHub Actions / Code style

Avoid negated conditions in if-else blocks.
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 @@
messages: "",
server_proof: nil,
stats: %{},
client_stats: %{},
mode: args.mode,
replica_type: args.replica_type,
reply: nil,
Expand Down Expand Up @@ -125,7 +126,7 @@
tenant = if data.proxy, do: Supavisor.tenant(data.id)
search_path = Supavisor.search_path(data.id)

case send_startup(sock, auth, tenant, search_path) do

Check warning on line 129 in lib/supavisor/db_handler.ex

View workflow job for this annotation

GitHub Actions / Code style

Function body is nested too deep (max depth is 2, was 3).
:ok ->
:ok = activate(sock)
{:next_state, :authentication, %{data | sock: sock}}
Expand Down Expand Up @@ -297,7 +298,10 @@
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,

Check warning on line 302 in lib/supavisor/db_handler.ex

View workflow job for this annotation

GitHub Actions / Code style

Avoid negated conditions in if-else blocks.
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 @@
%{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,

Check warning on line 316 in lib/supavisor/db_handler.ex

View workflow job for this annotation

GitHub Actions / Code style

Avoid negated conditions in if-else blocks.

Check warning on line 316 in lib/supavisor/db_handler.ex

View workflow job for this annotation

GitHub Actions / Code style

Function body is nested too deep (max depth is 2, was 3).
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}
end

{:next_state, :idle, data, {:next_event, :internal, :check_anon_buffer}}
Expand Down
Loading