MCPcopy
hub / github.com/canopy-network/canopy / NewMetricsServer

Function NewMetricsServer

lib/metrics.go:170–452  ·  view source on GitHub ↗

NewMetricsServer() creates a new telemetry server

(nodeAddress crypto.AddressI, chainID float64, softwareVersion string, config MetricsConfig, logger LoggerI)

Source from the content-addressed store, hash-verified

168
169// NewMetricsServer() creates a new telemetry server
170func NewMetricsServer(nodeAddress crypto.AddressI, chainID float64, softwareVersion string, config MetricsConfig, logger LoggerI) *Metrics {
171 mux := http.NewServeMux()
172 mux.Handle(metricsPattern, promhttp.Handler())
173 return &Metrics{
174 server: &http.Server{Addr: config.PrometheusAddress, Handler: mux},
175 config: config,
176 nodeAddress: nodeAddress.Bytes(),
177 chainID: float64(chainID),
178 softwareVersion: softwareVersion,
179 log: logger,
180 // NODE
181 NodeMetrics: NodeMetrics{
182 NodeStatus: promauto.NewGauge(prometheus.GaugeOpts{
183 Name: "canopy_node_status",
184 Help: "The node is alive and processing blocks",
185 }),
186 GetRootChainInfo: promauto.NewHistogram(prometheus.HistogramOpts{
187 Name: "canopy_root_chain_info_time",
188 Help: "The time it takes to process a 'GetRootChainInfo' call",
189 }),
190 SyncingStatus: promauto.NewGauge(prometheus.GaugeOpts{
191 Name: "canopy_syncing_status",
192 Help: "Node syncing status (0 for syncing, 1 for synced)",
193 }),
194 ProposerCount: promauto.NewCounter(prometheus.CounterOpts{
195 Name: "canopy_proposer_count",
196 Help: "Total blocks produced by this node",
197 }),
198 AccountBalance: promauto.NewGaugeVec(prometheus.GaugeOpts{
199 Name: "canopy_account_balance",
200 Help: "Account balance in uCNPY of the node's address",
201 }, []string{"address"}),
202 ChainId: promauto.NewGauge(prometheus.GaugeOpts{
203 Name: "canopy_chain_id",
204 Help: "The chain ID this node is running on",
205 }),
206 SoftwareVersion: promauto.NewGaugeVec(prometheus.GaugeOpts{
207 Name: "canopy_software_version",
208 Help: "The software version this node is running",
209 }, []string{"version"}),
210 StartupBlock: promauto.NewGauge(prometheus.GaugeOpts{
211 Name: "canopy_startup_block",
212 Help: "The block height when node first completed syncing after startup (set only once per run)",
213 }),
214 },
215 // BLOCK
216 BlockMetrics: BlockMetrics{
217 BlockProcessingTime: promauto.NewHistogram(prometheus.HistogramOpts{
218 Name: "canopy_block_processing_time",
219 Help: "The time it takes to process a received canopy block in seconds",
220 }),
221 BlockSize: promauto.NewGauge(prometheus.GaugeOpts{
222 Name: "canopy_block_size",
223 Help: "The size of the last block in bytes",
224 }),
225 BlockNumTxs: promauto.NewGauge(prometheus.GaugeOpts{
226 Name: "canopy_block_num_txs",
227 Help: "The number of transactions in the last canopy block",

Callers 1

StartFunction · 0.92

Calls 2

HandleMethod · 0.80
BytesMethod · 0.65

Tested by

no test coverage detected