From d1a89e71fcbb6f7ffc15c7d6b3385eee2d641925 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Wed, 23 May 2018 10:51:58 +0100 Subject: [PATCH] bla --- .../dendrite/cmd/dendrite-monolith-server/main.go | 7 ------- .../matrix-org/dendrite/common/basecomponent/base.go | 5 ++++- src/github.com/matrix-org/dendrite/common/httpapi.go | 1 + 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/cmd/dendrite-monolith-server/main.go b/src/github.com/matrix-org/dendrite/cmd/dendrite-monolith-server/main.go index 97a4763d4..c00154a78 100644 --- a/src/github.com/matrix-org/dendrite/cmd/dendrite-monolith-server/main.go +++ b/src/github.com/matrix-org/dendrite/cmd/dendrite-monolith-server/main.go @@ -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 {} } diff --git a/src/github.com/matrix-org/dendrite/common/basecomponent/base.go b/src/github.com/matrix-org/dendrite/common/basecomponent/base.go index 1e589c1a9..28f71a608 100644 --- a/src/github.com/matrix-org/dendrite/common/basecomponent/base.go +++ b/src/github.com/matrix-org/dendrite/common/basecomponent/base.go @@ -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 { diff --git a/src/github.com/matrix-org/dendrite/common/httpapi.go b/src/github.com/matrix-org/dendrite/common/httpapi.go index 4f6b53eed..5a3065d75 100644 --- a/src/github.com/matrix-org/dendrite/common/httpapi.go +++ b/src/github.com/matrix-org/dendrite/common/httpapi.go @@ -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)) }