From 69845bb44e4f99886cb5042fbf03b1f418b3367f Mon Sep 17 00:00:00 2001 From: William Banfield <4561443+williambanfield@users.noreply.github.com> Date: Mon, 8 Aug 2022 15:55:01 -0400 Subject: [PATCH] metrics: fixup after cherry-pick (#9195) * fixup after cherry-pick * cherry-pick fixups --- consensus/metrics.gen.go | 12 ++++++------ consensus/metrics.go | 10 +++++----- consensus/state.go | 4 ++-- proxy/app_conn.go | 32 ++++++++++++++++---------------- proxy/metrics.gen.go | 6 +++--- proxy/metrics.go | 2 +- state/metrics.gen.go | 2 +- state/metrics.go | 2 +- 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/consensus/metrics.gen.go b/consensus/metrics.gen.go index ae9fefcc5..70be488ef 100644 --- a/consensus/metrics.gen.go +++ b/consensus/metrics.gen.go @@ -32,10 +32,10 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { Name: "rounds", Help: "Number of rounds.", }, labels).With(labelsAndValues...), - RoundDuration: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{ + RoundDurationSeconds: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{ Namespace: namespace, Subsystem: MetricsSubsystem, - Name: "round_duration", + Name: "round_duration_seconds", Help: "Histogram of round duration.", Buckets: stdprometheus.ExponentialBucketsRange(0.1, 100, 8), @@ -136,10 +136,10 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { Name: "block_parts", Help: "Number of block parts transmitted by each peer.", }, append(labels, "peer_id")).With(labelsAndValues...), - StepDuration: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{ + StepDurationSeconds: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{ Namespace: namespace, Subsystem: MetricsSubsystem, - Name: "step_duration", + Name: "step_duration_seconds", Help: "Histogram of durations for each step in the consensus protocol.", Buckets: stdprometheus.ExponentialBucketsRange(0.1, 100, 8), @@ -170,7 +170,7 @@ func NopMetrics() *Metrics { Height: discard.NewGauge(), ValidatorLastSignedHeight: discard.NewGauge(), Rounds: discard.NewGauge(), - RoundDuration: discard.NewHistogram(), + RoundDurationSeconds: discard.NewHistogram(), Validators: discard.NewGauge(), ValidatorsPower: discard.NewGauge(), ValidatorPower: discard.NewGauge(), @@ -187,7 +187,7 @@ func NopMetrics() *Metrics { FastSyncing: discard.NewGauge(), StateSyncing: discard.NewGauge(), BlockParts: discard.NewCounter(), - StepDuration: discard.NewHistogram(), + StepDurationSeconds: discard.NewHistogram(), BlockGossipPartsReceived: discard.NewCounter(), QuorumPrevoteDelay: discard.NewGauge(), FullPrevoteDelay: discard.NewGauge(), diff --git a/consensus/metrics.go b/consensus/metrics.go index 9c218bea4..de0da45de 100644 --- a/consensus/metrics.go +++ b/consensus/metrics.go @@ -29,7 +29,7 @@ type Metrics struct { Rounds metrics.Gauge // Histogram of round duration. - RoundDuration metrics.Histogram `metrics_buckettype:"exprange" metrics_bucketsizes:"0.1, 100, 8"` + RoundDurationSeconds metrics.Histogram `metrics_buckettype:"exprange" metrics_bucketsizes:"0.1, 100, 8"` // Number of validators. Validators metrics.Gauge @@ -68,8 +68,8 @@ type Metrics struct { BlockParts metrics.Counter `metrics_labels:"peer_id"` // Histogram of durations for each step in the consensus protocol. - StepDuration metrics.Histogram `metrics_labels:"step" metrics_buckettype:"exprange" metrics_bucketsizes:"0.1, 100, 8"` - stepStart time.Time + StepDurationSeconds metrics.Histogram `metrics_labels:"step" metrics_buckettype:"exprange" metrics_bucketsizes:"0.1, 100, 8"` + stepStart time.Time // Number of block parts received by the node, separated by whether the part // was relevant to the block the node is trying to gather or not. @@ -105,14 +105,14 @@ func (m *Metrics) RecordConsMetrics(block *types.Block) { func (m *Metrics) MarkRound(r int32, st time.Time) { m.Rounds.Set(float64(r)) roundTime := time.Since(st).Seconds() - m.RoundDuration.Observe(roundTime) + m.RoundDurationSeconds.Observe(roundTime) } func (m *Metrics) MarkStep(s cstypes.RoundStepType) { if !m.stepStart.IsZero() { stepTime := time.Since(m.stepStart).Seconds() stepName := strings.TrimPrefix(s.String(), "RoundStep") - m.StepDuration.With("step", stepName).Observe(stepTime) + m.StepDurationSeconds.With("step", stepName).Observe(stepTime) } m.stepStart = time.Now() } diff --git a/consensus/state.go b/consensus/state.go index 965621db3..20c406c05 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -2323,12 +2323,12 @@ func (cs *State) calculatePrevoteMessageDelayMetrics() { _, val := cs.Validators.GetByAddress(v.ValidatorAddress) votingPowerSeen += val.VotingPower if votingPowerSeen >= cs.Validators.TotalVotingPower()*2/3+1 { - cs.metrics.QuorumPrevoteDelay.Set(v.Timestamp.Sub(cs.Proposal.Timestamp).Seconds()) + cs.metrics.QuorumPrevoteDelay.With("proposer_address", cs.Validators.GetProposer().Address.String()).Set(v.Timestamp.Sub(cs.Proposal.Timestamp).Seconds()) break } } if ps.HasAll() { - cs.metrics.FullPrevoteDelay.Set(pl[len(pl)-1].Timestamp.Sub(cs.Proposal.Timestamp).Seconds()) + cs.metrics.FullPrevoteDelay.With("proposer_address", cs.Validators.GetProposer().Address.String()).Set(pl[len(pl)-1].Timestamp.Sub(cs.Proposal.Timestamp).Seconds()) } } diff --git a/proxy/app_conn.go b/proxy/app_conn.go index f25c33ce0..e69daba9d 100644 --- a/proxy/app_conn.go +++ b/proxy/app_conn.go @@ -79,27 +79,27 @@ func (app *appConnConsensus) Error() error { } func (app *appConnConsensus) InitChainSync(req types.RequestInitChain) (*types.ResponseInitChain, error) { - defer addTimeSample(app.metrics.MethodTiming.With("method", "init_chain", "type", "sync"))() + defer addTimeSample(app.metrics.MethodTimingSeconds.With("method", "init_chain", "type", "sync"))() return app.appConn.InitChainSync(req) } func (app *appConnConsensus) BeginBlockSync(req types.RequestBeginBlock) (*types.ResponseBeginBlock, error) { - defer addTimeSample(app.metrics.MethodTiming.With("method", "begin_block", "type", "sync"))() + defer addTimeSample(app.metrics.MethodTimingSeconds.With("method", "begin_block", "type", "sync"))() return app.appConn.BeginBlockSync(req) } func (app *appConnConsensus) DeliverTxAsync(req types.RequestDeliverTx) *abcicli.ReqRes { - defer addTimeSample(app.metrics.MethodTiming.With("method", "deliver_tx", "type", "async"))() + defer addTimeSample(app.metrics.MethodTimingSeconds.With("method", "deliver_tx", "type", "async"))() return app.appConn.DeliverTxAsync(req) } func (app *appConnConsensus) EndBlockSync(req types.RequestEndBlock) (*types.ResponseEndBlock, error) { - defer addTimeSample(app.metrics.MethodTiming.With("method", "end_block", "type", "sync"))() + defer addTimeSample(app.metrics.MethodTimingSeconds.With("method", "end_block", "type", "sync"))() return app.appConn.EndBlockSync(req) } func (app *appConnConsensus) CommitSync() (*types.ResponseCommit, error) { - defer addTimeSample(app.metrics.MethodTiming.With("method", "commit", "type", "sync"))() + defer addTimeSample(app.metrics.MethodTimingSeconds.With("method", "commit", "type", "sync"))() return app.appConn.CommitSync() } @@ -127,22 +127,22 @@ func (app *appConnMempool) Error() error { } func (app *appConnMempool) FlushAsync() *abcicli.ReqRes { - defer addTimeSample(app.metrics.MethodTiming.With("method", "flush", "type", "async"))() + defer addTimeSample(app.metrics.MethodTimingSeconds.With("method", "flush", "type", "async"))() return app.appConn.FlushAsync() } func (app *appConnMempool) FlushSync() error { - defer addTimeSample(app.metrics.MethodTiming.With("method", "flush", "type", "sync"))() + defer addTimeSample(app.metrics.MethodTimingSeconds.With("method", "flush", "type", "sync"))() return app.appConn.FlushSync() } func (app *appConnMempool) CheckTxAsync(req types.RequestCheckTx) *abcicli.ReqRes { - defer addTimeSample(app.metrics.MethodTiming.With("method", "check_tx", "type", "async"))() + defer addTimeSample(app.metrics.MethodTimingSeconds.With("method", "check_tx", "type", "async"))() return app.appConn.CheckTxAsync(req) } func (app *appConnMempool) CheckTxSync(req types.RequestCheckTx) (*types.ResponseCheckTx, error) { - defer addTimeSample(app.metrics.MethodTiming.With("method", "check_tx", "type", "sync"))() + defer addTimeSample(app.metrics.MethodTimingSeconds.With("method", "check_tx", "type", "sync"))() return app.appConn.CheckTxSync(req) } @@ -166,17 +166,17 @@ func (app *appConnQuery) Error() error { } func (app *appConnQuery) EchoSync(msg string) (*types.ResponseEcho, error) { - defer addTimeSample(app.metrics.MethodTiming.With("method", "echo", "type", "sync"))() + defer addTimeSample(app.metrics.MethodTimingSeconds.With("method", "echo", "type", "sync"))() return app.appConn.EchoSync(msg) } func (app *appConnQuery) InfoSync(req types.RequestInfo) (*types.ResponseInfo, error) { - defer addTimeSample(app.metrics.MethodTiming.With("method", "info", "type", "sync"))() + defer addTimeSample(app.metrics.MethodTimingSeconds.With("method", "info", "type", "sync"))() return app.appConn.InfoSync(req) } func (app *appConnQuery) QuerySync(reqQuery types.RequestQuery) (*types.ResponseQuery, error) { - defer addTimeSample(app.metrics.MethodTiming.With("method", "query", "type", "sync"))() + defer addTimeSample(app.metrics.MethodTimingSeconds.With("method", "query", "type", "sync"))() return app.appConn.QuerySync(reqQuery) } @@ -200,24 +200,24 @@ func (app *appConnSnapshot) Error() error { } func (app *appConnSnapshot) ListSnapshotsSync(req types.RequestListSnapshots) (*types.ResponseListSnapshots, error) { - defer addTimeSample(app.metrics.MethodTiming.With("method", "list_snapshots", "type", "sync"))() + defer addTimeSample(app.metrics.MethodTimingSeconds.With("method", "list_snapshots", "type", "sync"))() return app.appConn.ListSnapshotsSync(req) } func (app *appConnSnapshot) OfferSnapshotSync(req types.RequestOfferSnapshot) (*types.ResponseOfferSnapshot, error) { - defer addTimeSample(app.metrics.MethodTiming.With("method", "offer_snapshot", "type", "sync"))() + defer addTimeSample(app.metrics.MethodTimingSeconds.With("method", "offer_snapshot", "type", "sync"))() return app.appConn.OfferSnapshotSync(req) } func (app *appConnSnapshot) LoadSnapshotChunkSync( req types.RequestLoadSnapshotChunk) (*types.ResponseLoadSnapshotChunk, error) { - defer addTimeSample(app.metrics.MethodTiming.With("method", "load_snapshot_chunk", "type", "sync"))() + defer addTimeSample(app.metrics.MethodTimingSeconds.With("method", "load_snapshot_chunk", "type", "sync"))() return app.appConn.LoadSnapshotChunkSync(req) } func (app *appConnSnapshot) ApplySnapshotChunkSync( req types.RequestApplySnapshotChunk) (*types.ResponseApplySnapshotChunk, error) { - defer addTimeSample(app.metrics.MethodTiming.With("method", "apply_snapshot_chunk", "type", "sync"))() + defer addTimeSample(app.metrics.MethodTimingSeconds.With("method", "apply_snapshot_chunk", "type", "sync"))() return app.appConn.ApplySnapshotChunkSync(req) } diff --git a/proxy/metrics.gen.go b/proxy/metrics.gen.go index ea483f83d..f4387ca9c 100644 --- a/proxy/metrics.gen.go +++ b/proxy/metrics.gen.go @@ -14,10 +14,10 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { labels = append(labels, labelsAndValues[i]) } return &Metrics{ - MethodTiming: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{ + MethodTimingSeconds: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{ Namespace: namespace, Subsystem: MetricsSubsystem, - Name: "method_timing", + Name: "method_timing_seconds", Help: "Timing for each ABCI method.", Buckets: []float64{.0001, .0004, .002, .009, .02, .1, .65, 2, 6, 25}, @@ -27,6 +27,6 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { func NopMetrics() *Metrics { return &Metrics{ - MethodTiming: discard.NewHistogram(), + MethodTimingSeconds: discard.NewHistogram(), } } diff --git a/proxy/metrics.go b/proxy/metrics.go index 589dc4db1..7858c3bc5 100644 --- a/proxy/metrics.go +++ b/proxy/metrics.go @@ -15,5 +15,5 @@ const ( // Metrics contains the prometheus metrics exposed by the proxy package. type Metrics struct { // Timing for each ABCI method. - MethodTiming metrics.Histogram `metrics_bucketsizes:".0001,.0004,.002,.009,.02,.1,.65,2,6,25" metrics_labels:"method, type"` + MethodTimingSeconds metrics.Histogram `metrics_bucketsizes:".0001,.0004,.002,.009,.02,.1,.65,2,6,25" metrics_labels:"method, type"` } diff --git a/state/metrics.gen.go b/state/metrics.gen.go index 046db2ef4..288f1d7cf 100644 --- a/state/metrics.gen.go +++ b/state/metrics.gen.go @@ -20,7 +20,7 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { Name: "block_processing_time", Help: "Time between BeginBlock and EndBlock in ms.", - Buckets: []float64{1, 10, 10}, + Buckets: stdprometheus.LinearBuckets(1, 10, 10), }, labels).With(labelsAndValues...), } } diff --git a/state/metrics.go b/state/metrics.go index 81a628cc9..72712144f 100644 --- a/state/metrics.go +++ b/state/metrics.go @@ -15,5 +15,5 @@ const ( // Metrics contains metrics exposed by this package. type Metrics struct { // Time between BeginBlock and EndBlock in ms. - BlockProcessingTime metrics.Histogram `metrics_buckettype:"linear" metrics_bucketsizes:"1, 10, 10"` + BlockProcessingTime metrics.Histogram `metrics_buckettype:"lin" metrics_bucketsizes:"1, 10, 10"` }