mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 14:52:17 +00:00
add config option
This commit is contained in:
parent
c958b5319c
commit
1bdff076ad
@ -1,5 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## TBD
|
||||||
|
|
||||||
|
FEATURES:
|
||||||
|
- [node] added metrics (served under /metrics using a Prometheus client; disabled by default)
|
||||||
|
|
||||||
## 0.20.1
|
## 0.20.1
|
||||||
|
|
||||||
BUG FIXES:
|
BUG FIXES:
|
||||||
|
@ -142,6 +142,10 @@ type BaseConfig struct {
|
|||||||
|
|
||||||
// Database directory
|
// Database directory
|
||||||
DBPath string `mapstructure:"db_dir"`
|
DBPath string `mapstructure:"db_dir"`
|
||||||
|
|
||||||
|
// When true, metrics are served under `/metrics` using a Prometheus client
|
||||||
|
// Check out the documentation for the list of available metrics.
|
||||||
|
Monitoring bool `mapstructure:"monitoring"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultBaseConfig returns a default base configuration for a Tendermint node
|
// DefaultBaseConfig returns a default base configuration for a Tendermint node
|
||||||
@ -159,6 +163,7 @@ func DefaultBaseConfig() BaseConfig {
|
|||||||
FilterPeers: false,
|
FilterPeers: false,
|
||||||
DBBackend: "leveldb",
|
DBBackend: "leveldb",
|
||||||
DBPath: "data",
|
DBPath: "data",
|
||||||
|
Monitoring: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,7 +416,7 @@ func (cfg *MempoolConfig) WalDir() string {
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// ConsensusConfig
|
// ConsensusConfig
|
||||||
|
|
||||||
// ConsensusConfig defines the confuguration for the Tendermint consensus service,
|
// ConsensusConfig defines the configuration for the Tendermint consensus service,
|
||||||
// including timeouts and details about the WAL and the block structure.
|
// including timeouts and details about the WAL and the block structure.
|
||||||
type ConsensusConfig struct {
|
type ConsensusConfig struct {
|
||||||
RootDir string `mapstructure:"home"`
|
RootDir string `mapstructure:"home"`
|
||||||
@ -536,7 +541,7 @@ func (cfg *ConsensusConfig) SetWalFile(walFile string) {
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// TxIndexConfig
|
// TxIndexConfig
|
||||||
|
|
||||||
// TxIndexConfig defines the confuguration for the transaction
|
// TxIndexConfig defines the configuration for the transaction
|
||||||
// indexer, including tags to index.
|
// indexer, including tags to index.
|
||||||
type TxIndexConfig struct {
|
type TxIndexConfig struct {
|
||||||
// What indexer to use for transactions
|
// What indexer to use for transactions
|
||||||
|
@ -107,6 +107,10 @@ prof_laddr = "{{ .BaseConfig.ProfListenAddress }}"
|
|||||||
# so the app can decide if we should keep the connection or not
|
# so the app can decide if we should keep the connection or not
|
||||||
filter_peers = {{ .BaseConfig.FilterPeers }}
|
filter_peers = {{ .BaseConfig.FilterPeers }}
|
||||||
|
|
||||||
|
# When true, metrics are served under /metrics using a Prometheus client
|
||||||
|
# Check out the documentation for the list of available metrics.
|
||||||
|
monitoring = {{ .BaseConfig.Monitoring }}
|
||||||
|
|
||||||
##### advanced configuration options #####
|
##### advanced configuration options #####
|
||||||
|
|
||||||
##### rpc server configuration options #####
|
##### rpc server configuration options #####
|
||||||
|
23
node/node.go
23
node/node.go
@ -93,8 +93,8 @@ func DefaultNewNode(config *cfg.Config, logger log.Logger) (*Node, error) {
|
|||||||
// MetricsProvider returns a consensus and p2p Metrics.
|
// MetricsProvider returns a consensus and p2p Metrics.
|
||||||
type MetricsProvider func() (*cs.Metrics, *p2p.Metrics, *mempl.Metrics)
|
type MetricsProvider func() (*cs.Metrics, *p2p.Metrics, *mempl.Metrics)
|
||||||
|
|
||||||
// DefaultMetricsProvider returns a consensus and p2p Metrics build using
|
// DefaultMetricsProvider returns consensus, p2p and mempool Metrics build
|
||||||
// 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 &cs.Metrics{
|
||||||
Height: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
Height: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
@ -176,6 +176,11 @@ func DefaultMetricsProvider() (*cs.Metrics, *p2p.Metrics, *mempl.Metrics) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NopMetricsProvider returns consensus, p2p and mempool Metrics as no-op.
|
||||||
|
func NopMetricsProvider() (*cs.Metrics, *p2p.Metrics, *mempl.Metrics) {
|
||||||
|
return cs.NopMetrics(), p2p.NopMetrics(), mempl.NopMetrics()
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Node is the highest level interface to a full Tendermint node.
|
// Node is the highest level interface to a full Tendermint node.
|
||||||
@ -300,7 +305,17 @@ func NewNode(config *cfg.Config,
|
|||||||
consensusLogger.Info("This node is not a validator", "addr", privValidator.GetAddress(), "pubKey", privValidator.GetPubKey())
|
consensusLogger.Info("This node is not a validator", "addr", privValidator.GetAddress(), "pubKey", privValidator.GetPubKey())
|
||||||
}
|
}
|
||||||
|
|
||||||
csMetrics, p2pMetrics, memplMetrics := metricsProvider()
|
// metrics
|
||||||
|
var (
|
||||||
|
csMetrics *cs.Metrics
|
||||||
|
p2pMetrics *p2p.Metrics
|
||||||
|
memplMetrics *mempl.Metrics
|
||||||
|
)
|
||||||
|
if config.BaseConfig.Monitoring {
|
||||||
|
csMetrics, p2pMetrics, memplMetrics = metricsProvider()
|
||||||
|
} else {
|
||||||
|
csMetrics, p2pMetrics, memplMetrics = NopMetricsProvider()
|
||||||
|
}
|
||||||
|
|
||||||
// Make MempoolReactor
|
// Make MempoolReactor
|
||||||
mempoolLogger := logger.With("module", "mempool")
|
mempoolLogger := logger.With("module", "mempool")
|
||||||
@ -600,7 +615,9 @@ func (n *Node) startRPC() ([]net.Listener, error) {
|
|||||||
wm := rpcserver.NewWebsocketManager(rpccore.Routes, coreCodec, rpcserver.EventSubscriber(n.eventBus))
|
wm := rpcserver.NewWebsocketManager(rpccore.Routes, coreCodec, rpcserver.EventSubscriber(n.eventBus))
|
||||||
wm.SetLogger(rpcLogger.With("protocol", "websocket"))
|
wm.SetLogger(rpcLogger.With("protocol", "websocket"))
|
||||||
mux.HandleFunc("/websocket", wm.WebsocketHandler)
|
mux.HandleFunc("/websocket", wm.WebsocketHandler)
|
||||||
|
if n.config.BaseConfig.Monitoring {
|
||||||
mux.Handle("/metrics", promhttp.Handler())
|
mux.Handle("/metrics", promhttp.Handler())
|
||||||
|
}
|
||||||
rpcserver.RegisterRPCFuncs(mux, rpccore.Routes, coreCodec, rpcLogger)
|
rpcserver.RegisterRPCFuncs(mux, rpccore.Routes, coreCodec, rpcLogger)
|
||||||
listener, err := rpcserver.StartHTTPServer(listenAddr, mux, rpcLogger)
|
listener, err := rpcserver.StartHTTPServer(listenAddr, mux, rpcLogger)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user