Skip to content

Commit

Permalink
refactor(metrics): replace buildconstants with AddNetworkTag for cons…
Browse files Browse the repository at this point in the history
…istent network tagging across multiple files
  • Loading branch information
virajbhartiya committed Dec 16, 2024
1 parent 1244845 commit 01e8501
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 22 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ The Lotus v1.31.0 release introduces the new `ChainIndexer` subsystem, enhancing
- Return a consistent error when encountering null rounds in ETH RPC method calls. ([filecoin-project/lotus#12655](https://github.com/filecoin-project/lotus/pull/12655))
- Correct erroneous sector QAP-calculation upon sector extension in lotus-miner cli. ([filecoin-project/lotus#12720](https://github.com/filecoin-project/lotus/pull/12720))


## 📝 Changelog

For the full set of changes since the last stable release:
Expand Down
8 changes: 2 additions & 6 deletions blockstore/splitstore/splitstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ import (
ipld "github.com/ipfs/go-ipld-format"
logging "github.com/ipfs/go-log/v2"
"go.opencensus.io/stats"
"go.opencensus.io/tag"
"go.uber.org/multierr"
"golang.org/x/xerrors"

"github.com/filecoin-project/go-state-types/abi"

bstore "github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/build/buildconstants"
"github.com/filecoin-project/lotus/chain/actors/policy"
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/types"
Expand Down Expand Up @@ -270,10 +268,8 @@ func Open(path string, ds dstore.Datastore, hot, cold bstore.Blockstore, cfg *Co
ss.chainSyncCond.L = &ss.chainSyncMx

baseCtx := context.Background()
ctx, err := tag.New(baseCtx, tag.Insert(metrics.Network, buildconstants.NetworkBundle))
if err != nil {
return nil, xerrors.Errorf("failed to create context with network tag: %w", err)
}
ctx := metrics.AddNetworkTag(baseCtx)

ss.ctx, ss.cancel = context.WithCancel(ctx)

ss.reifyCond.L = &ss.reifyMx
Expand Down
3 changes: 1 addition & 2 deletions cmd/lotus-miner/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/filecoin-project/lotus/api/v0api"
"github.com/filecoin-project/lotus/api/v1api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/build/buildconstants"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/lib/ulimit"
"github.com/filecoin-project/lotus/metrics"
Expand Down Expand Up @@ -60,8 +59,8 @@ var runCmd = &cli.Command{
tag.Insert(metrics.Version, build.MinerBuildVersion),
tag.Insert(metrics.Commit, build.CurrentCommit),
tag.Insert(metrics.NodeType, "miner"),
tag.Insert(metrics.Network, buildconstants.NetworkBundle),
)
ctx = metrics.AddNetworkTag(ctx)
// Register all metric views
if err := view.Register(
metrics.MinerNodeViews...,
Expand Down
2 changes: 1 addition & 1 deletion cmd/lotus/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ var DaemonCmd = &cli.Command{
tag.Insert(metrics.Version, build.NodeBuildVersion),
tag.Insert(metrics.Commit, build.CurrentCommit),
tag.Insert(metrics.NodeType, "chain"),
tag.Insert(metrics.Network, buildconstants.NetworkBundle),
)
ctx = metrics.AddNetworkTag(ctx)
// Register all metric views
if err = view.Register(
metrics.ChainNodeViews...,
Expand Down
3 changes: 1 addition & 2 deletions node/modules/lp2p/rcmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"go.opencensus.io/tag"
"go.uber.org/fx"

"github.com/filecoin-project/lotus/build/buildconstants"
"github.com/filecoin-project/lotus/metrics"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/node/repo"
Expand Down Expand Up @@ -180,7 +179,7 @@ type rcmgrMetrics struct{}

func (r rcmgrMetrics) AllowConn(dir network.Direction, usefd bool) {
ctx := context.Background()
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Network, buildconstants.NetworkBundle))
ctx = metrics.AddNetworkTag(ctx)
if dir == network.DirInbound {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Direction, "inbound"))
} else {
Expand Down
3 changes: 1 addition & 2 deletions node/modules/storageminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/namespace"
"github.com/jpillora/backoff"
"go.opencensus.io/tag"
"go.uber.org/fx"
"go.uber.org/multierr"
"golang.org/x/xerrors"
Expand Down Expand Up @@ -291,7 +290,7 @@ func WindowPostScheduler(fc config.MinerFeeConfig, pc config.ProvingConfig) func
)

ctx := helpers.LifecycleCtx(mctx, lc)
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Network, buildconstants.NetworkBundle))
ctx = metrics.AddNetworkTag(ctx)
fps, err := wdpost.NewWindowedPoStScheduler(api, fc, pc, as, sealer, verif, sealer, j, []dtypes.MinerAddress{params.Maddr})

if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions paychmgr/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore"
logging "github.com/ipfs/go-log/v2"
"go.opencensus.io/tag"
"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
Expand All @@ -18,7 +17,6 @@ import (
"github.com/filecoin-project/go-state-types/network"

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build/buildconstants"
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/types"
Expand Down Expand Up @@ -86,7 +84,7 @@ func NewManager(ctx context.Context, shutdown func(), sm stmgr.StateManagerAPI,
// newManager is used by the tests to supply mocks
func newManager(pchstore *Store, pchapi managerAPI) (*Manager, error) {
ctx := context.Background()
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Network, buildconstants.NetworkBundle))
ctx = metrics.AddNetworkTag(ctx)

pm := &Manager{
store: pchstore,
Expand Down
1 change: 0 additions & 1 deletion storage/paths/db_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ func splitString(str string) []string {
}

func (dbi *DBIndex) StorageAttach(ctx context.Context, si storiface.StorageInfo, st fsutil.FsStat) error {

var allow, deny = make([]string, 0, len(si.AllowTypes)), make([]string, 0, len(si.DenyTypes))

if _, hasAlert := dbi.pathAlerts[si.ID]; dbi.alerting != nil && !hasAlert {
Expand Down
8 changes: 4 additions & 4 deletions storage/paths/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ import (
"time"

"github.com/ipfs/go-cid"
"go.opencensus.io/tag"
"golang.org/x/xerrors"

ffi "github.com/filecoin-project/filecoin-ffi"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/proof"

"github.com/filecoin-project/lotus/build/buildconstants"
"github.com/filecoin-project/lotus/lib/result"
"github.com/filecoin-project/lotus/metrics"
"github.com/filecoin-project/lotus/storage/sealer/fsutil"
Expand Down Expand Up @@ -241,7 +239,9 @@ func (st *Local) OpenPath(ctx context.Context, p string) error {
if err != nil {
return err
}
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Network, buildconstants.NetworkBundle))

ctx = metrics.AddNetworkTag(ctx)

err = st.index.StorageAttach(ctx, storiface.StorageInfo{
ID: meta.ID,
URLs: st.urls,
Expand Down Expand Up @@ -334,7 +334,7 @@ func (st *Local) Redeclare(ctx context.Context, filterId *storiface.ID, dropMiss
continue
}

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Network, buildconstants.NetworkBundle))
ctx = metrics.AddNetworkTag(ctx)

err = st.index.StorageAttach(ctx, storiface.StorageInfo{
ID: id,
Expand Down

0 comments on commit 01e8501

Please sign in to comment.