github.com/prebid/prebid-server/v2@v2.18.0/server/prometheus.go (about) 1 package server 2 3 import ( 4 "net/http" 5 "strconv" 6 7 "github.com/golang/glog" 8 "github.com/prometheus/client_golang/prometheus/promhttp" 9 10 "github.com/prebid/prebid-server/v2/config" 11 metricsconfig "github.com/prebid/prebid-server/v2/metrics/config" 12 ) 13 14 func newPrometheusServer(cfg *config.Configuration, metrics *metricsconfig.DetailedMetricsEngine) *http.Server { 15 proMetrics := metrics.PrometheusMetrics 16 17 if proMetrics == nil { 18 glog.Fatal("Prometheus metrics configured, but a Prometheus metrics engine was not found. Cannot set up a Prometheus listener.") 19 } 20 return &http.Server{ 21 Addr: cfg.Host + ":" + strconv.Itoa(cfg.Metrics.Prometheus.Port), 22 Handler: promhttp.HandlerFor(proMetrics.Gatherer, promhttp.HandlerOpts{ 23 ErrorLog: loggerForPrometheus{}, 24 MaxRequestsInFlight: 5, 25 Timeout: cfg.Metrics.Prometheus.Timeout(), 26 }), 27 } 28 } 29 30 type loggerForPrometheus struct{} 31 32 func (loggerForPrometheus) Println(v ...interface{}) { 33 glog.Warningln(v...) 34 }