startPrometheusServer starts a Prometheus HTTP server, listening for metrics collectors on addr.
(addr string)
| 1217 | // startPrometheusServer starts a Prometheus HTTP server, listening for metrics |
| 1218 | // collectors on addr. |
| 1219 | func (n *Node) startPrometheusServer(addr string) *http.Server { |
| 1220 | srv := &http.Server{ |
| 1221 | Addr: addr, |
| 1222 | Handler: promhttp.InstrumentMetricHandler( |
| 1223 | prometheus.DefaultRegisterer, promhttp.HandlerFor( |
| 1224 | prometheus.DefaultGatherer, |
| 1225 | promhttp.HandlerOpts{MaxRequestsInFlight: n.config.Instrumentation.MaxOpenConnections}, |
| 1226 | ), |
| 1227 | ), |
| 1228 | ReadHeaderTimeout: readHeaderTimeout, |
| 1229 | } |
| 1230 | go func() { |
| 1231 | if err := srv.ListenAndServe(); err != http.ErrServerClosed { |
| 1232 | // Error starting or closing listener: |
| 1233 | n.Logger.Error("Prometheus HTTP server ListenAndServe", "err", err) |
| 1234 | } |
| 1235 | }() |
| 1236 | return srv |
| 1237 | } |
| 1238 | |
| 1239 | // Switch returns the Node's Switch. |
| 1240 | func (n *Node) Switch() *p2p.Switch { |
no test coverage detected