fix: Fix on-demand fetchers metrics (#10431)

* fix: Fix on-demand fetchers metrics

* Fix monitor metrics
pull/10441/head
Qwerty5Uiop 4 months ago committed by GitHub
parent f8f6c78c7c
commit 168067cff7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      apps/indexer/lib/indexer/memory/monitor.ex

@ -208,7 +208,7 @@ defmodule Indexer.Memory.Monitor do
@megabytes_divisor 2 ** 20 @megabytes_divisor 2 ** 20
defp set_metrics(%__MODULE__{shrinkable_set: shrinkable_set}) do defp set_metrics(%__MODULE__{shrinkable_set: shrinkable_set}) do
total_memory = total_memory =
Enum.reduce(shrinkable_set ++ on_demand_fetchers(), 0, fn pid, acc -> Enum.reduce(Enum.to_list(shrinkable_set) ++ on_demand_fetchers(), 0, fn pid, acc ->
memory = memory(pid) / @megabytes_divisor memory = memory(pid) / @megabytes_divisor
name = name(pid) name = name(pid)
@ -221,7 +221,9 @@ defmodule Indexer.Memory.Monitor do
end end
defp on_demand_fetchers do defp on_demand_fetchers do
Enum.flat_map([Indexer.Application, Indexer.Supervisor, Explorer.Supervisor], fn supervisor -> [Indexer.Application, Indexer.Supervisor, Explorer.Supervisor]
|> Enum.reject(&is_nil(Process.whereis(&1)))
|> Enum.flat_map(fn supervisor ->
supervisor supervisor
|> Supervisor.which_children() |> Supervisor.which_children()
|> Enum.filter(fn {name, _, _, _} -> is_atom(name) and String.contains?(to_string(name), "OnDemand") end) |> Enum.filter(fn {name, _, _, _} -> is_atom(name) and String.contains?(to_string(name), "OnDemand") end)

Loading…
Cancel
Save