MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / DefaultMetricsProvider

Function DefaultMetricsProvider

node/node.go:122–132  ·  view source on GitHub ↗

DefaultMetricsProvider returns Metrics build using Prometheus client library if Prometheus is enabled. Otherwise, it returns no-op Metrics.

(config *cfg.InstrumentationConfig)

Source from the content-addressed store, hash-verified

120// DefaultMetricsProvider returns Metrics build using Prometheus client library
121// if Prometheus is enabled. Otherwise, it returns no-op Metrics.
122func DefaultMetricsProvider(config *cfg.InstrumentationConfig) MetricsProvider {
123 return func(chainID string) (*cs.Metrics, *p2p.Metrics, *mempl.Metrics, *sm.Metrics) {
124 if config.Prometheus {
125 return cs.PrometheusMetrics(config.Namespace, "chain_id", chainID),
126 p2p.PrometheusMetrics(config.Namespace, "chain_id", chainID),
127 mempl.PrometheusMetrics(config.Namespace, "chain_id", chainID),
128 sm.PrometheusMetrics(config.Namespace, "chain_id", chainID)
129 }
130 return cs.NopMetrics(), p2p.NopMetrics(), mempl.NopMetrics(), sm.NopMetrics()
131 }
132}
133
134// Option sets a parameter for the node.
135type Option func(*Node)

Callers 2

DefaultNewNodeFunction · 0.70

Calls 2

PrometheusMetricsFunction · 0.92
NopMetricsFunction · 0.92

Tested by 1