aboutsummaryrefslogtreecommitdiff
path: root/appservice
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2022-12-05 13:53:36 +0100
committerGitHub <noreply@github.com>2022-12-05 13:53:36 +0100
commite245a26f6bcb4d134015f49f621b6d639a78707f (patch)
tree87bd54e9d6ad35a225fe8f6dd9bb102c161e5f2e /appservice
parentb65f89e61e95b295e46ac3ade3c860b56126fa90 (diff)
Enable/Disable internal metrics (#2899)
Basically enables us to use `test.WithAllDatabases` when testing internal HTTP APIs, as this would otherwise result in Prometheus complaining about already registered metric names.
Diffstat (limited to 'appservice')
-rw-r--r--appservice/appservice.go7
-rw-r--r--appservice/inthttp/server.go12
2 files changed, 10 insertions, 9 deletions
diff --git a/appservice/appservice.go b/appservice/appservice.go
index b3c28dbd..753850de 100644
--- a/appservice/appservice.go
+++ b/appservice/appservice.go
@@ -24,6 +24,8 @@ import (
"github.com/gorilla/mux"
"github.com/sirupsen/logrus"
+ "github.com/matrix-org/gomatrixserverlib"
+
appserviceAPI "github.com/matrix-org/dendrite/appservice/api"
"github.com/matrix-org/dendrite/appservice/consumers"
"github.com/matrix-org/dendrite/appservice/inthttp"
@@ -32,12 +34,11 @@ import (
"github.com/matrix-org/dendrite/setup/base"
"github.com/matrix-org/dendrite/setup/config"
userapi "github.com/matrix-org/dendrite/userapi/api"
- "github.com/matrix-org/gomatrixserverlib"
)
// AddInternalRoutes registers HTTP handlers for internal API calls
-func AddInternalRoutes(router *mux.Router, queryAPI appserviceAPI.AppServiceInternalAPI) {
- inthttp.AddRoutes(queryAPI, router)
+func AddInternalRoutes(router *mux.Router, queryAPI appserviceAPI.AppServiceInternalAPI, enableMetrics bool) {
+ inthttp.AddRoutes(queryAPI, router, enableMetrics)
}
// NewInternalAPI returns a concerete implementation of the internal API. Callers
diff --git a/appservice/inthttp/server.go b/appservice/inthttp/server.go
index ccf5c83d..b70fad67 100644
--- a/appservice/inthttp/server.go
+++ b/appservice/inthttp/server.go
@@ -8,29 +8,29 @@ import (
)
// AddRoutes adds the AppServiceQueryAPI handlers to the http.ServeMux.
-func AddRoutes(a api.AppServiceInternalAPI, internalAPIMux *mux.Router) {
+func AddRoutes(a api.AppServiceInternalAPI, internalAPIMux *mux.Router, enableMetrics bool) {
internalAPIMux.Handle(
AppServiceRoomAliasExistsPath,
- httputil.MakeInternalRPCAPI("AppserviceRoomAliasExists", a.RoomAliasExists),
+ httputil.MakeInternalRPCAPI("AppserviceRoomAliasExists", enableMetrics, a.RoomAliasExists),
)
internalAPIMux.Handle(
AppServiceUserIDExistsPath,
- httputil.MakeInternalRPCAPI("AppserviceUserIDExists", a.UserIDExists),
+ httputil.MakeInternalRPCAPI("AppserviceUserIDExists", enableMetrics, a.UserIDExists),
)
internalAPIMux.Handle(
AppServiceProtocolsPath,
- httputil.MakeInternalRPCAPI("AppserviceProtocols", a.Protocols),
+ httputil.MakeInternalRPCAPI("AppserviceProtocols", enableMetrics, a.Protocols),
)
internalAPIMux.Handle(
AppServiceLocationsPath,
- httputil.MakeInternalRPCAPI("AppserviceLocations", a.Locations),
+ httputil.MakeInternalRPCAPI("AppserviceLocations", enableMetrics, a.Locations),
)
internalAPIMux.Handle(
AppServiceUserPath,
- httputil.MakeInternalRPCAPI("AppserviceUser", a.User),
+ httputil.MakeInternalRPCAPI("AppserviceUser", enableMetrics, a.User),
)
}