diff --git a/ethergo/listener/listener.go b/ethergo/listener/listener.go index 3650b958bb..25ed10d1d0 100644 --- a/ethergo/listener/listener.go +++ b/ethergo/listener/listener.go @@ -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) } diff --git a/ethergo/listener/otel.go b/ethergo/listener/otel.go index 392c18cfcb..4b361be50d 100644 --- a/ethergo/listener/otel.go +++ b/ethergo/listener/otel.go @@ -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") @@ -76,7 +77,7 @@ func (o *otelRecorder) recordLastBlock(_ context.Context, observer metric.Observ } opts := metric.WithAttributes( - attribute.Int(metrics.ChainID, int(o.chainID)), + attribute.Int(metrics.ChainID, o.chainID), ) observer.ObserveInt64(o.lastBlockGauge, int64(*o.lastBlock), opts) @@ -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)