Skip to content

Commit

Permalink
Merge pull request filecoin-project#11361 from filecoin-project/feat/…
Browse files Browse the repository at this point in the history
…add-mpool-metrics

feat: metric: export Mpool message count
  • Loading branch information
rjan90 authored Nov 3, 2023
2 parents b1228b5 + 9d58fff commit 12b30c0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# UNRELEASED
- chore: Auto remove local chain data when importing chain file or snapshot ([filecoin-project/lotus#11277](https://github.com/filecoin-project/lotus/pull/11277))
- feat: metric: export Mpool message count ([filecoin-project/lotus#11361](https://github.com/filecoin-project/lotus/pull/11361))

## New features
- feat: Added new tracing API (**HIGHLY EXPERIMENTAL**) supporting two RPC methods: `trace_block` and `trace_replayBlockTransactions` ([filecoin-project/lotus#11100](https://github.com/filecoin-project/lotus/pull/11100))
Expand Down
7 changes: 7 additions & 0 deletions chain/messagepool/messagepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/minio/blake2b-simd"
"github.com/raulk/clock"
"go.opencensus.io/stats"
"golang.org/x/xerrors"

ffi "github.com/filecoin-project/filecoin-ffi"
Expand Down Expand Up @@ -1021,6 +1022,9 @@ func (mp *MessagePool) addLocked(ctx context.Context, m *types.SignedMessage, st
}
})

// Record the current size of the Mpool
stats.Record(ctx, metrics.MpoolMessageCount.M(int64(mp.currentSize)))

return nil
}

Expand Down Expand Up @@ -1213,6 +1217,9 @@ func (mp *MessagePool) remove(ctx context.Context, from address.Address, nonce u
return
}
}

// Record the current size of the Mpool
stats.Record(ctx, metrics.MpoolMessageCount.M(int64(mp.currentSize)))
}

func (mp *MessagePool) Pending(ctx context.Context) ([]*types.SignedMessage, *types.TipSet) {
Expand Down
6 changes: 6 additions & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ var (
MpoolAddTsDuration = stats.Float64("mpool/addts_ms", "Duration of addTs in mpool", stats.UnitMilliseconds)
MpoolAddDuration = stats.Float64("mpool/add_ms", "Duration of Add in mpool", stats.UnitMilliseconds)
MpoolPushDuration = stats.Float64("mpool/push_ms", "Duration of Push in mpool", stats.UnitMilliseconds)
MpoolMessageCount = stats.Int64("mpool/message_count", "Number of messages in the mpool", stats.UnitDimensionless)
BlockPublished = stats.Int64("block/published", "Counter for total locally published blocks", stats.UnitDimensionless)
BlockReceived = stats.Int64("block/received", "Counter for total received blocks", stats.UnitDimensionless)
BlockValidationFailure = stats.Int64("block/failure", "Counter for block validation failures", stats.UnitDimensionless)
Expand Down Expand Up @@ -307,6 +308,10 @@ var (
Measure: MpoolPushDuration,
Aggregation: defaultMillisecondsDistribution,
}
MpoolMessageCountView = &view.View{
Measure: MpoolMessageCount,
Aggregation: view.LastValue(),
}
PeerCountView = &view.View{
Measure: PeerCount,
Aggregation: view.LastValue(),
Expand Down Expand Up @@ -761,6 +766,7 @@ var ChainNodeViews = append([]*view.View{
MpoolAddTsDurationView,
MpoolAddDurationView,
MpoolPushDurationView,
MpoolMessageCountView,
PubsubPublishMessageView,
PubsubDeliverMessageView,
PubsubRejectMessageView,
Expand Down

0 comments on commit 12b30c0

Please sign in to comment.