From 168067cff797b5cd93d3c25d75680b3e52aa2bc5 Mon Sep 17 00:00:00 2001 From: Qwerty5Uiop <105209995+Qwerty5Uiop@users.noreply.github.com> Date: Wed, 17 Jul 2024 17:08:26 +0400 Subject: [PATCH] fix: Fix on-demand fetchers metrics (#10431) * fix: Fix on-demand fetchers metrics * Fix monitor metrics --- apps/indexer/lib/indexer/memory/monitor.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/indexer/lib/indexer/memory/monitor.ex b/apps/indexer/lib/indexer/memory/monitor.ex index b48bb0b73c..c907cda6b5 100644 --- a/apps/indexer/lib/indexer/memory/monitor.ex +++ b/apps/indexer/lib/indexer/memory/monitor.ex @@ -208,7 +208,7 @@ defmodule Indexer.Memory.Monitor do @megabytes_divisor 2 ** 20 defp set_metrics(%__MODULE__{shrinkable_set: shrinkable_set}) do 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 name = name(pid) @@ -221,7 +221,9 @@ defmodule Indexer.Memory.Monitor do end 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.which_children() |> Enum.filter(fn {name, _, _, _} -> is_atom(name) and String.contains?(to_string(name), "OnDemand") end)