only register metrics once
This commit is contained in:
parent
0f5f91c094
commit
4f060b87bb
@ -7,6 +7,7 @@ import (
|
|||||||
"math/bits"
|
"math/bits"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sync"
|
||||||
|
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
"github.com/libp2p/go-libp2p"
|
"github.com/libp2p/go-libp2p"
|
||||||
@ -24,6 +25,8 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/node/repo"
|
"github.com/filecoin-project/lotus/node/repo"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var rcmgrMetricsOnce sync.Once
|
||||||
|
|
||||||
func ResourceManager(connMgrHi uint) func(lc fx.Lifecycle, repo repo.LockedRepo) (network.ResourceManager, error) {
|
func ResourceManager(connMgrHi uint) func(lc fx.Lifecycle, repo repo.LockedRepo) (network.ResourceManager, error) {
|
||||||
return func(lc fx.Lifecycle, repo repo.LockedRepo) (network.ResourceManager, error) {
|
return func(lc fx.Lifecycle, repo repo.LockedRepo) (network.ResourceManager, error) {
|
||||||
isFullNode := repo.RepoType().Type() == "FullNode"
|
isFullNode := repo.RepoType().Type() == "FullNode"
|
||||||
@ -115,8 +118,9 @@ func ResourceManager(connMgrHi uint) func(lc fx.Lifecycle, repo repo.LockedRepo)
|
|||||||
return nil, fmt.Errorf("error creating resource manager stats reporter: %w", err)
|
return nil, fmt.Errorf("error creating resource manager stats reporter: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("registering prometheus metrics")
|
rcmgrMetricsOnce.Do(func() {
|
||||||
rcmgrObs.MustRegisterWith(prometheus.DefaultRegisterer)
|
rcmgrObs.MustRegisterWith(prometheus.DefaultRegisterer)
|
||||||
|
})
|
||||||
|
|
||||||
// Metrics
|
// Metrics
|
||||||
opts = append(opts, rcmgr.WithMetrics(rcmgrMetrics{}), rcmgr.WithTraceReporter(str))
|
opts = append(opts, rcmgr.WithMetrics(rcmgrMetrics{}), rcmgr.WithTraceReporter(str))
|
||||||
|
Loading…
Reference in New Issue
Block a user