From 403bc9a924410d5675c652e16017cca5b049efc3 Mon Sep 17 00:00:00 2001 From: rene <41963722+renaynay@users.noreply.github.com> Date: Thu, 26 Oct 2023 16:55:09 +0200 Subject: [PATCH] chore(core): remove block time metric and track last time subscription was stuck --- core/listener.go | 1 - core/metrics.go | 24 +----------------------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/core/listener.go b/core/listener.go index 9862a16d8e..d231ab06c8 100644 --- a/core/listener.go +++ b/core/listener.go @@ -163,7 +163,6 @@ func (cl *Listener) listen(ctx context.Context, sub <-chan types.EventDataSigned return errors.New("underlying subscription was closed") } - cl.metrics.observeBlockTime(ctx) log.Debugw("listener: new block from core", "height", b.Header.Height) err := cl.handleNewSignedBlock(ctx, b) diff --git a/core/metrics.go b/core/metrics.go index b3fd749563..b849a0cecc 100644 --- a/core/metrics.go +++ b/core/metrics.go @@ -11,9 +11,6 @@ import ( var meter = otel.Meter("core") type metrics struct { - blockTime time.Time - blockTimeInst metric.Float64Histogram - lastTimeSubscriptionStuck time.Time lastTimeSubscriptionStuckInst metric.Int64Observable lastTimeSubscriptionStuckReg metric.Registration @@ -25,14 +22,6 @@ func newMetrics() (*metrics, error) { m := new(metrics) var err error - m.blockTimeInst, err = meter.Float64Histogram( - "core_listener_block_time", - metric.WithDescription("time between blocks coming through core listener block subscription"), - ) - if err != nil { - return nil, err - } - m.subscriptionStuckInst, err = meter.Int64Counter( "core_listener_subscription_stuck_count", metric.WithDescription("number of times core listener block subscription has been stuck/retried"), @@ -64,21 +53,10 @@ func (m *metrics) observe(ctx context.Context, observeFn func(context.Context)) observeFn(ctx) } -func (m *metrics) observeBlockTime(ctx context.Context) { - m.observe(ctx, func(ctx context.Context) { - now := time.Now() - - if !m.blockTime.IsZero() { - m.blockTimeInst.Record(ctx, now.Sub(m.blockTime).Seconds()) - } - - m.blockTime = now - }) -} - func (m *metrics) subscriptionStuck(ctx context.Context) { m.observe(ctx, func(ctx context.Context) { m.subscriptionStuckInst.Add(ctx, 1) + m.lastTimeSubscriptionStuck = time.Now() }) }