mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 14:52:17 +00:00
move metrics constructors to a separate package
This commit is contained in:
parent
829342a82d
commit
e4bb3566a0
@ -6,24 +6,35 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Metrics contains metrics exposed by this package.
|
// Metrics contains metrics exposed by this package.
|
||||||
// see MetricsProvider for descriptions.
|
|
||||||
type Metrics struct {
|
type Metrics struct {
|
||||||
|
// Height of the chain.
|
||||||
Height metrics.Gauge
|
Height metrics.Gauge
|
||||||
|
|
||||||
|
// Number of rounds.
|
||||||
Rounds metrics.Gauge
|
Rounds metrics.Gauge
|
||||||
|
|
||||||
Validators metrics.Gauge
|
// Number of validators.
|
||||||
ValidatorsPower metrics.Gauge
|
Validators metrics.Gauge
|
||||||
MissingValidators metrics.Gauge
|
// Total power of all validators.
|
||||||
MissingValidatorsPower metrics.Gauge
|
ValidatorsPower metrics.Gauge
|
||||||
ByzantineValidators metrics.Gauge
|
// Number of validators who did not sign.
|
||||||
|
MissingValidators metrics.Gauge
|
||||||
|
// Total power of the missing validators.
|
||||||
|
MissingValidatorsPower metrics.Gauge
|
||||||
|
// Number of validators who tried to double sign.
|
||||||
|
ByzantineValidators metrics.Gauge
|
||||||
|
// Total power of the byzantine validators.
|
||||||
ByzantineValidatorsPower metrics.Gauge
|
ByzantineValidatorsPower metrics.Gauge
|
||||||
|
|
||||||
|
// Time between this and the last block.
|
||||||
BlockIntervalSeconds metrics.Histogram
|
BlockIntervalSeconds metrics.Histogram
|
||||||
|
|
||||||
NumTxs metrics.Gauge
|
// Number of transactions.
|
||||||
|
NumTxs metrics.Gauge
|
||||||
|
// Size of the block.
|
||||||
BlockSizeBytes metrics.Gauge
|
BlockSizeBytes metrics.Gauge
|
||||||
TotalTxs metrics.Gauge
|
// Total number of transactions.
|
||||||
|
TotalTxs metrics.Gauge
|
||||||
}
|
}
|
||||||
|
|
||||||
// NopMetrics returns no-op Metrics.
|
// NopMetrics returns no-op Metrics.
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
// 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.
|
||||||
Size metrics.Gauge
|
Size metrics.Gauge
|
||||||
}
|
}
|
||||||
|
|
||||||
|
102
metrics/prometheus/prometheus.go
Normal file
102
metrics/prometheus/prometheus.go
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
package prometheus
|
||||||
|
|
||||||
|
import (
|
||||||
|
prometheus "github.com/go-kit/kit/metrics/prometheus"
|
||||||
|
stdprometheus "github.com/prometheus/client_golang/prometheus"
|
||||||
|
|
||||||
|
cs "github.com/tendermint/tendermint/consensus"
|
||||||
|
mempl "github.com/tendermint/tendermint/mempool"
|
||||||
|
"github.com/tendermint/tendermint/p2p"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Consensus returns consensus Metrics build using Prometheus client library.
|
||||||
|
func Consensus() *cs.Metrics {
|
||||||
|
return &cs.Metrics{
|
||||||
|
Height: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Subsystem: "consensus",
|
||||||
|
Name: "height",
|
||||||
|
Help: "Height of the chain.",
|
||||||
|
}, []string{}),
|
||||||
|
Rounds: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Subsystem: "consensus",
|
||||||
|
Name: "rounds",
|
||||||
|
Help: "Number of rounds.",
|
||||||
|
}, []string{}),
|
||||||
|
|
||||||
|
Validators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Subsystem: "consensus",
|
||||||
|
Name: "validators",
|
||||||
|
Help: "Number of validators.",
|
||||||
|
}, []string{}),
|
||||||
|
ValidatorsPower: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Subsystem: "consensus",
|
||||||
|
Name: "validators_power",
|
||||||
|
Help: "Total power of all validators.",
|
||||||
|
}, []string{}),
|
||||||
|
MissingValidators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Subsystem: "consensus",
|
||||||
|
Name: "missing_validators",
|
||||||
|
Help: "Number of validators who did not sign.",
|
||||||
|
}, []string{}),
|
||||||
|
MissingValidatorsPower: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Subsystem: "consensus",
|
||||||
|
Name: "missing_validators_power",
|
||||||
|
Help: "Total power of the missing validators.",
|
||||||
|
}, []string{}),
|
||||||
|
ByzantineValidators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Subsystem: "consensus",
|
||||||
|
Name: "byzantine_validators",
|
||||||
|
Help: "Number of validators who tried to double sign.",
|
||||||
|
}, []string{}),
|
||||||
|
ByzantineValidatorsPower: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Subsystem: "consensus",
|
||||||
|
Name: "byzantine_validators_power",
|
||||||
|
Help: "Total power of the byzantine validators.",
|
||||||
|
}, []string{}),
|
||||||
|
|
||||||
|
BlockIntervalSeconds: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
|
||||||
|
Subsystem: "consensus",
|
||||||
|
Name: "block_interval_seconds",
|
||||||
|
Help: "Time between this and the last block.",
|
||||||
|
Buckets: []float64{1, 2.5, 5, 10, 60},
|
||||||
|
}, []string{}),
|
||||||
|
|
||||||
|
NumTxs: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Subsystem: "consensus",
|
||||||
|
Name: "num_txs",
|
||||||
|
Help: "Number of transactions.",
|
||||||
|
}, []string{}),
|
||||||
|
BlockSizeBytes: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Subsystem: "consensus",
|
||||||
|
Name: "block_size_bytes",
|
||||||
|
Help: "Size of the block.",
|
||||||
|
}, []string{}),
|
||||||
|
TotalTxs: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Subsystem: "consensus",
|
||||||
|
Name: "total_txs",
|
||||||
|
Help: "Total number of transactions.",
|
||||||
|
}, []string{}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// P2P returns p2p Metrics build using Prometheus client library.
|
||||||
|
func P2P() *p2p.Metrics {
|
||||||
|
return &p2p.Metrics{
|
||||||
|
Peers: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Subsystem: "p2p",
|
||||||
|
Name: "peers",
|
||||||
|
Help: "Number of peers.",
|
||||||
|
}, []string{}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mempool returns mempool Metrics build using Prometheus client library.
|
||||||
|
func Mempool() *mempl.Metrics {
|
||||||
|
return &mempl.Metrics{
|
||||||
|
Size: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Subsystem: "mempool",
|
||||||
|
Name: "size",
|
||||||
|
Help: "Size of the mempool (number of uncommitted transactions).",
|
||||||
|
}, []string{}),
|
||||||
|
}
|
||||||
|
}
|
84
node/node.go
84
node/node.go
@ -8,8 +8,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
prometheus "github.com/go-kit/kit/metrics/prometheus"
|
|
||||||
stdprometheus "github.com/prometheus/client_golang/prometheus"
|
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
|
|
||||||
abci "github.com/tendermint/abci/types"
|
abci "github.com/tendermint/abci/types"
|
||||||
@ -24,6 +22,7 @@ import (
|
|||||||
cs "github.com/tendermint/tendermint/consensus"
|
cs "github.com/tendermint/tendermint/consensus"
|
||||||
"github.com/tendermint/tendermint/evidence"
|
"github.com/tendermint/tendermint/evidence"
|
||||||
mempl "github.com/tendermint/tendermint/mempool"
|
mempl "github.com/tendermint/tendermint/mempool"
|
||||||
|
prometrics "github.com/tendermint/tendermint/metrics/prometheus"
|
||||||
"github.com/tendermint/tendermint/p2p"
|
"github.com/tendermint/tendermint/p2p"
|
||||||
"github.com/tendermint/tendermint/p2p/pex"
|
"github.com/tendermint/tendermint/p2p/pex"
|
||||||
"github.com/tendermint/tendermint/privval"
|
"github.com/tendermint/tendermint/privval"
|
||||||
@ -91,90 +90,13 @@ func DefaultNewNode(config *cfg.Config, logger log.Logger) (*Node, error) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MetricsProvider returns a consensus and p2p Metrics.
|
// MetricsProvider returns a consensus, p2p and mempool Metrics.
|
||||||
type MetricsProvider func() (*cs.Metrics, *p2p.Metrics, *mempl.Metrics)
|
type MetricsProvider func() (*cs.Metrics, *p2p.Metrics, *mempl.Metrics)
|
||||||
|
|
||||||
// DefaultMetricsProvider returns consensus, p2p and mempool Metrics build
|
// DefaultMetricsProvider returns consensus, p2p and mempool Metrics build
|
||||||
// using Prometheus client library.
|
// using Prometheus client library.
|
||||||
func DefaultMetricsProvider() (*cs.Metrics, *p2p.Metrics, *mempl.Metrics) {
|
func DefaultMetricsProvider() (*cs.Metrics, *p2p.Metrics, *mempl.Metrics) {
|
||||||
return &cs.Metrics{
|
return prometrics.Consensus(), prometrics.P2P(), prometrics.Mempool()
|
||||||
Height: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Subsystem: "consensus",
|
|
||||||
Name: "height",
|
|
||||||
Help: "Height of the chain.",
|
|
||||||
}, []string{}),
|
|
||||||
Rounds: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Subsystem: "consensus",
|
|
||||||
Name: "rounds",
|
|
||||||
Help: "Number of rounds.",
|
|
||||||
}, []string{}),
|
|
||||||
|
|
||||||
Validators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Subsystem: "consensus",
|
|
||||||
Name: "validators",
|
|
||||||
Help: "Number of validators.",
|
|
||||||
}, []string{}),
|
|
||||||
ValidatorsPower: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Subsystem: "consensus",
|
|
||||||
Name: "validators_power",
|
|
||||||
Help: "Total power of all validators.",
|
|
||||||
}, []string{}),
|
|
||||||
MissingValidators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Subsystem: "consensus",
|
|
||||||
Name: "missing_validators",
|
|
||||||
Help: "Number of validators who did not sign.",
|
|
||||||
}, []string{}),
|
|
||||||
MissingValidatorsPower: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Subsystem: "consensus",
|
|
||||||
Name: "missing_validators_power",
|
|
||||||
Help: "Total power of the missing validators.",
|
|
||||||
}, []string{}),
|
|
||||||
ByzantineValidators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Subsystem: "consensus",
|
|
||||||
Name: "byzantine_validators",
|
|
||||||
Help: "Number of validators who tried to double sign.",
|
|
||||||
}, []string{}),
|
|
||||||
ByzantineValidatorsPower: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Subsystem: "consensus",
|
|
||||||
Name: "byzantine_validators_power",
|
|
||||||
Help: "Total power of the byzantine validators.",
|
|
||||||
}, []string{}),
|
|
||||||
|
|
||||||
BlockIntervalSeconds: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
|
|
||||||
Subsystem: "consensus",
|
|
||||||
Name: "block_interval_seconds",
|
|
||||||
Help: "Time between this and the last block.",
|
|
||||||
Buckets: []float64{1, 2.5, 5, 10, 60},
|
|
||||||
}, []string{}),
|
|
||||||
|
|
||||||
NumTxs: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Subsystem: "consensus",
|
|
||||||
Name: "num_txs",
|
|
||||||
Help: "Number of transactions.",
|
|
||||||
}, []string{}),
|
|
||||||
BlockSizeBytes: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Subsystem: "consensus",
|
|
||||||
Name: "block_size_bytes",
|
|
||||||
Help: "Size of the block.",
|
|
||||||
}, []string{}),
|
|
||||||
TotalTxs: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Subsystem: "consensus",
|
|
||||||
Name: "total_txs",
|
|
||||||
Help: "Total number of transactions.",
|
|
||||||
}, []string{}),
|
|
||||||
}, &p2p.Metrics{
|
|
||||||
Peers: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Subsystem: "p2p",
|
|
||||||
Name: "peers",
|
|
||||||
Help: "Number of peers.",
|
|
||||||
}, []string{}),
|
|
||||||
}, &mempl.Metrics{
|
|
||||||
Size: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
|
||||||
Subsystem: "mempool",
|
|
||||||
Name: "size",
|
|
||||||
Help: "Size of the mempool (number of uncommitted transactions).",
|
|
||||||
}, []string{}),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NopMetricsProvider returns consensus, p2p and mempool Metrics as no-op.
|
// NopMetricsProvider returns consensus, p2p and mempool Metrics as no-op.
|
||||||
|
@ -6,8 +6,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Metrics contains metrics exposed by this package.
|
// Metrics contains metrics exposed by this package.
|
||||||
// see MetricsProvider for descriptions.
|
|
||||||
type Metrics struct {
|
type Metrics struct {
|
||||||
|
// Number of peers.
|
||||||
Peers metrics.Gauge
|
Peers metrics.Gauge
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user