From 5ae8b8139b35e2520d6a665ada860333c1f2f3b1 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Thu, 5 Dec 2024 14:13:13 -0800 Subject: [PATCH] add core_block_time_latency metric --- zetaclient/metrics/metrics.go | 8 ++++++++ zetaclient/orchestrator/orchestrator.go | 3 +++ 2 files changed, 11 insertions(+) diff --git a/zetaclient/metrics/metrics.go b/zetaclient/metrics/metrics.go index ddd8b0aa3f..bfa8f59838 100644 --- a/zetaclient/metrics/metrics.go +++ b/zetaclient/metrics/metrics.go @@ -85,6 +85,14 @@ var ( Help: "Last core block number", }) + // CoreBlockLatency is a guage 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")