Hook up resource manager metrics
This commit is contained in:
parent
3c2c827bc3
commit
5a133ff2d4
@ -9,6 +9,7 @@ import (
|
|||||||
"go.opencensus.io/tag"
|
"go.opencensus.io/tag"
|
||||||
|
|
||||||
rpcmetrics "github.com/filecoin-project/go-jsonrpc/metrics"
|
rpcmetrics "github.com/filecoin-project/go-jsonrpc/metrics"
|
||||||
|
"github.com/libp2p/go-libp2p-resource-manager/obs"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/blockstore"
|
"github.com/filecoin-project/lotus/blockstore"
|
||||||
)
|
)
|
||||||
@ -645,6 +646,7 @@ var DefaultViews = func() []*view.View {
|
|||||||
}
|
}
|
||||||
views = append(views, blockstore.DefaultViews...)
|
views = append(views, blockstore.DefaultViews...)
|
||||||
views = append(views, rpcmetrics.DefaultViews...)
|
views = append(views, rpcmetrics.DefaultViews...)
|
||||||
|
views = append(views, obs.DefaultViews...)
|
||||||
return views
|
return views
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
ocprom "contrib.go.opencensus.io/exporter/prometheus"
|
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
"github.com/libp2p/go-libp2p"
|
"github.com/libp2p/go-libp2p"
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p-core/network"
|
||||||
@ -16,9 +15,7 @@ import (
|
|||||||
"github.com/libp2p/go-libp2p-core/protocol"
|
"github.com/libp2p/go-libp2p-core/protocol"
|
||||||
rcmgr "github.com/libp2p/go-libp2p-resource-manager"
|
rcmgr "github.com/libp2p/go-libp2p-resource-manager"
|
||||||
rcmgrObs "github.com/libp2p/go-libp2p-resource-manager/obs"
|
rcmgrObs "github.com/libp2p/go-libp2p-resource-manager/obs"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
|
||||||
"go.opencensus.io/stats"
|
"go.opencensus.io/stats"
|
||||||
"go.opencensus.io/stats/view"
|
|
||||||
"go.opencensus.io/tag"
|
"go.opencensus.io/tag"
|
||||||
"go.uber.org/fx"
|
"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)
|
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{
|
lc.Append(fx.Hook{
|
||||||
OnStop: func(_ context.Context) error {
|
OnStop: func(_ context.Context) error {
|
||||||
return mgr.Close()
|
return mgr.Close()
|
||||||
|
Loading…
Reference in New Issue
Block a user