Merge remote-tracking branch 'origin/wb/abci-metrics' into wb/abci-metrics

This commit is contained in:
William Banfield
2021-10-13 12:41:13 -04:00
2 changed files with 12 additions and 5 deletions

View File

@@ -61,6 +61,9 @@ type Metrics struct {
// Number of blockparts transmitted by peer.
BlockParts metrics.Counter
// Histogram of time taken per step annotated with reason that the step proceeded.
StepTime metrics.Histogram
}
// PrometheusMetrics returns Metrics build using Prometheus client library.
@@ -187,6 +190,12 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
Name: "block_parts",
Help: "Number of blockparts transmitted by peer.",
}, append(labels, "peer_id")).With(labelsAndValues...),
StepTime: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "step_time",
Help: "Time spent per step.",
}, append(labels, "step", "reason")).With(labelsAndValues...),
}
}

View File

@@ -97,7 +97,7 @@ func (app *appConnConsensus) DeliverTxAsync(
ctx context.Context,
req types.RequestDeliverTx,
) (*abciclient.ReqRes, error) {
defer addTimeSample(app.metrics.MethodTiming.With("method", "deliver_tx", "type", "aync"))()
defer addTimeSample(app.metrics.MethodTiming.With("method", "deliver_tx", "type", "async"))()
return app.appConn.DeliverTxAsync(ctx, req)
}
@@ -138,7 +138,7 @@ func (app *appConnMempool) Error() error {
}
func (app *appConnMempool) FlushAsync(ctx context.Context) (*abciclient.ReqRes, error) {
defer addTimeSample(app.metrics.MethodTiming.With("method", "flush", "type", "sync"))()
defer addTimeSample(app.metrics.MethodTiming.With("method", "flush", "type", "async"))()
return app.appConn.FlushAsync(ctx)
}
@@ -148,9 +148,7 @@ func (app *appConnMempool) FlushSync(ctx context.Context) error {
}
func (app *appConnMempool) CheckTxAsync(ctx context.Context, req types.RequestCheckTx) (*abciclient.ReqRes, error) {
start := time.Now()
defer app.metrics.MethodTiming.With("method", "check_tx",
"type", "sync").Observe(time.Since(start).Seconds())
defer addTimeSample(app.metrics.MethodTiming.With("method", "check_tx", "type", "async"))()
return app.appConn.CheckTxAsync(ctx, req)
}