mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-06 05:25:35 +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
This commit is contained in:
committed by
Sam Ricotta
parent
692dcef140
commit
0a7be048f0
195
consensus/metrics.gen.go
Normal file
195
consensus/metrics.gen.go
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
// 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(),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,12 +5,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-kit/kit/metrics"
|
"github.com/go-kit/kit/metrics"
|
||||||
"github.com/go-kit/kit/metrics/discard"
|
|
||||||
cstypes "github.com/tendermint/tendermint/consensus/types"
|
cstypes "github.com/tendermint/tendermint/consensus/types"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
|
|
||||||
prometheus "github.com/go-kit/kit/metrics/prometheus"
|
|
||||||
stdprometheus "github.com/prometheus/client_golang/prometheus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -19,28 +15,30 @@ const (
|
|||||||
MetricsSubsystem = "consensus"
|
MetricsSubsystem = "consensus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate go run ../scripts/metricsgen -struct=Metrics
|
||||||
|
|
||||||
// Metrics contains metrics exposed by this package.
|
// Metrics contains metrics exposed by this package.
|
||||||
type Metrics struct {
|
type Metrics struct {
|
||||||
// Height of the chain.
|
// Height of the chain.
|
||||||
Height metrics.Gauge
|
Height metrics.Gauge
|
||||||
|
|
||||||
// ValidatorLastSignedHeight of a validator.
|
// Last height signed by this validator if the node is a validator.
|
||||||
ValidatorLastSignedHeight metrics.Gauge
|
ValidatorLastSignedHeight metrics.Gauge `metrics_labels:"validator_address"`
|
||||||
|
|
||||||
// Number of rounds.
|
// Number of rounds.
|
||||||
Rounds metrics.Gauge
|
Rounds metrics.Gauge
|
||||||
|
|
||||||
// Histogram of round duration.
|
// Histogram of round duration.
|
||||||
RoundDuration metrics.Histogram
|
RoundDuration metrics.Histogram `metrics_buckettype:"exprange" metrics_bucketsizes:"0.1, 100, 8"`
|
||||||
|
|
||||||
// Number of validators.
|
// Number of validators.
|
||||||
Validators metrics.Gauge
|
Validators metrics.Gauge
|
||||||
// Total power of all validators.
|
// Total power of all validators.
|
||||||
ValidatorsPower metrics.Gauge
|
ValidatorsPower metrics.Gauge
|
||||||
// Power of a validator.
|
// Power of a validator.
|
||||||
ValidatorPower metrics.Gauge
|
ValidatorPower metrics.Gauge `metrics_labels:"validator_address"`
|
||||||
// Amount of blocks missed by a validator.
|
// Amount of blocks missed per validator.
|
||||||
ValidatorMissedBlocks metrics.Gauge
|
ValidatorMissedBlocks metrics.Gauge `metrics_labels:"validator_address"`
|
||||||
// Number of validators who did not sign.
|
// Number of validators who did not sign.
|
||||||
MissingValidators metrics.Gauge
|
MissingValidators metrics.Gauge
|
||||||
// Total power of the missing validators.
|
// Total power of the missing validators.
|
||||||
@@ -60,22 +58,22 @@ type Metrics struct {
|
|||||||
// Total number of transactions.
|
// Total number of transactions.
|
||||||
TotalTxs metrics.Gauge
|
TotalTxs metrics.Gauge
|
||||||
// The latest block height.
|
// The latest block height.
|
||||||
CommittedHeight metrics.Gauge
|
CommittedHeight metrics.Gauge `metrics_name:"latest_block_height"`
|
||||||
// Whether or not a node is fast syncing. 1 if yes, 0 if no.
|
// Whether or not a node is fast syncing. 1 if yes, 0 if no.
|
||||||
FastSyncing metrics.Gauge
|
FastSyncing metrics.Gauge
|
||||||
// Whether or not a node is state syncing. 1 if yes, 0 if no.
|
// Whether or not a node is state syncing. 1 if yes, 0 if no.
|
||||||
StateSyncing metrics.Gauge
|
StateSyncing metrics.Gauge
|
||||||
|
|
||||||
// Number of blockparts transmitted by peer.
|
// Number of block parts transmitted by each peer.
|
||||||
BlockParts metrics.Counter
|
BlockParts metrics.Counter `metrics_labels:"peer_id"`
|
||||||
|
|
||||||
// Histogram of step duration.
|
// Histogram of durations for each step in the consensus protocol.
|
||||||
StepDuration metrics.Histogram
|
StepDuration metrics.Histogram `metrics_labels:"step" metrics_buckettype:"exprange" metrics_bucketsizes:"0.1, 100, 8"`
|
||||||
stepStart time.Time
|
stepStart time.Time
|
||||||
|
|
||||||
// Number of block parts received by the node, separated by whether the part
|
// 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.
|
// was relevant to the block the node is trying to gather or not.
|
||||||
BlockGossipPartsReceived metrics.Counter
|
BlockGossipPartsReceived metrics.Counter `metrics_labels:"matches_current"`
|
||||||
|
|
||||||
// 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
|
||||||
@@ -86,208 +84,14 @@ type Metrics struct {
|
|||||||
// be above 2/3 of the total voting power of the network defines the endpoint
|
// be above 2/3 of the total voting power of the network defines the endpoint
|
||||||
// the endpoint of the interval. Subtract the proposal timestamp from this endpoint
|
// the endpoint of the interval. Subtract the proposal timestamp from this endpoint
|
||||||
// to obtain the quorum delay.
|
// to obtain the quorum delay.
|
||||||
QuorumPrevoteMessageDelay metrics.Gauge
|
//metrics:Interval in seconds between the proposal timestamp and the timestamp of the earliest prevote that achieved a quorum.
|
||||||
|
QuorumPrevoteDelay metrics.Gauge `metrics_labels:"proposer_address"`
|
||||||
|
|
||||||
// FullPrevoteMessageDelay is the interval in seconds between the proposal
|
// FullPrevoteDelay is the interval in seconds between the proposal
|
||||||
// timestamp and the timestamp of the latest prevote in a round where 100%
|
// timestamp and the timestamp of the latest prevote in a round where 100%
|
||||||
// of the voting power on the network issued prevotes.
|
// of the voting power on the network issued prevotes.
|
||||||
FullPrevoteMessageDelay metrics.Gauge
|
//metrics:Interval in seconds between the proposal timestamp and the timestamp of the latest prevote in a round where all validators voted.
|
||||||
}
|
FullPrevoteDelay metrics.Gauge `metrics_labels:"proposer_address"`
|
||||||
|
|
||||||
// PrometheusMetrics returns Metrics build using Prometheus client library.
|
|
||||||
// Optionally, labels can be provided along with their values ("foo",
|
|
||||||
// "fooValue").
|
|
||||||
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...),
|
|
||||||
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_seconds",
|
|
||||||
Help: "Time spent in a round.",
|
|
||||||
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...),
|
|
||||||
ValidatorLastSignedHeight: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: MetricsSubsystem,
|
|
||||||
Name: "validator_last_signed_height",
|
|
||||||
Help: "Last signed height for a validator",
|
|
||||||
}, append(labels, "validator_address")).With(labelsAndValues...),
|
|
||||||
ValidatorMissedBlocks: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: MetricsSubsystem,
|
|
||||||
Name: "validator_missed_blocks",
|
|
||||||
Help: "Total missed blocks for a validator",
|
|
||||||
}, append(labels, "validator_address")).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...),
|
|
||||||
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 blockparts transmitted by peer.",
|
|
||||||
}, append(labels, "peer_id")).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, 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_seconds",
|
|
||||||
Help: "Time spent per step.",
|
|
||||||
Buckets: stdprometheus.ExponentialBucketsRange(0.1, 100, 8),
|
|
||||||
}, append(labels, "step")).With(labelsAndValues...),
|
|
||||||
QuorumPrevoteMessageDelay: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: MetricsSubsystem,
|
|
||||||
Name: "quorum_prevote_message_delay",
|
|
||||||
Help: "Difference in seconds between the proposal timestamp and the timestamp " +
|
|
||||||
"of the latest prevote that achieved a quorum in the prevote step.",
|
|
||||||
}, labels).With(labelsAndValues...),
|
|
||||||
FullPrevoteMessageDelay: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: MetricsSubsystem,
|
|
||||||
Name: "full_prevote_message_delay",
|
|
||||||
Help: "Difference in seconds between the proposal timestamp and the timestamp " +
|
|
||||||
"of the latest prevote that achieved 100% of the voting power in the prevote step.",
|
|
||||||
}, labels).With(labelsAndValues...),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NopMetrics returns no-op Metrics.
|
|
||||||
func NopMetrics() *Metrics {
|
|
||||||
return &Metrics{
|
|
||||||
Height: discard.NewGauge(),
|
|
||||||
|
|
||||||
ValidatorLastSignedHeight: discard.NewGauge(),
|
|
||||||
|
|
||||||
Rounds: discard.NewGauge(),
|
|
||||||
RoundDuration: discard.NewHistogram(),
|
|
||||||
StepDuration: 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(),
|
|
||||||
BlockGossipPartsReceived: discard.NewCounter(),
|
|
||||||
QuorumPrevoteMessageDelay: discard.NewGauge(),
|
|
||||||
FullPrevoteMessageDelay: discard.NewGauge(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RecordConsMetrics uses for recording the block related metrics during fast-sync.
|
// RecordConsMetrics uses for recording the block related metrics during fast-sync.
|
||||||
|
|||||||
@@ -2323,12 +2323,12 @@ func (cs *State) calculatePrevoteMessageDelayMetrics() {
|
|||||||
_, val := cs.Validators.GetByAddress(v.ValidatorAddress)
|
_, val := cs.Validators.GetByAddress(v.ValidatorAddress)
|
||||||
votingPowerSeen += val.VotingPower
|
votingPowerSeen += val.VotingPower
|
||||||
if votingPowerSeen >= cs.Validators.TotalVotingPower()*2/3+1 {
|
if votingPowerSeen >= cs.Validators.TotalVotingPower()*2/3+1 {
|
||||||
cs.metrics.QuorumPrevoteMessageDelay.Set(v.Timestamp.Sub(cs.Proposal.Timestamp).Seconds())
|
cs.metrics.QuorumPrevoteDelay.Set(v.Timestamp.Sub(cs.Proposal.Timestamp).Seconds())
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ps.HasAll() {
|
if ps.HasAll() {
|
||||||
cs.metrics.FullPrevoteMessageDelay.Set(pl[len(pl)-1].Timestamp.Sub(cs.Proposal.Timestamp).Seconds())
|
cs.metrics.FullPrevoteDelay.Set(pl[len(pl)-1].Timestamp.Sub(cs.Proposal.Timestamp).Seconds())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
67
mempool/metrics.gen.go
Normal file
67
mempool/metrics.gen.go
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
// Code generated by metricsgen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package mempool
|
||||||
|
|
||||||
|
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{
|
||||||
|
Size: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: MetricsSubsystem,
|
||||||
|
Name: "size",
|
||||||
|
Help: "Number of uncommitted transactions in the mempool.",
|
||||||
|
}, labels).With(labelsAndValues...),
|
||||||
|
TxSizeBytes: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: MetricsSubsystem,
|
||||||
|
Name: "tx_size_bytes",
|
||||||
|
Help: "Histogram of transaction sizes in bytes.",
|
||||||
|
|
||||||
|
Buckets: stdprometheus.ExponentialBuckets(1, 3, 7),
|
||||||
|
}, labels).With(labelsAndValues...),
|
||||||
|
FailedTxs: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: MetricsSubsystem,
|
||||||
|
Name: "failed_txs",
|
||||||
|
Help: "Number of failed transactions.",
|
||||||
|
}, labels).With(labelsAndValues...),
|
||||||
|
RejectedTxs: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: MetricsSubsystem,
|
||||||
|
Name: "rejected_txs",
|
||||||
|
Help: "Number of rejected transactions.",
|
||||||
|
}, labels).With(labelsAndValues...),
|
||||||
|
EvictedTxs: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: MetricsSubsystem,
|
||||||
|
Name: "evicted_txs",
|
||||||
|
Help: "Number of evicted transactions.",
|
||||||
|
}, labels).With(labelsAndValues...),
|
||||||
|
RecheckTimes: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: MetricsSubsystem,
|
||||||
|
Name: "recheck_times",
|
||||||
|
Help: "Number of times transactions are rechecked in the mempool.",
|
||||||
|
}, labels).With(labelsAndValues...),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NopMetrics() *Metrics {
|
||||||
|
return &Metrics{
|
||||||
|
Size: discard.NewGauge(),
|
||||||
|
TxSizeBytes: discard.NewHistogram(),
|
||||||
|
FailedTxs: discard.NewCounter(),
|
||||||
|
RejectedTxs: discard.NewCounter(),
|
||||||
|
EvictedTxs: discard.NewCounter(),
|
||||||
|
RecheckTimes: discard.NewCounter(),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,9 +2,6 @@ package mempool
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"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/prometheus"
|
|
||||||
stdprometheus "github.com/prometheus/client_golang/prometheus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -13,14 +10,16 @@ const (
|
|||||||
MetricsSubsystem = "mempool"
|
MetricsSubsystem = "mempool"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate go run ../scripts/metricsgen -struct=Metrics
|
||||||
|
|
||||||
// Metrics contains metrics exposed by this package.
|
// Metrics contains metrics exposed by this package.
|
||||||
// see MetricsProvider for descriptions.
|
// see MetricsProvider for descriptions.
|
||||||
type Metrics struct {
|
type Metrics struct {
|
||||||
// Size of the mempool.
|
// Number of uncommitted transactions in the mempool.
|
||||||
Size metrics.Gauge
|
Size metrics.Gauge
|
||||||
|
|
||||||
// Histogram of transaction sizes, in bytes.
|
// Histogram of transaction sizes in bytes.
|
||||||
TxSizeBytes metrics.Histogram
|
TxSizeBytes metrics.Histogram `metrics_buckettype:"exp" metrics_bucketsizes:"1,3,7"`
|
||||||
|
|
||||||
// Number of failed transactions.
|
// Number of failed transactions.
|
||||||
FailedTxs metrics.Counter
|
FailedTxs metrics.Counter
|
||||||
@@ -29,80 +28,16 @@ type Metrics struct {
|
|||||||
// transactions that passed CheckTx but failed to make it into the mempool
|
// transactions that passed CheckTx but failed to make it into the mempool
|
||||||
// due to resource limits, e.g. mempool is full and no lower priority
|
// due to resource limits, e.g. mempool is full and no lower priority
|
||||||
// transactions exist in the mempool.
|
// transactions exist in the mempool.
|
||||||
|
//metrics:Number of rejected transactions.
|
||||||
RejectedTxs metrics.Counter
|
RejectedTxs metrics.Counter
|
||||||
|
|
||||||
// EvictedTxs defines the number of evicted transactions. These are valid
|
// EvictedTxs defines the number of evicted transactions. These are valid
|
||||||
// transactions that passed CheckTx and existed in the mempool but were later
|
// transactions that passed CheckTx and existed in the mempool but were later
|
||||||
// evicted to make room for higher priority valid transactions that passed
|
// evicted to make room for higher priority valid transactions that passed
|
||||||
// CheckTx.
|
// CheckTx.
|
||||||
|
//metrics:Number of evicted transactions.
|
||||||
EvictedTxs metrics.Counter
|
EvictedTxs metrics.Counter
|
||||||
|
|
||||||
// Number of times transactions are rechecked in the mempool.
|
// Number of times transactions are rechecked in the mempool.
|
||||||
RecheckTimes metrics.Counter
|
RecheckTimes metrics.Counter
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrometheusMetrics returns Metrics build using Prometheus client library.
|
|
||||||
// Optionally, labels can be provided along with their values ("foo",
|
|
||||||
// "fooValue").
|
|
||||||
func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
|
|
||||||
labels := []string{}
|
|
||||||
for i := 0; i < len(labelsAndValues); i += 2 {
|
|
||||||
labels = append(labels, labelsAndValues[i])
|
|
||||||
}
|
|
||||||
return &Metrics{
|
|
||||||
Size: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: MetricsSubsystem,
|
|
||||||
Name: "size",
|
|
||||||
Help: "Size of the mempool (number of uncommitted transactions).",
|
|
||||||
}, labels).With(labelsAndValues...),
|
|
||||||
|
|
||||||
TxSizeBytes: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: MetricsSubsystem,
|
|
||||||
Name: "tx_size_bytes",
|
|
||||||
Help: "Transaction sizes in bytes.",
|
|
||||||
Buckets: stdprometheus.ExponentialBuckets(1, 3, 17),
|
|
||||||
}, labels).With(labelsAndValues...),
|
|
||||||
|
|
||||||
FailedTxs: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: MetricsSubsystem,
|
|
||||||
Name: "failed_txs",
|
|
||||||
Help: "Number of failed transactions.",
|
|
||||||
}, labels).With(labelsAndValues...),
|
|
||||||
|
|
||||||
RejectedTxs: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: MetricsSubsystem,
|
|
||||||
Name: "rejected_txs",
|
|
||||||
Help: "Number of rejected transactions.",
|
|
||||||
}, labels).With(labelsAndValues...),
|
|
||||||
|
|
||||||
EvictedTxs: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: MetricsSubsystem,
|
|
||||||
Name: "evicted_txs",
|
|
||||||
Help: "Number of evicted transactions.",
|
|
||||||
}, labels).With(labelsAndValues...),
|
|
||||||
|
|
||||||
RecheckTimes: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: MetricsSubsystem,
|
|
||||||
Name: "recheck_times",
|
|
||||||
Help: "Number of times transactions are rechecked in the mempool.",
|
|
||||||
}, labels).With(labelsAndValues...),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NopMetrics returns no-op Metrics.
|
|
||||||
func NopMetrics() *Metrics {
|
|
||||||
return &Metrics{
|
|
||||||
Size: discard.NewGauge(),
|
|
||||||
TxSizeBytes: discard.NewHistogram(),
|
|
||||||
FailedTxs: discard.NewCounter(),
|
|
||||||
RejectedTxs: discard.NewCounter(),
|
|
||||||
EvictedTxs: discard.NewCounter(),
|
|
||||||
RecheckTimes: discard.NewCounter(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
58
p2p/metrics.gen.go
Normal file
58
p2p/metrics.gen.go
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
// Code generated by metricsgen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package p2p
|
||||||
|
|
||||||
|
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{
|
||||||
|
Peers: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: MetricsSubsystem,
|
||||||
|
Name: "peers",
|
||||||
|
Help: "Number of peers.",
|
||||||
|
}, labels).With(labelsAndValues...),
|
||||||
|
PeerReceiveBytesTotal: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: MetricsSubsystem,
|
||||||
|
Name: "peer_receive_bytes_total",
|
||||||
|
Help: "Number of bytes received from a given peer.",
|
||||||
|
}, labels).With(labelsAndValues...),
|
||||||
|
PeerSendBytesTotal: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: MetricsSubsystem,
|
||||||
|
Name: "peer_send_bytes_total",
|
||||||
|
Help: "Number of bytes sent to a given peer.",
|
||||||
|
}, labels).With(labelsAndValues...),
|
||||||
|
PeerPendingSendBytes: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: MetricsSubsystem,
|
||||||
|
Name: "peer_pending_send_bytes",
|
||||||
|
Help: "Pending bytes to be sent to a given peer.",
|
||||||
|
}, labels).With(labelsAndValues...),
|
||||||
|
NumTxs: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: MetricsSubsystem,
|
||||||
|
Name: "num_txs",
|
||||||
|
Help: "Number of transactions submitted by each peer.",
|
||||||
|
}, labels).With(labelsAndValues...),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NopMetrics() *Metrics {
|
||||||
|
return &Metrics{
|
||||||
|
Peers: discard.NewGauge(),
|
||||||
|
PeerReceiveBytesTotal: discard.NewCounter(),
|
||||||
|
PeerSendBytesTotal: discard.NewCounter(),
|
||||||
|
PeerPendingSendBytes: discard.NewGauge(),
|
||||||
|
NumTxs: discard.NewGauge(),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,9 +2,6 @@ package p2p
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"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/prometheus"
|
|
||||||
stdprometheus "github.com/prometheus/client_golang/prometheus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -13,6 +10,8 @@ const (
|
|||||||
MetricsSubsystem = "p2p"
|
MetricsSubsystem = "p2p"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate go run ../scripts/metricsgen -struct=Metrics
|
||||||
|
|
||||||
// Metrics contains metrics exposed by this package.
|
// Metrics contains metrics exposed by this package.
|
||||||
type Metrics struct {
|
type Metrics struct {
|
||||||
// Number of peers.
|
// Number of peers.
|
||||||
@@ -26,56 +25,3 @@ type Metrics struct {
|
|||||||
// Number of transactions submitted by each peer.
|
// Number of transactions submitted by each peer.
|
||||||
NumTxs metrics.Gauge
|
NumTxs metrics.Gauge
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrometheusMetrics returns Metrics build using Prometheus client library.
|
|
||||||
// Optionally, labels can be provided along with their values ("foo",
|
|
||||||
// "fooValue").
|
|
||||||
func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
|
|
||||||
labels := []string{}
|
|
||||||
for i := 0; i < len(labelsAndValues); i += 2 {
|
|
||||||
labels = append(labels, labelsAndValues[i])
|
|
||||||
}
|
|
||||||
return &Metrics{
|
|
||||||
Peers: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: MetricsSubsystem,
|
|
||||||
Name: "peers",
|
|
||||||
Help: "Number of peers.",
|
|
||||||
}, labels).With(labelsAndValues...),
|
|
||||||
PeerReceiveBytesTotal: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: MetricsSubsystem,
|
|
||||||
Name: "peer_receive_bytes_total",
|
|
||||||
Help: "Number of bytes received from a given peer.",
|
|
||||||
}, append(labels, "peer_id", "chID")).With(labelsAndValues...),
|
|
||||||
PeerSendBytesTotal: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: MetricsSubsystem,
|
|
||||||
Name: "peer_send_bytes_total",
|
|
||||||
Help: "Number of bytes sent to a given peer.",
|
|
||||||
}, append(labels, "peer_id", "chID")).With(labelsAndValues...),
|
|
||||||
PeerPendingSendBytes: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: MetricsSubsystem,
|
|
||||||
Name: "peer_pending_send_bytes",
|
|
||||||
Help: "Number of pending bytes to be sent to a given peer.",
|
|
||||||
}, append(labels, "peer_id")).With(labelsAndValues...),
|
|
||||||
NumTxs: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: MetricsSubsystem,
|
|
||||||
Name: "num_txs",
|
|
||||||
Help: "Number of transactions submitted by each peer.",
|
|
||||||
}, append(labels, "peer_id")).With(labelsAndValues...),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NopMetrics returns no-op Metrics.
|
|
||||||
func NopMetrics() *Metrics {
|
|
||||||
return &Metrics{
|
|
||||||
Peers: discard.NewGauge(),
|
|
||||||
PeerReceiveBytesTotal: discard.NewCounter(),
|
|
||||||
PeerSendBytesTotal: discard.NewCounter(),
|
|
||||||
PeerPendingSendBytes: discard.NewGauge(),
|
|
||||||
NumTxs: discard.NewGauge(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
32
proxy/metrics.gen.go
Normal file
32
proxy/metrics.gen.go
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// Code generated by metricsgen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package proxy
|
||||||
|
|
||||||
|
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{
|
||||||
|
MethodTiming: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: MetricsSubsystem,
|
||||||
|
Name: "method_timing",
|
||||||
|
Help: "Timing for each ABCI method.",
|
||||||
|
|
||||||
|
Buckets: []float64{.0001, .0004, .002, .009, .02, .1, .65, 2, 6, 25},
|
||||||
|
}, append(labels, "method", "type")).With(labelsAndValues...),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NopMetrics() *Metrics {
|
||||||
|
return &Metrics{
|
||||||
|
MethodTiming: discard.NewHistogram(),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,9 +2,6 @@ package proxy
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"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/prometheus"
|
|
||||||
stdprometheus "github.com/prometheus/client_golang/prometheus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -13,35 +10,10 @@ const (
|
|||||||
MetricsSubsystem = "abci_connection"
|
MetricsSubsystem = "abci_connection"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate go run ../scripts/metricsgen -struct=Metrics
|
||||||
|
|
||||||
// Metrics contains the prometheus metrics exposed by the proxy package.
|
// Metrics contains the prometheus metrics exposed by the proxy package.
|
||||||
type Metrics struct {
|
type Metrics struct {
|
||||||
MethodTiming metrics.Histogram
|
// Timing for each ABCI method.
|
||||||
}
|
MethodTiming metrics.Histogram `metrics_bucketsizes:".0001,.0004,.002,.009,.02,.1,.65,2,6,25" metrics_labels:"method, type"`
|
||||||
|
|
||||||
// PrometheusMetrics constructs a Metrics instance that collects metrics samples.
|
|
||||||
// The resulting metrics will be prefixed with namespace and labeled with the
|
|
||||||
// defaultLabelsAndValues. defaultLabelsAndValues must be a list of string pairs
|
|
||||||
// where the first of each pair is the label and the second is the value.
|
|
||||||
func PrometheusMetrics(namespace string, defaultLabelsAndValues ...string) *Metrics {
|
|
||||||
defaultLabels := []string{}
|
|
||||||
for i := 0; i < len(defaultLabelsAndValues); i += 2 {
|
|
||||||
defaultLabels = append(defaultLabels, defaultLabelsAndValues[i])
|
|
||||||
}
|
|
||||||
return &Metrics{
|
|
||||||
MethodTiming: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: MetricsSubsystem,
|
|
||||||
Name: "method_timing_seconds",
|
|
||||||
Help: "ABCI Method Timing",
|
|
||||||
Buckets: []float64{.0001, .0004, .002, .009, .02, .1, .65, 2, 6, 25},
|
|
||||||
}, append(defaultLabels, []string{"method", "type"}...)).With(defaultLabelsAndValues...),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NopMetrics constructs a Metrics instance that discards all samples and is suitable
|
|
||||||
// for testing.
|
|
||||||
func NopMetrics() *Metrics {
|
|
||||||
return &Metrics{
|
|
||||||
MethodTiming: discard.NewHistogram(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
32
state/metrics.gen.go
Normal file
32
state/metrics.gen.go
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// Code generated by metricsgen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package state
|
||||||
|
|
||||||
|
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{
|
||||||
|
BlockProcessingTime: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: MetricsSubsystem,
|
||||||
|
Name: "block_processing_time",
|
||||||
|
Help: "Time between BeginBlock and EndBlock in ms.",
|
||||||
|
|
||||||
|
Buckets: []float64{1, 10, 10},
|
||||||
|
}, labels).With(labelsAndValues...),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NopMetrics() *Metrics {
|
||||||
|
return &Metrics{
|
||||||
|
BlockProcessingTime: discard.NewHistogram(),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,9 +2,6 @@ package state
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"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/prometheus"
|
|
||||||
stdprometheus "github.com/prometheus/client_golang/prometheus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -13,34 +10,10 @@ const (
|
|||||||
MetricsSubsystem = "state"
|
MetricsSubsystem = "state"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate go run ../scripts/metricsgen -struct=Metrics
|
||||||
|
|
||||||
// Metrics contains metrics exposed by this package.
|
// Metrics contains metrics exposed by this package.
|
||||||
type Metrics struct {
|
type Metrics struct {
|
||||||
// Time between BeginBlock and EndBlock.
|
// Time between BeginBlock and EndBlock in ms.
|
||||||
BlockProcessingTime metrics.Histogram
|
BlockProcessingTime metrics.Histogram `metrics_buckettype:"linear" metrics_bucketsizes:"1, 10, 10"`
|
||||||
}
|
|
||||||
|
|
||||||
// PrometheusMetrics returns Metrics build using Prometheus client library.
|
|
||||||
// Optionally, labels can be provided along with their values ("foo",
|
|
||||||
// "fooValue").
|
|
||||||
func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
|
|
||||||
labels := []string{}
|
|
||||||
for i := 0; i < len(labelsAndValues); i += 2 {
|
|
||||||
labels = append(labels, labelsAndValues[i])
|
|
||||||
}
|
|
||||||
return &Metrics{
|
|
||||||
BlockProcessingTime: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: MetricsSubsystem,
|
|
||||||
Name: "block_processing_time",
|
|
||||||
Help: "Time between BeginBlock and EndBlock in ms.",
|
|
||||||
Buckets: stdprometheus.LinearBuckets(1, 10, 10),
|
|
||||||
}, labels).With(labelsAndValues...),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NopMetrics returns no-op Metrics.
|
|
||||||
func NopMetrics() *Metrics {
|
|
||||||
return &Metrics{
|
|
||||||
BlockProcessingTime: discard.NewHistogram(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user