@@ -56,34 +56,13 @@ func (e *exporter) ExportMetrics(ctx context.Context, m *metrics.Metrics) error
5656 e .logger .Info ().Msg ("stopping balance monitoring" )
5757 return ctx .Err ()
5858 case <- ticker .C :
59- e .checkEndpointAvailability (m )
6059 for _ , address := range e .addresses {
6160 e .checkBalance (ctx , m , address )
6261 }
6362 }
6463 }
6564}
6665
67- // checkEndpointAvailability checks the availability of each endpoint and marks them as unavailable if any fail.
68- func (e * exporter ) checkEndpointAvailability (m * metrics.Metrics ) {
69- for _ , endpoint := range e .endpoints {
70- if _ , err := cosmos .NewClient (endpoint , e .logger ); err != nil {
71- e .logger .Warn ().
72- Err (err ).
73- Str ("endpoint" , endpoint ).
74- Msg ("failed to create client, marking endpoint as unavailable" )
75- m .RecordConsensusRpcEndpointAvailability (e .chainID , endpoint , false )
76- m .RecordConsensusRpcEndpointError (e .chainID , endpoint , utils .CategorizeError (err ))
77- continue
78- }
79-
80- e .logger .Info ().
81- Str ("endpoint" , endpoint ).
82- Msg ("marking endpoint as available" )
83- m .RecordConsensusRpcEndpointAvailability (e .chainID , endpoint , true )
84- }
85- }
86-
8766// checkBalance queries balance with fallback across endpoints
8867func (e * exporter ) checkBalance (ctx context.Context , m * metrics.Metrics , address string ) {
8968 // try each endpoint until one succeeds
@@ -96,6 +75,8 @@ func (e *exporter) checkBalance(ctx context.Context, m *metrics.Metrics, address
9675 Str ("endpoint" , endpoint ).
9776 Str ("address" , address ).
9877 Msg ("failed to create client, trying next endpoint" )
78+ m .RecordConsensusRpcEndpointAvailability (e .chainID , endpoint , false )
79+ m .RecordConsensusRpcEndpointError (e .chainID , endpoint , utils .CategorizeError (err ))
9980 continue
10081 }
10182
@@ -111,6 +92,8 @@ func (e *exporter) checkBalance(ctx context.Context, m *metrics.Metrics, address
11192 Str ("endpoint" , endpoint ).
11293 Str ("address" , address ).
11394 Msg ("failed to query balance, trying next endpoint" )
95+ m .RecordConsensusRpcEndpointAvailability (e .chainID , endpoint , false )
96+ m .RecordConsensusRpcEndpointError (e .chainID , endpoint , utils .CategorizeError (err ))
11497 continue
11598 }
11699
@@ -141,7 +124,7 @@ func (e *exporter) checkBalance(ctx context.Context, m *metrics.Metrics, address
141124 Msg ("recorded account balance" )
142125 }
143126
144- // successfully queried from this endpoint, done
127+ // successfully queried from this endpoint
145128 return
146129 }
147130
0 commit comments