-
Notifications
You must be signed in to change notification settings - Fork 561
Add metric to count number of non-deactivated users. #19848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+278
−56
Merged
Changes from 20 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
7023899
Add synapse_admin_user_count metric.
Half-Shot c89519e
typo
Half-Shot b924048
spacing
Half-Shot 3c0e6f4
Potential fix for pull request finding
Half-Shot 4335e1f
Potential fix for pull request finding
Half-Shot 39468bc
Potential fix for pull request finding
Half-Shot 170d120
Potential fix for pull request finding
Half-Shot a0dc0c3
Potential fix for pull request finding
Half-Shot 2c1a9f3
test update
Half-Shot e420c3b
lint
Half-Shot fb2ec7d
Bump metrics dependency to support .clear()
Half-Shot 715c253
update lock
Half-Shot 772082e
Active is fine
Half-Shot 904385c
Review changes
Half-Shot 1b9ce6c
update tests
Half-Shot 3ae1139
Update tests
Half-Shot 742d92f
Merge remote-tracking branch 'origin/develop' into hs/metric-for-all-…
Half-Shot d821bbe
update lock
Half-Shot b240e9c
More tidyup
Half-Shot a9b58dd
Add a comment
Half-Shot 33b10c6
Update synapse/app/phone_stats_home.py
Half-Shot 4176100
Update tests/metrics/test_phone_home_stats.py
Half-Shot 7892274
Apply suggestions from code review
Half-Shot 539a0c9
comment COUNT_USERS_INTERVAL value source.
Half-Shot 54d6b58
Merge remote-tracking branch 'origin/develop' into hs/metric-for-all-…
Half-Shot 49ed33e
use poetry 2.4.1 for lock
Half-Shot 4f40339
lint
Half-Shot c3003e1
Use more standard import
MadLittleMods 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 hidden or 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 @@ | ||
| Add new metric `synapse_non_deactivated_user_count` which tracks the number of non-deactivated users in the database, split by `app_service`. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,40 @@ | ||
| # | ||
| # This file is licensed under the Affero General Public License (AGPL) version 3. | ||
| # | ||
| # Copyright (C) 2026 Element Creations Ltd | ||
| # | ||
| # This program is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Affero General Public License as | ||
| # published by the Free Software Foundation, either version 3 of the | ||
| # License, or (at your option) any later version. | ||
| # | ||
| # See the GNU Affero General Public License for more details: | ||
| # <https://www.gnu.org/licenses/agpl-3.0.html>. | ||
|
|
||
| from synapse.metrics import ( | ||
|
Half-Shot marked this conversation as resolved.
|
||
| REGISTRY, | ||
| generate_latest, | ||
| ) | ||
|
|
||
|
|
||
| def get_latest_metrics() -> dict[str, str]: | ||
|
Half-Shot marked this conversation as resolved.
|
||
| """ | ||
| Collect the latest metrics from the registry and parse them into an easy to use map. | ||
| The key includes the metric name and labels. | ||
|
|
||
| Example output: | ||
| { | ||
| "synapse_util_caches_cache_size": "0.0", | ||
| "synapse_util_caches_cache_max_size{name="some_cache",server_name="hs1"}": "777.0", | ||
| ... | ||
| } | ||
| """ | ||
| metric_map = { | ||
| x.split(b" ")[0].decode("ascii"): x.split(b" ")[1].decode("ascii") | ||
| for x in filter( | ||
| lambda x: len(x) > 0 and not x.startswith(b"#"), | ||
| generate_latest(REGISTRY).split(b"\n"), | ||
| ) | ||
| } | ||
|
|
||
| return metric_map | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.