File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed
telemetry_api/lib/telemetry_api Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 11defmodule TelemetryApi.Periodically do
22 use GenServer
33 alias TelemetryApi.Operators
4- alias TelemetryApi.EthereumMetrics
4+ alias TelemetryApi.PrometheusMetrics
55 alias TelemetryApi.ContractManagers.RegistryCoordinatorManager
66 require Logger
77
@@ -45,7 +45,7 @@ defmodule TelemetryApi.Periodically do
4545 def handle_info ( :gas_price , _state ) do
4646 case Ethers . current_gas_price ( ) do
4747 { :ok , gas_price } ->
48- EthereumMetrics . new_gas_price ( gas_price )
48+ PrometheusMetrics . new_gas_price ( gas_price )
4949
5050 { :error , error } ->
5151 IO . inspect ( "Error fetching gas price: #{ error } " )
Original file line number Diff line number Diff line change 1- defmodule TelemetryApi.EthereumMetrics do
1+ defmodule TelemetryApi.PrometheusMetrics do
22 use Prometheus.Metric
33
44 @ gauge [ name: :gas_price , help: "Ethereum Gas Price." , labels: [ ] ]
5+ @ counter [ name: :missing_operator_count , help: "Missing Operators" , labels: [ :operator ] ]
56
67 def new_gas_price ( gas_price ) do
78 Gauge . set (
89 [ name: :gas_price , labels: [ ] ] ,
910 gas_price
1011 )
1112 end
13+
14+ def missing_operator ( operator ) do
15+ Counter . inc (
16+ name: :missing_operator_count ,
17+ labels: [ operator ]
18+ )
19+ end
1220end
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ defmodule TelemetryApi.Traces do
55 alias TelemetryApi.Traces.Trace
66 alias TelemetryApi.Operators
77 alias TelemetryApi.ContractManagers.StakeRegistry
8+ alias TelemetryApi.PrometheusMetrics
89
910 require OpenTelemetry.Tracer
1011 require OpenTelemetry.Ctx
@@ -208,7 +209,6 @@ defmodule TelemetryApi.Traces do
208209 :ok
209210 end
210211 end
211-
212212
213213 @ doc """
214214 Registers the sending of a batcher task to Ethereum in the task trace.
@@ -298,7 +298,7 @@ defmodule TelemetryApi.Traces do
298298 :ok
299299 end
300300 end
301-
301+
302302 @ doc """
303303 Registers a bump in the gas price when the aggregator tries to respond to a task in the task trace.
304304
@@ -368,6 +368,11 @@ defmodule TelemetryApi.Traces do
368368 defp add_missing_operators ( [ ] ) , do: :ok
369369
370370 defp add_missing_operators ( missing_operators ) do
371+ # Send to prometheus
372+ missing_operators
373+ |> Enum . map ( fn o -> PrometheusMetrics . missing_operator ( o . name ) end )
374+ |> Enum . join ( ";" )
375+
371376 missing_operators =
372377 missing_operators |> Enum . map ( fn o -> o . name end ) |> Enum . join ( ";" )
373378
You can’t perform that action at this time.
0 commit comments