Add instrumenter for explorer

pull/6209/head
sl1depengwyn 2 years ago
parent a98c6f3333
commit 0d815c9a9d
  1. 23
      apps/explorer/lib/explorer/prometheus/instrumenter.ex

@ -0,0 +1,23 @@
defmodule Explorer.Prometheus.Instrumenter do
@moduledoc """
Blocks fetch and import metrics for `Prometheus`.
"""
use Prometheus.Metric
@histogram [
name: :block_import_stage_runner_duration_microseconds,
labels: [:stage, :runner, :step],
buckets: [1000, 5000, 10000, 100_000],
duration_unit: :microseconds,
help: "Block import stage, runner and step in runner processing time"
]
def block_import_stage_runner(function, stage, runner, step) do
{time, result} = :timer.tc(function)
Histogram.observe([name: :block_import_stage_runner_duration_microseconds, labels: [stage, runner, step]], time)
result
end
end
Loading…
Cancel
Save