From d24c4b8c9677e4cfdd7591043d9d015cac49eaee Mon Sep 17 00:00:00 2001 From: mostlyconsistent Date: Mon, 16 Nov 2026 11:04:28 -0500 Subject: [PATCH] OEV-1803 Remove Meter() TODO post core bump Make legacyevm.ChainOpts.Meter required and drop the beholder.GetMeter() fallback in newChain. Core now passes the meter explicitly. --- pkg/chains/legacyevm/chain.go | 14 +++++--------- pkg/chains/legacyevm/chain_test.go | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/pkg/chains/legacyevm/chain.go b/pkg/chains/legacyevm/chain.go index 59ea14cb94..ce06a82027 100644 --- a/pkg/chains/legacyevm/chain.go +++ b/pkg/chains/legacyevm/chain.go @@ -14,7 +14,6 @@ import ( chainselectors "github.com/smartcontractkit/chain-selectors" - "github.com/smartcontractkit/chainlink-common/pkg/beholder" common "github.com/smartcontractkit/chainlink-common/pkg/chains" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/services" @@ -151,9 +150,7 @@ type ChainOpts struct { DS sqlutil.DataSource - // Meter is used to report chain metrics. Defaults to the global beholder - // meter when unset. - // TODO: make this required once chainlink core passes it explicitly. + // Meter is used to report chain metrics. Required. Meter metric.Meter // TODO BCF-2513 remove test code from the API @@ -187,6 +184,9 @@ func (o ChainOpts) Validate() error { if o.DS == nil { err = errors.Join(err, errors.New("nil DS")) } + if o.Meter == nil { + err = errors.Join(err, errors.New("nil Meter")) + } if err != nil { err = fmt.Errorf("invalid ChainOpts: %w", err) } @@ -342,11 +342,7 @@ func newChain(cfg *config.ChainScoped, nodes []*toml.Node, opts ChainRelayOpts, } } - meter := opts.Meter - if meter == nil { - meter = beholder.GetMeter() - } - chainConfigMetrics, err := newChainConfigMetrics(meter) + chainConfigMetrics, err := newChainConfigMetrics(opts.Meter) if err != nil { return nil, fmt.Errorf("failed to create chain config metrics: %w", err) } diff --git a/pkg/chains/legacyevm/chain_test.go b/pkg/chains/legacyevm/chain_test.go index 28647062d6..a6484e2f2a 100644 --- a/pkg/chains/legacyevm/chain_test.go +++ b/pkg/chains/legacyevm/chain_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "go.opentelemetry.io/otel/metric/noop" "github.com/smartcontractkit/chainlink-common/pkg/sqlutil/sqltest" "github.com/smartcontractkit/chainlink-common/pkg/types" @@ -51,8 +52,21 @@ func TestChainOpts_Validate(t *testing.T) { FeatureConfig: &testFeatureConfig{}, MailMon: &mailbox.Monitor{}, DS: sqltest.NewNoOpDataSource(), + Meter: noop.NewMeterProvider().Meter("test"), }, }, + { + name: "missing meter", + opts: legacyevm.ChainOpts{ + ChainConfigs: []*toml.EVMConfig{}, + DatabaseConfig: &dbCfg, + ListenerConfig: dbCfg.Listener(), + FeatureConfig: &testFeatureConfig{}, + MailMon: &mailbox.Monitor{}, + DS: sqltest.NewNoOpDataSource(), + }, + wantErr: true, + }, { name: "invalid", opts: legacyevm.ChainOpts{},