fix: Repair /metrics endpoint (#10813)

* fix: Repair /metrics endpoint

* Return back change in the application.ex
np-fix-forever-pending-verification
Victor Baranov 2 months ago committed by GitHub
parent 5e4b8d856d
commit e897070d84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      apps/block_scout_web/test/block_scout_web/controllers/metrics_contoller_test.exs
  2. 21
      apps/indexer/lib/indexer/application.ex
  3. 4
      apps/indexer/lib/indexer/prometheus/collector/filecoin_pending_address_operations_collector.ex

@ -0,0 +1,11 @@
defmodule BlockScoutWeb.MetricsControllerTest do
use BlockScoutWeb.ConnCase
describe "/metrics page" do
test "renders /metrics page", %{conn: conn} do
conn = get(conn, "/metrics")
assert text_response(conn, 200)
end
end
end

@ -14,29 +14,8 @@ defmodule Indexer.Application do
alias Indexer.Memory alias Indexer.Memory
alias Prometheus.Registry alias Prometheus.Registry
@default_prometheus_collectors [
Indexer.Prometheus.Collector.PendingBlockOperations
]
case Application.compile_env(:explorer, :chain_type) do
:filecoin ->
@chain_type_prometheus_collectors [
Indexer.Prometheus.Collector.FilecoinPendingAddressOperations
]
_ ->
@chain_type_prometheus_collectors []
end
@prometheus_collectors @default_prometheus_collectors ++
@chain_type_prometheus_collectors
@impl Application @impl Application
def start(_type, _args) do def start(_type, _args) do
for collector <- @prometheus_collectors do
Registry.register_collector(collector)
end
memory_monitor_options = memory_monitor_options =
case Application.get_env(:indexer, :memory_limit) do case Application.get_env(:indexer, :memory_limit) do
nil -> %{} nil -> %{}

@ -1,4 +1,5 @@
defmodule Indexer.Prometheus.Collector.FilecoinPendingAddressOperations do if Application.compile_env(:explorer, :chain_type) == :filecoin do
defmodule Indexer.Prometheus.Collector.FilecoinPendingAddressOperations do
@moduledoc """ @moduledoc """
Custom collector to count number of records in filecoin_pending_address_operations table. Custom collector to count number of records in filecoin_pending_address_operations table.
""" """
@ -26,4 +27,5 @@ defmodule Indexer.Prometheus.Collector.FilecoinPendingAddressOperations do
defp create_gauge(name, help, data) do defp create_gauge(name, help, data) do
Model.create_mf(name, help, :gauge, __MODULE__, data) Model.create_mf(name, help, :gauge, __MODULE__, data)
end end
end
end end

Loading…
Cancel
Save