diff --git a/internal/metrics/metrics.go b/internal/metrics/metrics.go index 78fc0d4..1faf4b2 100644 --- a/internal/metrics/metrics.go +++ b/internal/metrics/metrics.go @@ -50,6 +50,13 @@ var ( }) ) +var ( + PollerLastTriggeredBlock = promauto.NewGauge(prometheus.GaugeOpts{ + Name: "poller_last_triggered_block", + Help: "The last block number that the poller was triggered for", + }) +) + // Failure Recoverer Metrics var ( FailureRecovererLastTriggeredBlock = promauto.NewGauge(prometheus.GaugeOpts{ diff --git a/internal/orchestrator/poller.go b/internal/orchestrator/poller.go index 031dae2..13030f9 100644 --- a/internal/orchestrator/poller.go +++ b/internal/orchestrator/poller.go @@ -95,6 +95,9 @@ func (p *Poller) Start() { } log.Debug().Msgf("Polling %d blocks starting from %s to %s", len(blockNumbers), blockNumbers[0], endBlock) + endBlockNumberFloat, _ := endBlock.Float64() + metrics.PollerLastTriggeredBlock.Set(endBlockNumberFloat) + worker := worker.NewWorker(p.rpc) results := worker.Run(blockNumbers) p.handleWorkerResults(results) diff --git a/internal/worker/worker.go b/internal/worker/worker.go index 89e89f4..2915616 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -92,9 +92,8 @@ func (w *Worker) Run(blockNumbers []*big.Int) []WorkerResult { // track the last fetched block number if len(results) > 0 { - // dividing by 10 to avoid scientific notation (e.g. 1.23456e+07) - // TODO: find a solution - metrics.LastFetchedBlock.Set(float64(results[len(results)-1].BlockNumber.Uint64()) / 10) + lastBlockNumberFloat, _ := results[len(results)-1].BlockNumber.Float64() + metrics.LastFetchedBlock.Set(lastBlockNumberFloat) } return results }