Skip to content

Commit

Permalink
Merge branch 'fix/block-acquisition' of https://github.com/synapsecns…
Browse files Browse the repository at this point in the history
…/sanguine into fix/block-acquisition
  • Loading branch information
trajan0x committed Jul 8, 2024
2 parents e64943b + e0e1354 commit a1900b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ethergo/listener/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func NewChainListener(omnirpcClient client.EVM, store listenerDB.ChainListenerDB
}

var err error
c.otelRecorder, err = newOtelRecorder(handler)
c.otelRecorder, err = newOtelRecorder(handler, int(c.chainID))
if err != nil {
return nil, fmt.Errorf("could not create otel recorder: %w", err)
}

Check warning on line 86 in ethergo/listener/listener.go

View check run for this annotation

Codecov / codecov/patch

ethergo/listener/listener.go#L85-L86

Added lines #L85 - L86 were not covered by tests
Expand Down
9 changes: 5 additions & 4 deletions ethergo/listener/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ type otelRecorder struct {
// lastBlockFetchTime is the time the last block was fetched (used to calculate last block age).
lastBlockFetchTime *time.Time
// chainID is the chain ID for the listener.
chainID uint32
chainID int
}

func newOtelRecorder(meterHandler metrics.Handler) (_ iOtelRecorder, err error) {
func newOtelRecorder(meterHandler metrics.Handler, chainID int) (_ iOtelRecorder, err error) {
or := otelRecorder{
metrics: meterHandler,
meter: meterHandler.Meter(meterName),
lastBlock: nil,
lastBlockFetchTime: nil,
chainID: chainID,
}

or.lastBlockGauge, err = or.meter.Int64ObservableGauge("last_block")
Expand Down Expand Up @@ -76,7 +77,7 @@ func (o *otelRecorder) recordLastBlock(_ context.Context, observer metric.Observ
}

Check warning on line 77 in ethergo/listener/otel.go

View check run for this annotation

Codecov / codecov/patch

ethergo/listener/otel.go#L74-L77

Added lines #L74 - L77 were not covered by tests

opts := metric.WithAttributes(
attribute.Int(metrics.ChainID, int(o.chainID)),
attribute.Int(metrics.ChainID, o.chainID),
)
observer.ObserveInt64(o.lastBlockGauge, int64(*o.lastBlock), opts)

Expand All @@ -90,7 +91,7 @@ func (o *otelRecorder) recordLastBlockAge(_ context.Context, observer metric.Obs

age := time.Since(*o.lastBlockFetchTime).Seconds()
opts := metric.WithAttributes(
attribute.Int(metrics.ChainID, int(o.chainID)),
attribute.Int(metrics.ChainID, o.chainID),
)
observer.ObserveFloat64(o.lastBlockAgeGauge, age, opts)

Expand Down

0 comments on commit a1900b6

Please sign in to comment.