This commit is contained in:
Andrew Morgan 2018-05-23 10:51:58 +01:00
parent ee146d1a78
commit d1a89e71fc
3 changed files with 5 additions and 8 deletions

View file

@ -16,7 +16,6 @@ package main
import (
"flag"
"log"
"net/http"
"github.com/matrix-org/dendrite/common/keydb"
@ -32,8 +31,6 @@ import (
"github.com/matrix-org/dendrite/roomserver"
"github.com/matrix-org/dendrite/syncapi"
"github.com/sirupsen/logrus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var (
@ -82,10 +79,6 @@ func main() {
}
}()
// Set up prometheus metrics
http.Handle("/metrics", promhttp.Handler())
log.Fatal(http.ListenAndServe(":8080", nil))
// We want to block forever to let the HTTP and HTTPS handler serve the APIs
select {}
}

View file

@ -27,6 +27,7 @@ import (
"github.com/matrix-org/dendrite/clientapi/auth/storage/devices"
"github.com/matrix-org/dendrite/common"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/gorilla/mux"
sarama "gopkg.in/Shopify/sarama.v1"
@ -134,9 +135,11 @@ func (b *BaseDendrite) CreateFederationClient() *gomatrixserverlib.FederationCli
// ApiMux under /api/ and adds a prometheus handler under /metrics.
func (b *BaseDendrite) SetupAndServeHTTP(addr string) {
common.SetupHTTPAPI(http.DefaultServeMux, common.WrapHandlerInCORS(b.APIMux))
logrus.Infof("Starting %s server on %s", b.componentName, addr)
http.Handle("/metrics", promhttp.Handler())
logrus.Infof("Starting %s Prometheus server at /metrics", b.componentName)
err := http.ListenAndServe(addr, nil)
if err != nil {

View file

@ -89,6 +89,7 @@ func MakeFedAPI(
func SetupHTTPAPI(servMux *http.ServeMux, apiMux http.Handler) {
// This is deprecated.
servMux.Handle("/metrics", prometheus.Handler()) // nolint: megacheck, staticcheck
servMux.Handle("/metrics", promhttp.Handler())
servMux.Handle("/api/", http.StripPrefix("/api", apiMux))
}