diff options
author | Brendan Abolivier <babolivier@matrix.org> | 2022-09-05 12:26:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-05 10:26:43 +0000 |
commit | 898fef2789c9b1a20ef53c7d588f536f51f0fe2f (patch) | |
tree | 326f374fa50f2418f7ab13cdfc21c92da613291d /synapse/app/phone_stats_home.py | |
parent | fix grammar (diff) | |
download | synapse-898fef2789c9b1a20ef53c7d588f536f51f0fe2f.tar.xz |
Share some metrics between the Prometheus exporter and the phone home stats (#13671)
Diffstat (limited to 'synapse/app/phone_stats_home.py')
-rw-r--r-- | synapse/app/phone_stats_home.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/synapse/app/phone_stats_home.py b/synapse/app/phone_stats_home.py index 40dbdace8e..51c8d15711 100644 --- a/synapse/app/phone_stats_home.py +++ b/synapse/app/phone_stats_home.py @@ -51,6 +51,16 @@ async def phone_stats_home( stats: JsonDict, stats_process: List[Tuple[int, "resource.struct_rusage"]] = _stats_process, ) -> None: + """Collect usage statistics and send them to the configured endpoint. + + Args: + hs: the HomeServer object to use for gathering usage data. + stats: the dict in which to store the statistics sent to the configured + endpoint. Mostly used in tests to figure out the data that is supposed to + be sent. + stats_process: statistics about resource usage of the process. + """ + logger.info("Gathering stats for reporting") now = int(hs.get_clock().time()) # Ensure the homeserver has started. @@ -83,6 +93,7 @@ async def phone_stats_home( # store = hs.get_datastores().main + common_metrics = await hs.get_common_usage_metrics_manager().get_metrics() stats["homeserver"] = hs.config.server.server_name stats["server_context"] = hs.config.server.server_context @@ -104,7 +115,7 @@ async def phone_stats_home( room_count = await store.get_room_count() stats["total_room_count"] = room_count - stats["daily_active_users"] = await store.count_daily_users() + stats["daily_active_users"] = common_metrics.daily_active_users stats["monthly_active_users"] = await store.count_monthly_users() daily_active_e2ee_rooms = await store.count_daily_active_e2ee_rooms() stats["daily_active_e2ee_rooms"] = daily_active_e2ee_rooms |