mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-03 10:32:05 +00:00
Absence of this label causes a panic because the setters try to access the label despite it never being added to the metric. This PR adds the label to the metrics, thus preventing the panic.
#### 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
59 lines
2.0 KiB
Go
59 lines
2.0 KiB
Go
// 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.",
|
|
}, 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: "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...),
|
|
}
|
|
}
|
|
|
|
func NopMetrics() *Metrics {
|
|
return &Metrics{
|
|
Peers: discard.NewGauge(),
|
|
PeerReceiveBytesTotal: discard.NewCounter(),
|
|
PeerSendBytesTotal: discard.NewCounter(),
|
|
PeerPendingSendBytes: discard.NewGauge(),
|
|
NumTxs: discard.NewGauge(),
|
|
}
|
|
}
|