diff options
author | Neil Johnson <neil@matrix.org> | 2018-08-01 17:49:41 +0100 |
---|---|---|
committer | Neil Johnson <neil@matrix.org> | 2018-08-01 17:49:41 +0100 |
commit | d766f26de978f3ffc7989f3bdc586f3f87ac28c1 (patch) | |
tree | c8043934dfa079b3af4de4c942917c10df1237e0 /synapse/app/homeserver.py | |
parent | clean up (diff) | |
parent | Merge pull request #3630 from matrix-org/neilj/mau_sign_in_log_in_limits (diff) | |
download | synapse-d766f26de978f3ffc7989f3bdc586f3f87ac28c1.tar.xz |
Merge branch 'develop' of github.com:matrix-org/synapse into neilj/mau_tracker
Diffstat (limited to 'synapse/app/homeserver.py')
-rwxr-xr-x | synapse/app/homeserver.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py index 79772fa61a..5f0ca51ac7 100755 --- a/synapse/app/homeserver.py +++ b/synapse/app/homeserver.py @@ -20,6 +20,8 @@ import sys from six import iteritems +from prometheus_client import Gauge + from twisted.application import service from twisted.internet import defer, reactor from twisted.web.resource import EncodingResourceWrapper, NoResource @@ -301,6 +303,11 @@ class SynapseHomeServer(HomeServer): quit_with_error(e.message) +# Gauges to expose monthly active user control metrics +current_mau_gauge = Gauge("synapse_admin_current_mau", "Current MAU") +max_mau_value_gauge = Gauge("synapse_admin_max_mau_value", "MAU Limit") + + def setup(config_options): """ Args: @@ -516,6 +523,18 @@ def run(hs): MonthlyActiveUsersStore(hs).reap_monthly_active_users, 1000 * 60 * 60 ) + @defer.inlineCallbacks + def generate_monthly_active_users(): + count = 0 + if hs.config.limit_usage_by_mau: + count = yield hs.get_datastore().count_monthly_users() + current_mau_gauge.set(float(count)) + max_mau_value_gauge.set(float(hs.config.max_mau_value)) + + generate_monthly_active_users() + if hs.config.limit_usage_by_mau: + clock.looping_call(generate_monthly_active_users, 5 * 60 * 1000) + if hs.config.report_stats: logger.info("Scheduling stats reporting for 3 hour intervals") clock.looping_call(start_phone_stats_home, 3 * 60 * 60 * 1000) |