From 7c380cd59412c5df5d78e75cfb23af644fc89178 Mon Sep 17 00:00:00 2001 From: Sam Calder-Mason Date: Fri, 22 Sep 2023 10:34:30 +1000 Subject: [PATCH] Move metrics --- pkg/cannon/ethereum/beacon.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/cannon/ethereum/beacon.go b/pkg/cannon/ethereum/beacon.go index 0177e68d..8c4f893d 100644 --- a/pkg/cannon/ethereum/beacon.go +++ b/pkg/cannon/ethereum/beacon.go @@ -203,6 +203,8 @@ func (b *BeaconNode) Synced(ctx context.Context) error { // GetBeaconBlock returns a beacon block by its identifier. Blocks can be cached internally. func (b *BeaconNode) GetBeaconBlock(ctx context.Context, identifier string, ignoreMetrics ...bool) (*spec.VersionedSignedBeaconBlock, error) { + b.metrics.IncBlocksFetched(string(b.Metadata().Network.Name)) + // Use singleflight to ensure we only make one request for a block at a time. x, err, _ := b.sfGroup.Do(identifier, func() (interface{}, error) { // Check the cache first. @@ -237,10 +239,6 @@ func (b *BeaconNode) GetBeaconBlock(ctx context.Context, identifier string, igno return nil, err } - if len(ignoreMetrics) != 0 && ignoreMetrics[0] { - b.metrics.IncBlocksFetched(string(b.Metadata().Network.Name)) - } - return x.(*spec.VersionedSignedBeaconBlock), nil }