@@ -19,22 +19,24 @@ type Collector interface {
1919 MeasureRequestDuration (start time.Time , method string )
2020 OperatorBalance (account * flow.Account )
2121 AvailableSigningKeys (count int )
22+ GasEstimationIterations (count int )
2223}
2324
2425var _ Collector = & DefaultCollector {}
2526
2627type DefaultCollector struct {
2728 // TODO: for now we cannot differentiate which api request failed number of times
28- apiErrorsCounter prometheus.Counter
29- serverPanicsCounters * prometheus.CounterVec
30- cadenceBlockHeight prometheus.Gauge
31- evmBlockHeight prometheus.Gauge
32- evmBlockIndexedCounter prometheus.Counter
33- evmTxIndexedCounter prometheus.Counter
34- operatorBalance prometheus.Gauge
35- evmAccountCallCounters * prometheus.CounterVec
36- requestDurations * prometheus.HistogramVec
37- availableSigningkeys prometheus.Gauge
29+ apiErrorsCounter prometheus.Counter
30+ serverPanicsCounters * prometheus.CounterVec
31+ cadenceBlockHeight prometheus.Gauge
32+ evmBlockHeight prometheus.Gauge
33+ evmBlockIndexedCounter prometheus.Counter
34+ evmTxIndexedCounter prometheus.Counter
35+ operatorBalance prometheus.Gauge
36+ evmAccountCallCounters * prometheus.CounterVec
37+ requestDurations * prometheus.HistogramVec
38+ availableSigningkeys prometheus.Gauge
39+ gasEstimationIterations prometheus.Gauge
3840}
3941
4042func NewCollector (logger zerolog.Logger ) Collector {
@@ -90,6 +92,11 @@ func NewCollector(logger zerolog.Logger) Collector {
9092 Help : "Number of keys available for transaction signing" ,
9193 })
9294
95+ gasEstimationIterations := prometheus .NewGauge (prometheus.GaugeOpts {
96+ Name : prefixedName ("gas_estimation_iterations" ),
97+ Help : "Number of iterations taken to estimate the gas of a EVM call/tx" ,
98+ })
99+
93100 metrics := []prometheus.Collector {
94101 apiErrors ,
95102 serverPanicsCounters ,
@@ -101,23 +108,25 @@ func NewCollector(logger zerolog.Logger) Collector {
101108 evmAccountCallCounters ,
102109 requestDurations ,
103110 availableSigningKeys ,
111+ gasEstimationIterations ,
104112 }
105113 if err := registerMetrics (logger , metrics ... ); err != nil {
106114 logger .Info ().Msg ("using noop collector as metric register failed" )
107115 return NopCollector
108116 }
109117
110118 return & DefaultCollector {
111- apiErrorsCounter : apiErrors ,
112- serverPanicsCounters : serverPanicsCounters ,
113- cadenceBlockHeight : cadenceBlockHeight ,
114- evmBlockHeight : evmBlockHeight ,
115- evmBlockIndexedCounter : evmBlockIndexedCounter ,
116- evmTxIndexedCounter : evmTxIndexedCounter ,
117- evmAccountCallCounters : evmAccountCallCounters ,
118- requestDurations : requestDurations ,
119- operatorBalance : operatorBalance ,
120- availableSigningkeys : availableSigningKeys ,
119+ apiErrorsCounter : apiErrors ,
120+ serverPanicsCounters : serverPanicsCounters ,
121+ cadenceBlockHeight : cadenceBlockHeight ,
122+ evmBlockHeight : evmBlockHeight ,
123+ evmBlockIndexedCounter : evmBlockIndexedCounter ,
124+ evmTxIndexedCounter : evmTxIndexedCounter ,
125+ evmAccountCallCounters : evmAccountCallCounters ,
126+ requestDurations : requestDurations ,
127+ operatorBalance : operatorBalance ,
128+ availableSigningkeys : availableSigningKeys ,
129+ gasEstimationIterations : gasEstimationIterations ,
121130 }
122131}
123132
@@ -172,6 +181,10 @@ func (c *DefaultCollector) AvailableSigningKeys(count int) {
172181 c .availableSigningkeys .Set (float64 (count ))
173182}
174183
184+ func (c * DefaultCollector ) GasEstimationIterations (count int ) {
185+ c .gasEstimationIterations .Set (float64 (count ))
186+ }
187+
175188func prefixedName (name string ) string {
176189 return fmt .Sprintf ("evm_gateway_%s" , name )
177190}
0 commit comments