Skip to content

Commit

Permalink
Observability - remove old metric implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-ssvlabs committed Dec 2, 2024
1 parent da9df9b commit 1243fc1
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 314 deletions.
21 changes: 5 additions & 16 deletions cli/operator/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import (
genesisvalidation "github.com/ssvlabs/ssv/message/validation/genesis"
"github.com/ssvlabs/ssv/migrations"
"github.com/ssvlabs/ssv/monitoring/metrics"
"github.com/ssvlabs/ssv/monitoring/metricsreporter"
"github.com/ssvlabs/ssv/network"
p2pv1 "github.com/ssvlabs/ssv/network/p2p"
"github.com/ssvlabs/ssv/networkconfig"
Expand Down Expand Up @@ -117,10 +116,6 @@ var StartNodeCmd = &cobra.Command{

logger.Info(fmt.Sprintf("starting %v", commons.GetBuildData()))

metricsReporter := metricsreporter.New(
metricsreporter.WithLogger(logger),
)

observabilityShutdown, err := observability.Initialize(
cmd.Parent().Short,
cmd.Parent().Version,
Expand Down Expand Up @@ -262,7 +257,6 @@ var StartNodeCmd = &cobra.Command{
networkConfig,
genesisvalidation.WithNodeStorage(nodeStorage),
genesisvalidation.WithLogger(logger),
genesisvalidation.WithMetrics(metricsReporter),
genesisvalidation.WithDutyStore(dutyStore),
),
}
Expand All @@ -271,7 +265,7 @@ var StartNodeCmd = &cobra.Command{
cfg.P2pNetworkConfig.MessageValidator = messageValidator
cfg.SSVOptions.ValidatorOptions.MessageValidator = messageValidator

p2pNetwork, genesisP2pNetwork := setupP2P(logger, db, metricsReporter)
p2pNetwork, genesisP2pNetwork := setupP2P(logger, db)

cfg.SSVOptions.Context = cmd.Context()
cfg.SSVOptions.DB = db
Expand Down Expand Up @@ -343,7 +337,6 @@ var StartNodeCmd = &cobra.Command{
cfg.SSVOptions.ValidatorOptions.Graffiti = []byte(cfg.Graffiti)
cfg.SSVOptions.ValidatorOptions.ValidatorStore = nodeStorage.ValidatorStore()
cfg.SSVOptions.ValidatorOptions.OperatorSigner = types.NewSsvOperatorSigner(operatorPrivKey, operatorDataStore.GetOperatorID)
cfg.SSVOptions.Metrics = metricsReporter

cfg.SSVOptions.ValidatorOptions.GenesisControllerOptions.StorageMap = genesisStorageMap
cfg.SSVOptions.ValidatorOptions.GenesisControllerOptions.Network = &genesisP2pNetwork
Expand All @@ -355,7 +348,7 @@ var StartNodeCmd = &cobra.Command{
operatorNode = operator.New(logger, cfg.SSVOptions, slotTickerProvider, storageMap)

if cfg.MetricsAPIPort > 0 {
go startMetricsHandler(cmd.Context(), logger, db, metricsReporter, cfg.MetricsAPIPort, cfg.EnableProfile)
go startMetricsHandler(cmd.Context(), logger, db, cfg.MetricsAPIPort, cfg.EnableProfile)
}

nodeProber := nodeprobe.NewProber(
Expand All @@ -377,14 +370,11 @@ var StartNodeCmd = &cobra.Command{
nodeProber.Wait()
logger.Info("ethereum node(s) are healthy")

metricsReporter.SSVNodeHealthy()

eventSyncer := setupEventHandling(
cmd.Context(),
logger,
executionClient,
validatorCtrl,
metricsReporter,
networkConfig,
nodeStorage,
operatorDataStore,
Expand Down Expand Up @@ -661,7 +651,7 @@ func setupSSVNetwork(logger *zap.Logger) (networkconfig.NetworkConfig, error) {
return networkConfig, nil
}

func setupP2P(logger *zap.Logger, db basedb.Database, mr metricsreporter.MetricsReporter) (network.P2PNetwork, p2pv1.GenesisP2P) {
func setupP2P(logger *zap.Logger, db basedb.Database) (network.P2PNetwork, p2pv1.GenesisP2P) {
istore := ssv_identity.NewIdentityStore(db)
netPrivKey, err := istore.SetupNetworkKey(logger, cfg.NetworkPrivateKey)
if err != nil {
Expand Down Expand Up @@ -695,7 +685,6 @@ func setupEventHandling(
logger *zap.Logger,
executionClient *executionclient.ExecutionClient,
validatorCtrl validator.Controller,
metricsReporter metricsreporter.MetricsReporter,
networkConfig networkconfig.NetworkConfig,
nodeStorage operatorstorage.Storage,
operatorDataStore operatordatastore.OperatorDataStore,
Expand Down Expand Up @@ -811,10 +800,10 @@ func setupEventHandling(
return eventSyncer
}

func startMetricsHandler(ctx context.Context, logger *zap.Logger, db basedb.Database, metricsReporter metricsreporter.MetricsReporter, port int, enableProf bool) {
func startMetricsHandler(ctx context.Context, logger *zap.Logger, db basedb.Database, port int, enableProf bool) {
logger = logger.Named(logging.NameMetricsHandler)
// init and start HTTP handler
metricsHandler := metrics.NewMetricsHandler(ctx, db, metricsReporter, enableProf, operatorNode.(metrics.HealthChecker))
metricsHandler := metrics.NewMetricsHandler(ctx, db, enableProf, operatorNode.(metrics.HealthChecker))
addr := fmt.Sprintf(":%d", port)
if err := metricsHandler.Start(logger, http.NewServeMux(), addr); err != nil {
logger.Panic("failed to serve metrics", zap.Error(err))
Expand Down
11 changes: 0 additions & 11 deletions message/validation/genesis/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/ssvlabs/ssv/utils/hashmap"

"github.com/ssvlabs/ssv/logging/fields"
"github.com/ssvlabs/ssv/monitoring/metricsreporter"
"github.com/ssvlabs/ssv/network/commons"
"github.com/ssvlabs/ssv/networkconfig"
"github.com/ssvlabs/ssv/operator/duties/dutystore"
Expand Down Expand Up @@ -63,7 +62,6 @@ type MessageValidator interface {

type messageValidator struct {
logger *zap.Logger
metrics metricsreporter.MetricsReporter
netCfg networkconfig.NetworkConfig
index sync.Map
nodeStorage operatorstorage.Storage
Expand All @@ -83,7 +81,6 @@ type messageValidator struct {
func New(netCfg networkconfig.NetworkConfig, opts ...Option) MessageValidator {
mv := &messageValidator{
logger: zap.NewNop(),
metrics: metricsreporter.NewNop(),
netCfg: netCfg,
operatorIDToPubkeyCache: hashmap.New[spectypes.OperatorID, keys.OperatorPublicKey](),
validationLocks: make(map[spectypes.MessageID]*sync.Mutex),
Expand All @@ -106,13 +103,6 @@ func WithLogger(logger *zap.Logger) Option {
}
}

// WithMetrics sets the metrics for the messageValidator.
func WithMetrics(metrics metricsreporter.MetricsReporter) Option {
return func(mv *messageValidator) {
mv.metrics = metrics
}
}

// WithDutyStore sets the duty store for the messageValidator.
func WithDutyStore(dutyStore *dutystore.Store) Option {
return func(mv *messageValidator) {
Expand Down Expand Up @@ -292,7 +282,6 @@ func (mv *messageValidator) validateP2PMessage(pMsg *pubsub.Message, receivedAt
}

signatureVerifier := func() error {
mv.metrics.MessageValidationRSAVerifications()
return mv.verifySignature(signedSSVMsg)
}

Expand Down
10 changes: 2 additions & 8 deletions monitoring/metrics/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,16 @@ type Handler interface {
type metricsHandler struct {
ctx context.Context
db basedb.Database
reporter nodeMetrics
enableProf bool
healthChecker HealthChecker
}

// NewMetricsHandler returns a new metrics handler.
func NewMetricsHandler(ctx context.Context, db basedb.Database, reporter nodeMetrics, enableProf bool, healthChecker HealthChecker) Handler {
if reporter == nil {
reporter = nopMetrics{}
}
func NewMetricsHandler(ctx context.Context, db basedb.Database, enableProf bool, healthChecker HealthChecker) Handler {

mh := metricsHandler{
ctx: ctx,
db: db,
reporter: reporter,
enableProf: enableProf,
healthChecker: healthChecker,
}
Expand Down Expand Up @@ -128,7 +124,6 @@ func (mh *metricsHandler) handleCountByCollection(w http.ResponseWriter, r *http

func (mh *metricsHandler) handleHealth(res http.ResponseWriter, req *http.Request) {
if err := mh.healthChecker.HealthCheck(); err != nil {
mh.reporter.SSVNodeNotHealthy()
result := map[string][]string{
"errors": {err.Error()},
}
Expand All @@ -138,7 +133,6 @@ func (mh *metricsHandler) handleHealth(res http.ResponseWriter, req *http.Reques
http.Error(res, string(raw), http.StatusInternalServerError)
}
} else {
mh.reporter.SSVNodeHealthy()
if _, err := fmt.Fprintln(res, ""); err != nil {
http.Error(res, err.Error(), http.StatusInternalServerError)
}
Expand Down
11 changes: 0 additions & 11 deletions monitoring/metrics/reporter.go

This file was deleted.

187 changes: 0 additions & 187 deletions monitoring/metricsreporter/metrics_reporter.go

This file was deleted.

Loading

0 comments on commit 1243fc1

Please sign in to comment.