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

Method startPrometheusServer

node/node.go:1219–1237  ·  view source on GitHub ↗

startPrometheusServer starts a Prometheus HTTP server, listening for metrics collectors on addr.

(addr string)

Source from the content-addressed store, hash-verified

1217// startPrometheusServer starts a Prometheus HTTP server, listening for metrics
1218// collectors on addr.
1219func (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.
1240func (n *Node) Switch() *p2p.Switch {

Callers 1

OnStartMethod · 0.95

Calls 2

ListenAndServeMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected