-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: metric endpoint per tenant (#147)
- Loading branch information
Showing
8 changed files
with
92 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.2.27 | ||
0.2.28 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
defmodule Supavisor.TenantsMetrics do | ||
@moduledoc false | ||
use GenServer, restart: :transient | ||
require Logger | ||
|
||
alias Supavisor.Monitoring.PromEx | ||
|
||
@check_timeout 10_000 | ||
|
||
def start_link(args) do | ||
GenServer.start_link(__MODULE__, args, name: __MODULE__) | ||
end | ||
|
||
## Callbacks | ||
|
||
@impl true | ||
def init(_args) do | ||
send(self(), :check_metrics) | ||
{:ok, %{check_ref: make_ref()}} | ||
end | ||
|
||
@impl true | ||
def handle_info(:check_metrics, state) do | ||
Process.cancel_timer(state.check_ref) | ||
|
||
PromEx.do_cache_tenants_metrics() | ||
|
||
{:noreply, %{state | check_ref: check_metrics()}} | ||
end | ||
|
||
## Internal functions | ||
|
||
defp check_metrics() do | ||
Process.send_after( | ||
self(), | ||
:check_metrics, | ||
@check_timeout | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters