mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-04 04:04:00 +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
68 lines
2.2 KiB
Go
68 lines
2.2 KiB
Go
// 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(),
|
|
}
|
|
}
|