|
@ -1,9 +1,13 @@ |
|
|
package consensus |
|
|
package consensus |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
|
|
|
"strings" |
|
|
|
|
|
"time" |
|
|
|
|
|
|
|
|
"github.com/go-kit/kit/metrics" |
|
|
"github.com/go-kit/kit/metrics" |
|
|
"github.com/go-kit/kit/metrics/discard" |
|
|
"github.com/go-kit/kit/metrics/discard" |
|
|
|
|
|
|
|
|
|
|
|
cstypes "github.com/tendermint/tendermint/internal/consensus/types" |
|
|
"github.com/tendermint/tendermint/types" |
|
|
"github.com/tendermint/tendermint/types" |
|
|
|
|
|
|
|
|
prometheus "github.com/go-kit/kit/metrics/prometheus" |
|
|
prometheus "github.com/go-kit/kit/metrics/prometheus" |
|
@ -27,6 +31,9 @@ type Metrics struct { |
|
|
// Number of rounds.
|
|
|
// Number of rounds.
|
|
|
Rounds metrics.Gauge |
|
|
Rounds metrics.Gauge |
|
|
|
|
|
|
|
|
|
|
|
// Histogram of round duration.
|
|
|
|
|
|
RoundDuration metrics.Histogram |
|
|
|
|
|
|
|
|
// Number of validators.
|
|
|
// Number of validators.
|
|
|
Validators metrics.Gauge |
|
|
Validators metrics.Gauge |
|
|
// Total power of all validators.
|
|
|
// Total power of all validators.
|
|
@ -63,8 +70,18 @@ type Metrics struct { |
|
|
// Number of blockparts transmitted by peer.
|
|
|
// Number of blockparts transmitted by peer.
|
|
|
BlockParts metrics.Counter |
|
|
BlockParts metrics.Counter |
|
|
|
|
|
|
|
|
// Histogram of time taken per step annotated with reason that the step proceeded.
|
|
|
|
|
|
StepTime metrics.Histogram |
|
|
|
|
|
|
|
|
// Histogram of step duration.
|
|
|
|
|
|
StepDuration metrics.Histogram |
|
|
|
|
|
stepStart time.Time |
|
|
|
|
|
|
|
|
|
|
|
// Histogram of time taken to receive a block in seconds, measured between when a new block is first
|
|
|
|
|
|
// discovered to when the block is completed.
|
|
|
|
|
|
BlockGossipReceiveLatency metrics.Histogram |
|
|
|
|
|
blockGossipStart 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.
|
|
|
|
|
|
BlockGossipPartsReceived metrics.Counter |
|
|
|
|
|
|
|
|
// QuroumPrevoteMessageDelay is the interval in seconds between the proposal
|
|
|
// QuroumPrevoteMessageDelay is the interval in seconds between the proposal
|
|
|
// timestamp and the timestamp of the earliest prevote that achieved a quorum
|
|
|
// timestamp and the timestamp of the earliest prevote that achieved a quorum
|
|
@ -109,7 +126,13 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { |
|
|
Name: "rounds", |
|
|
Name: "rounds", |
|
|
Help: "Number of rounds.", |
|
|
Help: "Number of rounds.", |
|
|
}, labels).With(labelsAndValues...), |
|
|
}, labels).With(labelsAndValues...), |
|
|
|
|
|
|
|
|
|
|
|
RoundDuration: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{ |
|
|
|
|
|
Namespace: namespace, |
|
|
|
|
|
Subsystem: MetricsSubsystem, |
|
|
|
|
|
Name: "round_duration", |
|
|
|
|
|
Help: "Time spent in a round.", |
|
|
|
|
|
Buckets: stdprometheus.ExponentialBucketsRange(0.1, 100, 8), |
|
|
|
|
|
}, labels).With(labelsAndValues...), |
|
|
Validators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ |
|
|
Validators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ |
|
|
Namespace: namespace, |
|
|
Namespace: namespace, |
|
|
Subsystem: MetricsSubsystem, |
|
|
Subsystem: MetricsSubsystem, |
|
@ -212,12 +235,28 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { |
|
|
Name: "block_parts", |
|
|
Name: "block_parts", |
|
|
Help: "Number of blockparts transmitted by peer.", |
|
|
Help: "Number of blockparts transmitted by peer.", |
|
|
}, append(labels, "peer_id")).With(labelsAndValues...), |
|
|
}, append(labels, "peer_id")).With(labelsAndValues...), |
|
|
StepTime: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{ |
|
|
|
|
|
|
|
|
BlockGossipReceiveLatency: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{ |
|
|
|
|
|
Namespace: namespace, |
|
|
|
|
|
Subsystem: MetricsSubsystem, |
|
|
|
|
|
Name: "block_gossip_receive_latency", |
|
|
|
|
|
Help: "Difference in seconds between when the validator learns of a new block" + |
|
|
|
|
|
"and when the validator receives the last piece of the block.", |
|
|
|
|
|
Buckets: stdprometheus.ExponentialBucketsRange(0.1, 100, 8), |
|
|
|
|
|
}, labels).With(labelsAndValues...), |
|
|
|
|
|
BlockGossipPartsReceived: prometheus.NewCounterFrom(stdprometheus.CounterOpts{ |
|
|
Namespace: namespace, |
|
|
Namespace: namespace, |
|
|
Subsystem: MetricsSubsystem, |
|
|
Subsystem: MetricsSubsystem, |
|
|
Name: "step_time", |
|
|
|
|
|
|
|
|
Name: "block_gossip_parts_received", |
|
|
|
|
|
Help: "Number of block parts received by the node, labeled by whether the " + |
|
|
|
|
|
"part was relevant to the block the node was currently gathering or not.", |
|
|
|
|
|
}, append(labels, "matches_current")).With(labelsAndValues...), |
|
|
|
|
|
StepDuration: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{ |
|
|
|
|
|
Namespace: namespace, |
|
|
|
|
|
Subsystem: MetricsSubsystem, |
|
|
|
|
|
Name: "step_duration", |
|
|
Help: "Time spent per step.", |
|
|
Help: "Time spent per step.", |
|
|
}, append(labels, "step", "reason")).With(labelsAndValues...), |
|
|
|
|
|
|
|
|
Buckets: stdprometheus.ExponentialBucketsRange(0.1, 100, 8), |
|
|
|
|
|
}, append(labels, "step")).With(labelsAndValues...), |
|
|
QuorumPrevoteMessageDelay: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ |
|
|
QuorumPrevoteMessageDelay: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ |
|
|
Namespace: namespace, |
|
|
Namespace: namespace, |
|
|
Subsystem: MetricsSubsystem, |
|
|
Subsystem: MetricsSubsystem, |
|
@ -251,7 +290,9 @@ func NopMetrics() *Metrics { |
|
|
|
|
|
|
|
|
ValidatorLastSignedHeight: discard.NewGauge(), |
|
|
ValidatorLastSignedHeight: discard.NewGauge(), |
|
|
|
|
|
|
|
|
Rounds: discard.NewGauge(), |
|
|
|
|
|
|
|
|
Rounds: discard.NewGauge(), |
|
|
|
|
|
RoundDuration: discard.NewHistogram(), |
|
|
|
|
|
StepDuration: discard.NewHistogram(), |
|
|
|
|
|
|
|
|
Validators: discard.NewGauge(), |
|
|
Validators: discard.NewGauge(), |
|
|
ValidatorsPower: discard.NewGauge(), |
|
|
ValidatorsPower: discard.NewGauge(), |
|
@ -271,6 +312,8 @@ func NopMetrics() *Metrics { |
|
|
BlockSyncing: discard.NewGauge(), |
|
|
BlockSyncing: discard.NewGauge(), |
|
|
StateSyncing: discard.NewGauge(), |
|
|
StateSyncing: discard.NewGauge(), |
|
|
BlockParts: discard.NewCounter(), |
|
|
BlockParts: discard.NewCounter(), |
|
|
|
|
|
BlockGossipReceiveLatency: discard.NewHistogram(), |
|
|
|
|
|
BlockGossipPartsReceived: discard.NewCounter(), |
|
|
QuorumPrevoteMessageDelay: discard.NewGauge(), |
|
|
QuorumPrevoteMessageDelay: discard.NewGauge(), |
|
|
FullPrevoteMessageDelay: discard.NewGauge(), |
|
|
FullPrevoteMessageDelay: discard.NewGauge(), |
|
|
ProposalTimestampDifference: discard.NewHistogram(), |
|
|
ProposalTimestampDifference: discard.NewHistogram(), |
|
@ -284,3 +327,26 @@ func (m *Metrics) RecordConsMetrics(block *types.Block) { |
|
|
m.BlockSizeBytes.Observe(float64(block.Size())) |
|
|
m.BlockSizeBytes.Observe(float64(block.Size())) |
|
|
m.CommittedHeight.Set(float64(block.Height)) |
|
|
m.CommittedHeight.Set(float64(block.Height)) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (m *Metrics) MarkBlockGossipStarted() { |
|
|
|
|
|
m.blockGossipStart = time.Now() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (m *Metrics) MarkBlockGossipComplete() { |
|
|
|
|
|
m.BlockGossipReceiveLatency.Observe(time.Since(m.blockGossipStart).Seconds()) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (m *Metrics) MarkRound(r int32, st time.Time) { |
|
|
|
|
|
m.Rounds.Set(float64(r)) |
|
|
|
|
|
roundTime := time.Since(st).Seconds() |
|
|
|
|
|
m.RoundDuration.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.stepStart = time.Now() |
|
|
|
|
|
} |