fix: Repair /metrics endpoint (#10813)
* fix: Repair /metrics endpoint * Return back change in the application.exnp-fix-forever-pending-verification
parent
5e4b8d856d
commit
e897070d84
@ -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 |
@ -1,29 +1,31 @@ |
|||||||
defmodule Indexer.Prometheus.Collector.FilecoinPendingAddressOperations do |
if Application.compile_env(:explorer, :chain_type) == :filecoin do |
||||||
@moduledoc """ |
defmodule Indexer.Prometheus.Collector.FilecoinPendingAddressOperations do |
||||||
Custom collector to count number of records in filecoin_pending_address_operations table. |
@moduledoc """ |
||||||
""" |
Custom collector to count number of records in filecoin_pending_address_operations table. |
||||||
|
""" |
||||||
|
|
||||||
use Prometheus.Collector |
use Prometheus.Collector |
||||||
|
|
||||||
alias Explorer.Chain.Filecoin.PendingAddressOperation |
alias Explorer.Chain.Filecoin.PendingAddressOperation |
||||||
alias Explorer.Repo |
alias Explorer.Repo |
||||||
alias Prometheus.Model |
alias Prometheus.Model |
||||||
|
|
||||||
def collect_mf(_registry, callback) do |
def collect_mf(_registry, callback) do |
||||||
callback.( |
callback.( |
||||||
create_gauge( |
create_gauge( |
||||||
:filecoin_pending_address_operations, |
:filecoin_pending_address_operations, |
||||||
"Number of records in filecoin_pending_address_operations table", |
"Number of records in filecoin_pending_address_operations table", |
||||||
Repo.aggregate(PendingAddressOperation, :count, timeout: :infinity) |
Repo.aggregate(PendingAddressOperation, :count, timeout: :infinity) |
||||||
|
) |
||||||
) |
) |
||||||
) |
end |
||||||
end |
|
||||||
|
|
||||||
def collect_metrics(:filecoin_pending_address_operations, count) do |
def collect_metrics(:filecoin_pending_address_operations, count) do |
||||||
Model.gauge_metrics([{count}]) |
Model.gauge_metrics([{count}]) |
||||||
end |
end |
||||||
|
|
||||||
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…
Reference in new issue