Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove optional gatherer #563

Merged
merged 4 commits into from
May 30, 2024
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21.10

require (
github.com/VictoriaMetrics/fastcache v1.12.1
github.com/ava-labs/avalanchego v1.11.6
github.com/ava-labs/avalanchego v1.11.7-remove-optional-gatherer
github.com/cespare/cp v0.1.0
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233
github.com/davecgh/go-spew v1.1.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanchego v1.11.6 h1:gPWNQSV+bY3XW9OhfJ4wNwxp/qidTSHA4V+VYP8kWpQ=
github.com/ava-labs/avalanchego v1.11.6/go.mod h1:s8U9tOakcU6ftSL4JcRcFrNNYI5JbekNCjTkdqZWYdE=
github.com/ava-labs/avalanchego v1.11.7-remove-optional-gatherer h1:zypQAMneAPjwuifqoZYhisqH58GZ2pquFeRqVTLI2p8=
github.com/ava-labs/avalanchego v1.11.7-remove-optional-gatherer/go.mod h1:s8U9tOakcU6ftSL4JcRcFrNNYI5JbekNCjTkdqZWYdE=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down
35 changes: 16 additions & 19 deletions plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"sync"
"time"

avalanchegoMetrics "github.com/ava-labs/avalanchego/api/metrics"
"github.com/ava-labs/avalanchego/network/p2p"
"github.com/ava-labs/avalanchego/network/p2p/gossip"
avalanchegoConstants "github.com/ava-labs/avalanchego/utils/constants"
Expand Down Expand Up @@ -137,6 +136,7 @@ const (

// Prefixes for metrics gatherers
ethMetricsPrefix = "eth"
sdkMetricsPrefix = "sdk"
chainStateMetricsPrefix = "chain_state"

targetAtomicTxsSize = 40 * units.KiB
Expand Down Expand Up @@ -316,8 +316,7 @@ type VM struct {
validators *p2p.Validators

// Metrics
multiGatherer avalanchegoMetrics.MultiGatherer
sdkMetrics *prometheus.Registry
sdkMetrics *prometheus.Registry

bootstrapped bool
IsPlugin bool
Expand Down Expand Up @@ -667,22 +666,16 @@ func (vm *VM) Initialize(

func (vm *VM) initializeMetrics() error {
vm.sdkMetrics = prometheus.NewRegistry()
vm.multiGatherer = avalanchegoMetrics.NewMultiGatherer()
// If metrics are enabled, register the default metrics regitry
if metrics.Enabled {
gatherer := corethPrometheus.Gatherer(metrics.DefaultRegistry)
if err := vm.multiGatherer.Register(ethMetricsPrefix, gatherer); err != nil {
return err
}
if err := vm.multiGatherer.Register("sdk", vm.sdkMetrics); err != nil {
return err
}
// Register [multiGatherer] after registerers have been registered to it
if err := vm.ctx.Metrics.Register(vm.multiGatherer); err != nil {
return err
}
// If metrics are enabled, register the default metrics registry
if !metrics.Enabled {
return nil
}
return nil

gatherer := corethPrometheus.Gatherer(metrics.DefaultRegistry)
if err := vm.ctx.Metrics.Register(ethMetricsPrefix, gatherer); err != nil {
return err
}
return vm.ctx.Metrics.Register(sdkMetricsPrefix, vm.sdkMetrics)
}

func (vm *VM) initializeChain(lastAcceptedHash common.Hash) error {
Expand Down Expand Up @@ -816,7 +809,11 @@ func (vm *VM) initChainState(lastAcceptedBlock *types.Block) error {
}
vm.State = state

return vm.multiGatherer.Register(chainStateMetricsPrefix, chainStateRegisterer)
if !metrics.Enabled {
return nil
}

return vm.ctx.Metrics.Register(chainStateMetricsPrefix, chainStateRegisterer)
StephenButtolph marked this conversation as resolved.
Show resolved Hide resolved
}

func (vm *VM) createConsensusCallbacks() dummy.ConsensusCallbacks {
Expand Down
2 changes: 1 addition & 1 deletion scripts/versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
set -euo pipefail

# Don't export them as they're used in the context of other calls
AVALANCHE_VERSION=${AVALANCHE_VERSION:-'v1.11.6'}
AVALANCHE_VERSION=${AVALANCHE_VERSION:-'v1.11.7-remove-optional-gatherer'}
2 changes: 1 addition & 1 deletion utils/snow.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestSnowContext() *snow.Context {
PublicKey: pk,
Log: logging.NoLog{},
BCLookup: ids.NewAliaser(),
Metrics: metrics.NewOptionalGatherer(),
Metrics: metrics.NewMultiGatherer(),
ChainDataDir: "",
ValidatorState: &validators.TestState{},
}
Expand Down
Loading