Start() starts the telemetry server
()
| 453 | |
| 454 | // Start() starts the telemetry server |
| 455 | func (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 |
| 478 | func (m *Metrics) Stop() { |