mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-08 14:21:14 +00:00
This pull request completes the change to the `metricsgen` metrics. It adds `go generate` directives to all of the files containing the `Metrics` structs.
Using the outputs of `metricsdiff` between these generated metrics and `main`, we can see that there is a minimal diff between the two sets of metrics when run locally. The diff here stems from removal of the word 'message' which was done in v0.36+ and is ultimately a better phrasing. This metric has not yet been released, so this phrasing is preferred.
```
./metricsdiff old new
Metric changes:
+++ tendermint_consensus_full_prevote_delay
+++ tendermint_consensus_quorum_prevote_delay
--- tendermint_consensus_full_prevote_message_delay
--- tendermint_consensus_quorum_prevote_message_delay
```
This change also adds parsing for a `metrics:` key in a field comment. If a comment line begins with `//metrics:` the rest of the line is interpreted to be the metric help text. Additionally, a bug where lists of labels were not properly quoted in the `metricsgen` rendered output was fixed.
In my view, docs and tests are not needed for this internal only change.
---
#### PR checklist
- [ ] Tests written/updated, or no tests needed
- [ ] `CHANGELOG_PENDING.md` updated, or no changelog entry needed
- [ ] Updated relevant documentation (`docs/`) and code comments, or no
documentation updates needed
Ports #8488 to main
196 lines
8.2 KiB
Go
196 lines
8.2 KiB
Go
// Code generated by metricsgen. DO NOT EDIT.
|
|
|
|
package consensus
|
|
|
|
import (
|
|
"github.com/go-kit/kit/metrics/discard"
|
|
prometheus "github.com/go-kit/kit/metrics/prometheus"
|
|
stdprometheus "github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
|
|
labels := []string{}
|
|
for i := 0; i < len(labelsAndValues); i += 2 {
|
|
labels = append(labels, labelsAndValues[i])
|
|
}
|
|
return &Metrics{
|
|
Height: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "height",
|
|
Help: "Height of the chain.",
|
|
}, labels).With(labelsAndValues...),
|
|
ValidatorLastSignedHeight: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "validator_last_signed_height",
|
|
Help: "Last height signed by this validator if the node is a validator.",
|
|
}, append(labels, "validator_address")).With(labelsAndValues...),
|
|
Rounds: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "rounds",
|
|
Help: "Number of rounds.",
|
|
}, labels).With(labelsAndValues...),
|
|
RoundDuration: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "round_duration",
|
|
Help: "Histogram of round duration.",
|
|
|
|
Buckets: stdprometheus.ExponentialBucketsRange(0.1, 100, 8),
|
|
}, labels).With(labelsAndValues...),
|
|
Validators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "validators",
|
|
Help: "Number of validators.",
|
|
}, labels).With(labelsAndValues...),
|
|
ValidatorsPower: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "validators_power",
|
|
Help: "Total power of all validators.",
|
|
}, labels).With(labelsAndValues...),
|
|
ValidatorPower: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "validator_power",
|
|
Help: "Power of a validator.",
|
|
}, append(labels, "validator_address")).With(labelsAndValues...),
|
|
ValidatorMissedBlocks: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "validator_missed_blocks",
|
|
Help: "Amount of blocks missed per validator.",
|
|
}, append(labels, "validator_address")).With(labelsAndValues...),
|
|
MissingValidators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "missing_validators",
|
|
Help: "Number of validators who did not sign.",
|
|
}, labels).With(labelsAndValues...),
|
|
MissingValidatorsPower: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "missing_validators_power",
|
|
Help: "Total power of the missing validators.",
|
|
}, labels).With(labelsAndValues...),
|
|
ByzantineValidators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "byzantine_validators",
|
|
Help: "Number of validators who tried to double sign.",
|
|
}, labels).With(labelsAndValues...),
|
|
ByzantineValidatorsPower: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "byzantine_validators_power",
|
|
Help: "Total power of the byzantine validators.",
|
|
}, labels).With(labelsAndValues...),
|
|
BlockIntervalSeconds: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "block_interval_seconds",
|
|
Help: "Time between this and the last block.",
|
|
}, labels).With(labelsAndValues...),
|
|
NumTxs: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "num_txs",
|
|
Help: "Number of transactions.",
|
|
}, labels).With(labelsAndValues...),
|
|
BlockSizeBytes: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "block_size_bytes",
|
|
Help: "Size of the block.",
|
|
}, labels).With(labelsAndValues...),
|
|
TotalTxs: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "total_txs",
|
|
Help: "Total number of transactions.",
|
|
}, labels).With(labelsAndValues...),
|
|
CommittedHeight: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "latest_block_height",
|
|
Help: "The latest block height.",
|
|
}, labels).With(labelsAndValues...),
|
|
FastSyncing: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "fast_syncing",
|
|
Help: "Whether or not a node is fast syncing. 1 if yes, 0 if no.",
|
|
}, labels).With(labelsAndValues...),
|
|
StateSyncing: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "state_syncing",
|
|
Help: "Whether or not a node is state syncing. 1 if yes, 0 if no.",
|
|
}, labels).With(labelsAndValues...),
|
|
BlockParts: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "block_parts",
|
|
Help: "Number of block parts transmitted by each peer.",
|
|
}, append(labels, "peer_id")).With(labelsAndValues...),
|
|
StepDuration: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "step_duration",
|
|
Help: "Histogram of durations for each step in the consensus protocol.",
|
|
|
|
Buckets: stdprometheus.ExponentialBucketsRange(0.1, 100, 8),
|
|
}, append(labels, "step")).With(labelsAndValues...),
|
|
BlockGossipPartsReceived: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "block_gossip_parts_received",
|
|
Help: "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.",
|
|
}, append(labels, "matches_current")).With(labelsAndValues...),
|
|
QuorumPrevoteDelay: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "quorum_prevote_delay",
|
|
Help: "Interval in seconds between the proposal timestamp and the timestamp of the earliest prevote that achieved a quorum.",
|
|
}, append(labels, "proposer_address")).With(labelsAndValues...),
|
|
FullPrevoteDelay: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "full_prevote_delay",
|
|
Help: "Interval in seconds between the proposal timestamp and the timestamp of the latest prevote in a round where all validators voted.",
|
|
}, append(labels, "proposer_address")).With(labelsAndValues...),
|
|
}
|
|
}
|
|
|
|
func NopMetrics() *Metrics {
|
|
return &Metrics{
|
|
Height: discard.NewGauge(),
|
|
ValidatorLastSignedHeight: discard.NewGauge(),
|
|
Rounds: discard.NewGauge(),
|
|
RoundDuration: discard.NewHistogram(),
|
|
Validators: discard.NewGauge(),
|
|
ValidatorsPower: discard.NewGauge(),
|
|
ValidatorPower: discard.NewGauge(),
|
|
ValidatorMissedBlocks: discard.NewGauge(),
|
|
MissingValidators: discard.NewGauge(),
|
|
MissingValidatorsPower: discard.NewGauge(),
|
|
ByzantineValidators: discard.NewGauge(),
|
|
ByzantineValidatorsPower: discard.NewGauge(),
|
|
BlockIntervalSeconds: discard.NewHistogram(),
|
|
NumTxs: discard.NewGauge(),
|
|
BlockSizeBytes: discard.NewGauge(),
|
|
TotalTxs: discard.NewGauge(),
|
|
CommittedHeight: discard.NewGauge(),
|
|
FastSyncing: discard.NewGauge(),
|
|
StateSyncing: discard.NewGauge(),
|
|
BlockParts: discard.NewCounter(),
|
|
StepDuration: discard.NewHistogram(),
|
|
BlockGossipPartsReceived: discard.NewCounter(),
|
|
QuorumPrevoteDelay: discard.NewGauge(),
|
|
FullPrevoteDelay: discard.NewGauge(),
|
|
}
|
|
}
|