mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-03 11:45:18 +00:00
## What does this change do? 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 `master`, we can see that there is not a diff between the two sets of metrics when run locally. ``` [william@sidewinder] tendermint[wb/metrics-gen-transition]:. ◆ ./scripts/metricsgen/metricsdiff/metricsdiff metrics_master metrics_generated [william@sidewinder] tendermint[wb/metrics-gen-transition]:. ◆ ``` 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.
47 lines
1.6 KiB
Go
47 lines
1.6 KiB
Go
// 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.",
|
|
|
|
Buckets: stdprometheus.LinearBuckets(1, 10, 10),
|
|
}, labels).With(labelsAndValues...),
|
|
ConsensusParamUpdates: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "consensus_param_updates",
|
|
Help: "Number of consensus parameter updates returned by the application since process start.",
|
|
}, labels).With(labelsAndValues...),
|
|
ValidatorSetUpdates: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "validator_set_updates",
|
|
Help: "Number of validator set updates returned by the application since process start.",
|
|
}, labels).With(labelsAndValues...),
|
|
}
|
|
}
|
|
|
|
func NopMetrics() *Metrics {
|
|
return &Metrics{
|
|
BlockProcessingTime: discard.NewHistogram(),
|
|
ConsensusParamUpdates: discard.NewCounter(),
|
|
ValidatorSetUpdates: discard.NewCounter(),
|
|
}
|
|
}
|