Skip to content

Commit

Permalink
*: Register prometheus metric for each type of tracker
Browse files Browse the repository at this point in the history
Signed-off-by: Evgenii Baidakov <[email protected]>
  • Loading branch information
smallhive committed Dec 22, 2023
1 parent 7848479 commit 4e8602f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
3 changes: 0 additions & 3 deletions cmd/neofs-net-monitor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"strings"
"syscall"

"github.com/nspcc-dev/neofs-net-monitor/pkg/monitor"
"github.com/spf13/viper"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -45,8 +44,6 @@ func main() {
os.Exit(1)
}

monitor.RegisterMetrics()

neofsMonitor.Start(ctx)

neofsMonitor.Logger().Info("application started", zap.String("version", Version))
Expand Down
2 changes: 2 additions & 0 deletions cmd/neofs-net-monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ func New(ctx context.Context, cfg *viper.Viper) (*monitor.Monitor, error) {

var job monitor.Job
if cfg.GetBool(cfgChainFSChain) {
monitor.RegisterSideChainMetrics()
job, err = sideChainJob(ctx, cfg, sideNeogoClient, logger, sideChainEndpoints)
} else {
monitor.RegisterMainChainMetrics()
job, err = mainChainJob(cfg, sideNeogoClient, logger)
}

Expand Down
15 changes: 10 additions & 5 deletions pkg/monitor/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,27 @@ var (
)
)

// RegisterMetrics inits prometheus metrics. Panics if can't do it.
func RegisterMetrics() {
// RegisterSideChainMetrics inits prometheus metrics for side chain. Panics if can't do it.
func RegisterSideChainMetrics() {
prometheus.MustRegister(locationPresent)
prometheus.MustRegister(droppedNodesCount)
prometheus.MustRegister(newNodesCount)
prometheus.MustRegister(epochNumber)
prometheus.MustRegister(storageNodeGASBalances)
prometheus.MustRegister(storageNodeNotaryBalances)
prometheus.MustRegister(innerRingBalances)
prometheus.MustRegister(alphabetGASBalances)
prometheus.MustRegister(alphabetNotaryBalances)
prometheus.MustRegister(proxyBalance)
prometheus.MustRegister(mainChainSupply)
prometheus.MustRegister(sideChainSupply)
prometheus.MustRegister(alphabetPubKeys)
prometheus.MustRegister(alphabetPubKeys) // used for both monitors
prometheus.MustRegister(containersNumber)
prometheus.MustRegister(chainHeight)
prometheus.MustRegister(chainState)
}

// RegisterMainChainMetrics inits prometheus metrics for main chain. Panics if can't do it.
func RegisterMainChainMetrics() {
prometheus.MustRegister(alphabetGASBalances)
prometheus.MustRegister(mainChainSupply)
prometheus.MustRegister(alphabetPubKeys) // used for both monitors
}

0 comments on commit 4e8602f

Please sign in to comment.