Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions pkg/chains/legacyevm/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
14 changes: 14 additions & 0 deletions pkg/chains/legacyevm/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{},
Expand Down
Loading