diff --git a/zetaclient/metrics/metrics.go b/zetaclient/metrics/metrics.go index ddd8b0aa3f..e614cbf676 100644 --- a/zetaclient/metrics/metrics.go +++ b/zetaclient/metrics/metrics.go @@ -85,6 +85,14 @@ var ( Help: "Last core block number", }) + // CoreBlockLatency is a gauge that measures the difference between system time and + // block time from zetacore + CoreBlockLatency = promauto.NewGauge(prometheus.GaugeOpts{ + Namespace: ZetaClientNamespace, + Name: "core_block_latency", + Help: "Difference between system time and block time from zetacore", + }) + // Info is a gauge that contains information about the zetaclient environment Info = promauto.NewGaugeVec(prometheus.GaugeOpts{ Namespace: ZetaClientNamespace, diff --git a/zetaclient/orchestrator/orchestrator.go b/zetaclient/orchestrator/orchestrator.go index 6f0a45543c..a658025307 100644 --- a/zetaclient/orchestrator/orchestrator.go +++ b/zetaclient/orchestrator/orchestrator.go @@ -307,6 +307,9 @@ func (oc *Orchestrator) runScheduler(ctx context.Context) error { case newBlock := <-newBlockChan: bn := newBlock.Block.Height + blockTimeLatency := time.Since(newBlock.Block.Time) + metrics.CoreBlockLatency.Set(blockTimeLatency.Seconds()) + balance, err := oc.zetacoreClient.GetZetaHotKeyBalance(ctx) if err != nil { oc.logger.Error().Err(err).Msgf("couldn't get operator balance")