mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-24 22:32:15 +00:00
add config option
This commit is contained in:
parent
c958b5319c
commit
1bdff076ad
@ -1,5 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## TBD
|
||||
|
||||
FEATURES:
|
||||
- [node] added metrics (served under /metrics using a Prometheus client; disabled by default)
|
||||
|
||||
## 0.20.1
|
||||
|
||||
BUG FIXES:
|
||||
|
@ -142,6 +142,10 @@ type BaseConfig struct {
|
||||
|
||||
// Database directory
|
||||
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
|
||||
@ -159,6 +163,7 @@ func DefaultBaseConfig() BaseConfig {
|
||||
FilterPeers: false,
|
||||
DBBackend: "leveldb",
|
||||
DBPath: "data",
|
||||
Monitoring: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -411,7 +416,7 @@ func (cfg *MempoolConfig) WalDir() string {
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
type ConsensusConfig struct {
|
||||
RootDir string `mapstructure:"home"`
|
||||
@ -536,7 +541,7 @@ func (cfg *ConsensusConfig) SetWalFile(walFile string) {
|
||||
//-----------------------------------------------------------------------------
|
||||
// TxIndexConfig
|
||||
|
||||
// TxIndexConfig defines the confuguration for the transaction
|
||||
// TxIndexConfig defines the configuration for the transaction
|
||||
// indexer, including tags to index.
|
||||
type TxIndexConfig struct {
|
||||
// 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
|
||||
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 #####
|
||||
|
||||
##### rpc server configuration options #####
|
||||
|
25
node/node.go
25
node/node.go
@ -93,8 +93,8 @@ func DefaultNewNode(config *cfg.Config, logger log.Logger) (*Node, error) {
|
||||
// MetricsProvider returns a consensus and p2p Metrics.
|
||||
type MetricsProvider func() (*cs.Metrics, *p2p.Metrics, *mempl.Metrics)
|
||||
|
||||
// DefaultMetricsProvider returns a consensus and p2p Metrics build using
|
||||
// Prometheus client library.
|
||||
// DefaultMetricsProvider returns consensus, p2p and mempool Metrics build
|
||||
// using Prometheus client library.
|
||||
func DefaultMetricsProvider() (*cs.Metrics, *p2p.Metrics, *mempl.Metrics) {
|
||||
return &cs.Metrics{
|
||||
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.
|
||||
@ -300,7 +305,17 @@ func NewNode(config *cfg.Config,
|
||||
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
|
||||
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.SetLogger(rpcLogger.With("protocol", "websocket"))
|
||||
mux.HandleFunc("/websocket", wm.WebsocketHandler)
|
||||
mux.Handle("/metrics", promhttp.Handler())
|
||||
if n.config.BaseConfig.Monitoring {
|
||||
mux.Handle("/metrics", promhttp.Handler())
|
||||
}
|
||||
rpcserver.RegisterRPCFuncs(mux, rpccore.Routes, coreCodec, rpcLogger)
|
||||
listener, err := rpcserver.StartHTTPServer(listenAddr, mux, rpcLogger)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user