Skip to content

Commit

Permalink
feat: include software version as a label in all metrics (#1037)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmwaters authored Jul 17, 2023
1 parent d5cd08c commit c3ab251
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,17 @@ func DefaultNewNode(config *cfg.Config, logger log.Logger) (*Node, error) {
}

// MetricsProvider returns a consensus, p2p and mempool Metrics.
type MetricsProvider func(chainID string) (*cs.Metrics, *p2p.Metrics, *mempl.Metrics, *sm.Metrics)
type MetricsProvider func(chainID, softwareVersion string) (*cs.Metrics, *p2p.Metrics, *mempl.Metrics, *sm.Metrics)

// DefaultMetricsProvider returns Metrics build using Prometheus client library
// if Prometheus is enabled. Otherwise, it returns no-op Metrics.
func DefaultMetricsProvider(config *cfg.InstrumentationConfig) MetricsProvider {
return func(chainID string) (*cs.Metrics, *p2p.Metrics, *mempl.Metrics, *sm.Metrics) {
return func(chainID, softwareVersion string) (*cs.Metrics, *p2p.Metrics, *mempl.Metrics, *sm.Metrics) {
if config.Prometheus {
return cs.PrometheusMetrics(config.Namespace, "chain_id", chainID),
p2p.PrometheusMetrics(config.Namespace, "chain_id", chainID),
mempl.PrometheusMetrics(config.Namespace, "chain_id", chainID),
sm.PrometheusMetrics(config.Namespace, "chain_id", chainID)
return cs.PrometheusMetrics(config.Namespace, "chain_id", chainID, "version", softwareVersion),
p2p.PrometheusMetrics(config.Namespace, "chain_id", chainID, "version", softwareVersion),
mempl.PrometheusMetrics(config.Namespace, "chain_id", chainID, "version", softwareVersion),
sm.PrometheusMetrics(config.Namespace, "chain_id", chainID, "version", softwareVersion)
}
return cs.NopMetrics(), p2p.NopMetrics(), mempl.NopMetrics(), sm.NopMetrics()
}
Expand Down Expand Up @@ -839,7 +839,7 @@ func NewNode(config *cfg.Config,

logNodeStartupInfo(state, pubKey, logger, consensusLogger)

csMetrics, p2pMetrics, memplMetrics, smMetrics := metricsProvider(genDoc.ChainID)
csMetrics, p2pMetrics, memplMetrics, smMetrics := metricsProvider(genDoc.ChainID, softwareVersion)

// create an optional influxdb client to send arbitrary data to a remote
// influxdb server. This is used to collect trace data from many different nodes
Expand Down

0 comments on commit c3ab251

Please sign in to comment.