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

supabase / supavisor / 6af7f2db69bcd25b3c0152c1ae07f7f165c55681-PR-573

24 Jan 2025 12:13PM UTC coverage: 46.518% (-0.8%) from 47.304%
6af7f2db69bcd25b3c0152c1ae07f7f165c55681-PR-573

Pull #573

github

hauleth
chore: ignore tests support files in coverage reports
Pull Request #573: chore: ignore tests support files in coverage reports

962 of 2068 relevant lines covered (46.52%)

206.71 hits per line

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

77.78
/lib/supavisor/tenants_metrics.ex
1
defmodule Supavisor.TenantsMetrics do
2
  @moduledoc false
3
  use GenServer, restart: :transient
4
  require Logger
5

6
  alias Supavisor.Monitoring.PromEx
7

8
  @check_timeout 10_000
9

10
  def start_link(args) do
11
    GenServer.start_link(__MODULE__, args,
×
12
      name: __MODULE__,
13
      spawn_opt: [
14
        priority: :low
15
      ]
16
    )
17
  end
18

19
  ## Callbacks
20

21
  @impl true
22
  def init(_args) do
23
    send(self(), :check_metrics)
×
24
    {:ok, %{check_ref: make_ref(), pools: MapSet.new()}}
25
  end
26

27
  @impl true
28
  def handle_info(:check_metrics, state) do
29
    Process.cancel_timer(state.check_ref)
5✔
30

31
    active_pools = PromEx.do_cache_tenants_metrics() |> MapSet.new()
5✔
32

33
    MapSet.difference(state.pools, active_pools)
5✔
34
    |> Enum.each(fn {{_type, tenant}, _, _, _, _} = pool ->
5✔
35
      Logger.debug("Removing cached metrics for #{inspect(pool)}")
1✔
36
      Cachex.del(Supavisor.Cache, {:metrics, tenant})
1✔
37
    end)
38

39
    {:noreply, %{state | check_ref: check_metrics(), pools: active_pools}}
40
  end
41

42
  ## Internal functions
43

44
  defp check_metrics do
45
    Process.send_after(
5✔
46
      self(),
47
      :check_metrics,
48
      @check_timeout
49
    )
50
  end
51
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