add some metrics

This commit is contained in:
vyzo 2021-03-05 11:54:06 +02:00
parent 99d21573da
commit 2b32c2e597
2 changed files with 55 additions and 2 deletions

View File

@ -21,6 +21,9 @@ import (
bstore "github.com/filecoin-project/lotus/blockstore" bstore "github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/metrics"
"go.opencensus.io/stats"
) )
var ( var (
@ -206,7 +209,11 @@ func (s *SplitStore) Get(cid cid.Cid) (blocks.Block, error) {
return blk, nil return blk, nil
case bstore.ErrNotFound: case bstore.ErrNotFound:
return s.cold.Get(cid) blk, err = s.cold.Get(cid)
if err != nil {
stats.Record(context.Background(), metrics.SplitstoreMiss.M(1))
}
return blk, err
default: default:
return nil, err return nil, err
@ -221,7 +228,11 @@ func (s *SplitStore) GetSize(cid cid.Cid) (int, error) {
return size, nil return size, nil
case bstore.ErrNotFound: case bstore.ErrNotFound:
return s.cold.GetSize(cid) size, err = s.cold.GetSize(cid)
if err != nil {
stats.Record(context.Background(), metrics.SplitstoreMiss.M(1))
}
return size, err
default: default:
return 0, err return 0, err
@ -539,11 +550,14 @@ func (s *SplitStore) compact(curTs *types.TipSet) {
log.Infow("current mark set size estimate", "size", s.markSetSize) log.Infow("current mark set size estimate", "size", s.markSetSize)
} }
start := time.Now()
if s.fullCompaction { if s.fullCompaction {
err = s.compactFull(curTs) err = s.compactFull(curTs)
} else { } else {
err = s.compactSimple(curTs) err = s.compactSimple(curTs)
} }
took := time.Since(start).Milliseconds()
stats.Record(context.Background(), metrics.SplitstoreCompactionTimeSeconds.M(float64(took)/1e3))
if err != nil { if err != nil {
log.Errorf("COMPACTION ERROR: %s", err) log.Errorf("COMPACTION ERROR: %s", err)
@ -650,6 +664,8 @@ func (s *SplitStore) compactSimple(curTs *types.TipSet) error {
log.Infow("collection done", "took", time.Since(startCollect)) log.Infow("collection done", "took", time.Since(startCollect))
log.Infow("compaction stats", "hot", hotCnt, "cold", coldCnt) log.Infow("compaction stats", "hot", hotCnt, "cold", coldCnt)
stats.Record(context.Background(), metrics.SplitstoreCompactionHot.M(int64(hotCnt)))
stats.Record(context.Background(), metrics.SplitstoreCompactionCold.M(int64(coldCnt)))
// Enter critical section // Enter critical section
atomic.StoreInt32(&s.critsection, 1) atomic.StoreInt32(&s.critsection, 1)
@ -924,6 +940,9 @@ func (s *SplitStore) compactFull(curTs *types.TipSet) error {
log.Infow("collection done", "took", time.Since(startCollect)) log.Infow("collection done", "took", time.Since(startCollect))
log.Infow("compaction stats", "hot", hotCnt, "cold", coldCnt, "dead", deadCnt) log.Infow("compaction stats", "hot", hotCnt, "cold", coldCnt, "dead", deadCnt)
stats.Record(context.Background(), metrics.SplitstoreCompactionHot.M(int64(hotCnt)))
stats.Record(context.Background(), metrics.SplitstoreCompactionCold.M(int64(coldCnt)))
stats.Record(context.Background(), metrics.SplitstoreCompactionDead.M(int64(deadCnt)))
// Enter critical section // Enter critical section
atomic.StoreInt32(&s.critsection, 1) atomic.StoreInt32(&s.critsection, 1)

View File

@ -82,6 +82,13 @@ var (
WorkerCallsReturnedCount = stats.Int64("sealing/worker_calls_returned_count", "Counter of returned worker tasks", stats.UnitDimensionless) WorkerCallsReturnedCount = stats.Int64("sealing/worker_calls_returned_count", "Counter of returned worker tasks", stats.UnitDimensionless)
WorkerCallsReturnedDuration = stats.Float64("sealing/worker_calls_returned_ms", "Counter of returned worker tasks", stats.UnitMilliseconds) WorkerCallsReturnedDuration = stats.Float64("sealing/worker_calls_returned_ms", "Counter of returned worker tasks", stats.UnitMilliseconds)
WorkerUntrackedCallsReturned = stats.Int64("sealing/worker_untracked_calls_returned", "Counter of returned untracked worker tasks", stats.UnitDimensionless) WorkerUntrackedCallsReturned = stats.Int64("sealing/worker_untracked_calls_returned", "Counter of returned untracked worker tasks", stats.UnitDimensionless)
// splitstore
SplitstoreMiss = stats.Int64("splitstore/miss", "Number of misses in hotstre access", stats.UnitDimensionless)
SplitstoreCompactionTimeSeconds = stats.Float64("splitstore/compaction_time", "Compaction time in seconds", stats.UnitSeconds)
SplitstoreCompactionHot = stats.Int64("splitstore/hot", "Number of hot blocks in last compaction", stats.UnitDimensionless)
SplitstoreCompactionCold = stats.Int64("splitstore/cold", "Number of cold blocks in last compaction", stats.UnitDimensionless)
SplitstoreCompactionDead = stats.Int64("splitstore/dead", "Number of dead blocks in last compaction", stats.UnitDimensionless)
) )
var ( var (
@ -222,6 +229,28 @@ var (
Aggregation: workMillisecondsDistribution, Aggregation: workMillisecondsDistribution,
TagKeys: []tag.Key{TaskType, WorkerHostname}, TagKeys: []tag.Key{TaskType, WorkerHostname},
} }
// splitstore
SplitstoreMissView = &view.View{
Measure: SplitstoreMiss,
Aggregation: view.Count(),
}
SplitstoreCompactionTimeSecondsView = &view.View{
Measure: SplitstoreCompactionTimeSeconds,
Aggregation: view.LastValue(),
}
SplitstoreCompactionHotView = &view.View{
Measure: SplitstoreCompactionHot,
Aggregation: view.LastValue(),
}
SplitstoreCompactionColdView = &view.View{
Measure: SplitstoreCompactionCold,
Aggregation: view.Sum(),
}
SplitstoreCompactionDeadView = &view.View{
Measure: SplitstoreCompactionDead,
Aggregation: view.Sum(),
}
) )
// DefaultViews is an array of OpenCensus views for metric gathering purposes // DefaultViews is an array of OpenCensus views for metric gathering purposes
@ -258,6 +287,11 @@ var ChainNodeViews = append([]*view.View{
PubsubDropRPCView, PubsubDropRPCView,
VMFlushCopyCountView, VMFlushCopyCountView,
VMFlushCopyDurationView, VMFlushCopyDurationView,
SplitstoreMissView,
SplitstoreCompactionTimeSecondsView,
SplitstoreCompactionHotView,
SplitstoreCompactionColdView,
SplitstoreCompactionDeadView,
}, DefaultViews...) }, DefaultViews...)
var MinerNodeViews = append([]*view.View{ var MinerNodeViews = append([]*view.View{