This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
expose number of real reserved users #3846
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
create synapse_admin_mau:reserved metric to expose number of real reaserved users | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -307,6 +307,7 @@ def run_startup_checks(self, db_conn, database_engine): | |
# Gauges to expose monthly active user control metrics | ||
current_mau_gauge = Gauge("synapse_admin_mau:current", "Current MAU") | ||
max_mau_gauge = Gauge("synapse_admin_mau:max", "MAU Limit") | ||
reserved_mau_gauge = Gauge("synapse_admin_mau:reserved", "Reserved real MAU users") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we call this something other than |
||
|
||
|
||
def setup(config_options): | ||
|
@@ -531,10 +532,13 @@ def generate_user_daily_visit_stats(): | |
|
||
@defer.inlineCallbacks | ||
def generate_monthly_active_users(): | ||
count = 0 | ||
current_mau_count = 0 | ||
reserved_mau_count = 0 | ||
if hs.config.limit_usage_by_mau: | ||
count = yield hs.get_datastore().get_monthly_active_count() | ||
current_mau_gauge.set(float(count)) | ||
current_mau_count = yield hs.get_datastore().get_monthly_active_count() | ||
reserved_mau_count = yield hs.get_datastore().get_reserved_real_user_account() | ||
current_mau_gauge.set(float(current_mau_count)) | ||
reserved_mau_gauge.set(float(reserved_mau_count)) | ||
max_mau_gauge.set(float(hs.config.max_mau_value)) | ||
|
||
hs.get_datastore().initialise_reserved_users( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,3 +183,34 @@ def test_populate_monthly_users_should_not_update(self): | |
self.store.populate_monthly_active_users('user_id') | ||
self.pump() | ||
self.store.upsert_monthly_active_user.assert_not_called() | ||
|
||
def test_get_reserved_real_user_account(self): | ||
# Test no reserved users, or reserved threepids | ||
count = self.store.get_reserved_real_user_account() | ||
self.assertEquals(self.get_success(count), 0) | ||
# Test reserved users but no registered users | ||
|
||
user1 = '@user1:example.com' | ||
user2 = '@user2:example.com' | ||
user1_email = '[email protected]' | ||
user2_email = '[email protected]' | ||
threepids = [ | ||
{'medium': 'email', 'address': user1_email}, | ||
{'medium': 'email', 'address': user2_email}, | ||
] | ||
self.hs.config.mau_limits_reserved_threepids = threepids | ||
self.store.initialise_reserved_users(threepids) | ||
self.pump() | ||
count = self.store.get_reserved_real_user_account() | ||
self.assertEquals(self.get_success(count), 0) | ||
|
||
# Test reserved registed users | ||
self.store.register(user_id=user1, token="123", password_hash=None) | ||
self.store.register(user_id=user2, token="456", password_hash=None) | ||
self.pump() | ||
|
||
now = int(self.hs.get_clock().time_msec()) | ||
self.store.user_add_threepid(user1, "email", user1_email, now, now) | ||
self.store.user_add_threepid(user2, "email", user2_email, now, now) | ||
count = self.store.get_reserved_real_user_account() | ||
self.assertEquals(self.get_success(count), len(threepids)) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capital please (and start with "Add..." while your there)