Skip to content

Commit

Permalink
chore(core): remove block time metric and track last time subscriptio…
Browse files Browse the repository at this point in the history
…n was stuck
  • Loading branch information
renaynay committed Oct 27, 2023
1 parent ea1bf55 commit 403bc9a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
1 change: 0 additions & 1 deletion core/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 1 addition & 23 deletions core/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"),
Expand Down Expand Up @@ -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()
})
}

Expand Down

0 comments on commit 403bc9a

Please sign in to comment.