Change block validation aggregation type from sum to distribution
This commit is contained in:
parent
5af537147d
commit
9207315b25
@ -634,10 +634,8 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) (er
|
|||||||
|
|
||||||
validationStart := build.Clock.Now()
|
validationStart := build.Clock.Now()
|
||||||
defer func() {
|
defer func() {
|
||||||
dur := time.Since(validationStart)
|
stats.Record(ctx, metrics.BlockValidationDurationMilliseconds.M(metrics.SinceInMilliseconds(validationStart)))
|
||||||
durMilli := dur.Seconds() * float64(1000)
|
log.Infow("block validation", "took", time.Since(validationStart), "height", b.Header.Height)
|
||||||
stats.Record(ctx, metrics.BlockValidationDurationMilliseconds.M(durMilli))
|
|
||||||
log.Infow("block validation", "took", dur, "height", b.Header.Height)
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
ctx, span := trace.StartSpan(ctx, "validateBlock")
|
ctx, span := trace.StartSpan(ctx, "validateBlock")
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package metrics
|
package metrics
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"go.opencensus.io/stats"
|
"go.opencensus.io/stats"
|
||||||
"go.opencensus.io/stats/view"
|
"go.opencensus.io/stats/view"
|
||||||
"go.opencensus.io/tag"
|
"go.opencensus.io/tag"
|
||||||
@ -8,6 +10,9 @@ import (
|
|||||||
rpcmetrics "github.com/filecoin-project/go-jsonrpc/metrics"
|
rpcmetrics "github.com/filecoin-project/go-jsonrpc/metrics"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Distribution
|
||||||
|
var defaultMillisecondsDistribution = view.Distribution(0.01, 0.05, 0.1, 0.3, 0.6, 0.8, 1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 25, 30, 40, 50, 65, 80, 100, 130, 160, 200, 250, 300, 400, 500, 650, 800, 1000, 2000, 5000, 10000, 20000, 50000, 100000)
|
||||||
|
|
||||||
// Global Tags
|
// Global Tags
|
||||||
var (
|
var (
|
||||||
Version, _ = tag.NewKey("version")
|
Version, _ = tag.NewKey("version")
|
||||||
@ -66,7 +71,7 @@ var (
|
|||||||
}
|
}
|
||||||
BlockValidationDurationView = &view.View{
|
BlockValidationDurationView = &view.View{
|
||||||
Measure: BlockValidationDurationMilliseconds,
|
Measure: BlockValidationDurationMilliseconds,
|
||||||
Aggregation: view.Sum(),
|
Aggregation: defaultMillisecondsDistribution,
|
||||||
}
|
}
|
||||||
MessageReceivedView = &view.View{
|
MessageReceivedView = &view.View{
|
||||||
Measure: MessageReceived,
|
Measure: MessageReceived,
|
||||||
@ -99,4 +104,11 @@ var DefaultViews = append([]*view.View{
|
|||||||
MessageReceivedView,
|
MessageReceivedView,
|
||||||
MessageValidationFailureView,
|
MessageValidationFailureView,
|
||||||
MessageValidationSuccessView,
|
MessageValidationSuccessView,
|
||||||
PeerCountView}, rpcmetrics.DefaultViews...)
|
PeerCountView,
|
||||||
|
},
|
||||||
|
rpcmetrics.DefaultViews...)
|
||||||
|
|
||||||
|
// SinceInMilliseconds returns the duration of time since the provide time as a float64.
|
||||||
|
func SinceInMilliseconds(startTime time.Time) float64 {
|
||||||
|
return float64(time.Since(startTime).Nanoseconds()) / 1e6
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user