• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / supavisor / e5e7ebfe80dbec4965226225050d4ef5c8216e88-PR-605

21 Feb 2025 02:35PM UTC coverage: 45.973% (-0.03%) from 46.003%
e5e7ebfe80dbec4965226225050d4ef5c8216e88-PR-605

Pull #605

github

hauleth
fix: remaining SSL connections that need to set `verify_none` option
Pull Request #605: fix: remaining SSL connections that need to set `verify_none` option

2 of 9 new or added lines in 3 files covered. (22.22%)

267 existing lines in 26 files now uncovered.

959 of 2086 relevant lines covered (45.97%)

635.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.47
/lib/supavisor/monitoring/telem.ex
1
defmodule Supavisor.Monitoring.Telem do
2
  @moduledoc false
3

4
  require Logger
5

6
  defmacro telemetry_execute(event_name, measurements, metadata) do
7
    if not Application.get_env(:supavisor, :metrics_disabled, false) do
×
8
      quote do
9
        :telemetry.execute(unquote(event_name), unquote(measurements), unquote(metadata))
10
      end
11
    end
12
  end
13

14
  defmacro network_usage_disable(do: block) do
15
    if Application.get_env(:supavisor, :metrics_disabled, false) do
×
16
      quote do
17
        {:ok, %{recv_oct: 0, send_oct: 0}}
18
      end
19
    else
20
      block
×
21
    end
22
  end
23

24
  @spec network_usage(:client | :db, Supavisor.sock(), Supavisor.id(), map()) ::
25
          {:ok | :error, map()}
26
  def network_usage(type, {mod, socket}, id, stats) do
27
    network_usage_disable do
2,710✔
28
      mod = if mod == :ssl, do: :ssl, else: :inet
2,710✔
29

30
      case mod.getstat(socket, [:recv_oct, :send_oct]) do
2,710✔
31
        {:ok, [{:recv_oct, recv_oct}, {:send_oct, send_oct}]} ->
32
          stats = %{
2,710✔
33
            send_oct: send_oct - Map.get(stats, :send_oct, 0),
34
            recv_oct: recv_oct - Map.get(stats, :recv_oct, 0)
35
          }
36

37
          {{ptype, tenant}, user, mode, db_name, search_path} = id
2,710✔
38

39
          :telemetry.execute(
2,710✔
40
            [:supavisor, type, :network, :stat],
41
            stats,
42
            %{
43
              tenant: tenant,
44
              user: user,
45
              mode: mode,
46
              type: ptype,
47
              db_name: db_name,
48
              search_path: search_path
49
            }
50
          )
51

52
          {:ok, %{recv_oct: recv_oct, send_oct: send_oct}}
53

54
        {:error, reason} ->
55
          Logger.error("Failed to get socket stats: #{inspect(reason)}")
×
56
          {:error, stats}
57
      end
58
    end
59
  end
60

61
  @spec pool_checkout_time(integer(), Supavisor.id(), :local | :remote) :: :ok | nil
62
  def pool_checkout_time(time, {{type, tenant}, user, mode, db_name, search_path}, same_box) do
63
    telemetry_execute(
161✔
64
      [:supavisor, :pool, :checkout, :stop, same_box],
65
      %{duration: time},
66
      %{
67
        tenant: tenant,
68
        user: user,
69
        mode: mode,
70
        type: type,
71
        db_name: db_name,
72
        search_path: search_path
73
      }
74
    )
75
  end
76

77
  @spec client_query_time(integer(), Supavisor.id()) :: :ok | nil
78
  def client_query_time(start, {{type, tenant}, user, mode, db_name, search_path}) do
UNCOV
79
    telemetry_execute(
15✔
80
      [:supavisor, :client, :query, :stop],
81
      %{duration: System.monotonic_time() - start},
82
      %{
83
        tenant: tenant,
84
        user: user,
85
        mode: mode,
86
        type: type,
87
        db_name: db_name,
88
        search_path: search_path
89
      }
90
    )
91
  end
92

93
  @spec client_connection_time(integer(), Supavisor.id()) :: :ok | nil
94
  def client_connection_time(start, {{type, tenant}, user, mode, db_name, search_path}) do
95
    telemetry_execute(
171✔
96
      [:supavisor, :client, :connection, :stop],
97
      %{duration: System.monotonic_time() - start},
98
      %{
99
        tenant: tenant,
100
        user: user,
101
        mode: mode,
102
        type: type,
103
        db_name: db_name,
104
        search_path: search_path
105
      }
106
    )
107
  end
108

109
  @spec client_join(:ok | :fail, Supavisor.id() | any()) :: :ok | nil
110
  def client_join(status, {{type, tenant}, user, mode, db_name, search_path}) do
111
    telemetry_execute(
478✔
112
      [:supavisor, :client, :joins, status],
113
      %{},
114
      %{
115
        tenant: tenant,
116
        user: user,
117
        mode: mode,
118
        type: type,
119
        db_name: db_name,
120
        search_path: search_path
121
      }
122
    )
123
  end
124

125
  def client_join(_status, id) do
126
    Logger.warning("client_join is called with a mismatched id: #{inspect(id)}")
3✔
127
  end
128

129
  @spec handler_action(
130
          :client_handler | :db_handler,
131
          :started | :stopped | :db_connection,
132
          Supavisor.id()
133
        ) :: :ok | nil
134
  def handler_action(handler, action, {{type, tenant}, user, mode, db_name, search_path}) do
135
    telemetry_execute(
474✔
136
      [:supavisor, handler, action, :all],
137
      %{},
138
      %{
139
        tenant: tenant,
140
        user: user,
141
        mode: mode,
142
        type: type,
143
        db_name: db_name,
144
        search_path: search_path
145
      }
146
    )
147
  end
148

149
  def handler_action(handler, action, id) do
UNCOV
150
    Logger.warning(
1✔
151
      "handler_action is called with a mismatched #{inspect(handler)} #{inspect(action)} #{inspect(id)}"
152
    )
153
  end
154
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc