Hook up resource manager metrics

This commit is contained in:
Marco Munizaga 2022-08-11 15:56:48 -07:00
parent 3c2c827bc3
commit 5a133ff2d4
2 changed files with 2 additions and 16 deletions

View File

@ -9,6 +9,7 @@ import (
"go.opencensus.io/tag"
rpcmetrics "github.com/filecoin-project/go-jsonrpc/metrics"
"github.com/libp2p/go-libp2p-resource-manager/obs"
"github.com/filecoin-project/lotus/blockstore"
)
@ -645,6 +646,7 @@ var DefaultViews = func() []*view.View {
}
views = append(views, blockstore.DefaultViews...)
views = append(views, rpcmetrics.DefaultViews...)
views = append(views, obs.DefaultViews...)
return views
}()

View File

@ -8,7 +8,6 @@ import (
"os"
"path/filepath"
ocprom "contrib.go.opencensus.io/exporter/prometheus"
logging "github.com/ipfs/go-log/v2"
"github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p-core/network"
@ -16,9 +15,7 @@ import (
"github.com/libp2p/go-libp2p-core/protocol"
rcmgr "github.com/libp2p/go-libp2p-resource-manager"
rcmgrObs "github.com/libp2p/go-libp2p-resource-manager/obs"
"github.com/prometheus/client_golang/prometheus"
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"
"go.uber.org/fx"
@ -130,19 +127,6 @@ func ResourceManager(connMgrHi uint) func(lc fx.Lifecycle, repo repo.LockedRepo)
return nil, fmt.Errorf("error creating resource manager: %w", err)
}
// Hook up resource manager metrics
err = view.Register(rcmgrObs.DefaultViews...)
if err != nil {
return nil, fmt.Errorf("error registering metrics: %w", err)
}
_, err = ocprom.NewExporter(ocprom.Options{
Registry: prometheus.DefaultRegisterer.(*prometheus.Registry),
Namespace: "rcmgr_trace_metrics",
})
if err != nil {
return nil, fmt.Errorf("error registering metrics: %w", err)
}
lc.Append(fx.Hook{
OnStop: func(_ context.Context) error {
return mgr.Close()