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

Method Start

lib/metrics.go:455–475  ·  view source on GitHub ↗

Start() starts the telemetry server

()

Source from the content-addressed store, hash-verified

453
454// Start() starts the telemetry server
455func (m *Metrics) Start() {
456 // exit if empty
457 if m == nil {
458 return
459 }
460 // set the chain ID and software version metrics (one-time on startup)
461 m.ChainId.Set(m.chainID)
462 m.SoftwareVersion.WithLabelValues(m.softwareVersion).Set(1)
463 // if the metrics server is enabled
464 if m.config.MetricsEnabled {
465 go func() {
466 m.log.Infof("Starting metrics server on %s", m.config.PrometheusAddress)
467 // run the server
468 if err := m.server.ListenAndServe(); err != nil {
469 if err != http.ErrServerClosed {
470 m.log.Errorf("Metrics server failed with err: %s", err.Error())
471 }
472 }
473 }()
474 }
475}
476
477// Stop() gracefully stops the telemetry server
478func (m *Metrics) Stop() {

Callers

nothing calls this directly

Calls 4

SetMethod · 0.65
InfofMethod · 0.65
ErrorfMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected