Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit eebfd02

Browse files
authored
Factorise get_datastore calls in phone_stats_home. (#10427)
Follow-up to #10332.
1 parent 4e34041 commit eebfd02

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

changelog.d/10427.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add a new version of the R30 phone-home metric, which removes a false impression of retention given by the old R30 metric.

synapse/app/phone_stats_home.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ async def phone_stats_home(hs, stats, stats_process=_stats_process):
7171
# General statistics
7272
#
7373

74+
store = hs.get_datastore()
75+
7476
stats["homeserver"] = hs.config.server_name
7577
stats["server_context"] = hs.config.server_context
7678
stats["timestamp"] = now
@@ -79,35 +81,35 @@ async def phone_stats_home(hs, stats, stats_process=_stats_process):
7981
stats["python_version"] = "{}.{}.{}".format(
8082
version.major, version.minor, version.micro
8183
)
82-
stats["total_users"] = await hs.get_datastore().count_all_users()
84+
stats["total_users"] = await store.count_all_users()
8385

84-
total_nonbridged_users = await hs.get_datastore().count_nonbridged_users()
86+
total_nonbridged_users = await store.count_nonbridged_users()
8587
stats["total_nonbridged_users"] = total_nonbridged_users
8688

87-
daily_user_type_results = await hs.get_datastore().count_daily_user_type()
89+
daily_user_type_results = await store.count_daily_user_type()
8890
for name, count in daily_user_type_results.items():
8991
stats["daily_user_type_" + name] = count
9092

91-
room_count = await hs.get_datastore().get_room_count()
93+
room_count = await store.get_room_count()
9294
stats["total_room_count"] = room_count
9395

94-
stats["daily_active_users"] = await hs.get_datastore().count_daily_users()
95-
stats["monthly_active_users"] = await hs.get_datastore().count_monthly_users()
96-
daily_active_e2ee_rooms = await hs.get_datastore().count_daily_active_e2ee_rooms()
96+
stats["daily_active_users"] = await store.count_daily_users()
97+
stats["monthly_active_users"] = await store.count_monthly_users()
98+
daily_active_e2ee_rooms = await store.count_daily_active_e2ee_rooms()
9799
stats["daily_active_e2ee_rooms"] = daily_active_e2ee_rooms
98-
stats["daily_e2ee_messages"] = await hs.get_datastore().count_daily_e2ee_messages()
99-
daily_sent_e2ee_messages = await hs.get_datastore().count_daily_sent_e2ee_messages()
100+
stats["daily_e2ee_messages"] = await store.count_daily_e2ee_messages()
101+
daily_sent_e2ee_messages = await store.count_daily_sent_e2ee_messages()
100102
stats["daily_sent_e2ee_messages"] = daily_sent_e2ee_messages
101-
stats["daily_active_rooms"] = await hs.get_datastore().count_daily_active_rooms()
102-
stats["daily_messages"] = await hs.get_datastore().count_daily_messages()
103-
daily_sent_messages = await hs.get_datastore().count_daily_sent_messages()
103+
stats["daily_active_rooms"] = await store.count_daily_active_rooms()
104+
stats["daily_messages"] = await store.count_daily_messages()
105+
daily_sent_messages = await store.count_daily_sent_messages()
104106
stats["daily_sent_messages"] = daily_sent_messages
105107

106-
r30_results = await hs.get_datastore().count_r30_users()
108+
r30_results = await store.count_r30_users()
107109
for name, count in r30_results.items():
108110
stats["r30_users_" + name] = count
109111

110-
r30v2_results = await hs.get_datastore().count_r30_users()
112+
r30v2_results = await store.count_r30_users()
111113
for name, count in r30v2_results.items():
112114
stats["r30v2_users_" + name] = count
113115

@@ -119,8 +121,8 @@ async def phone_stats_home(hs, stats, stats_process=_stats_process):
119121
#
120122

121123
# This only reports info about the *main* database.
122-
stats["database_engine"] = hs.get_datastore().db_pool.engine.module.__name__
123-
stats["database_server_version"] = hs.get_datastore().db_pool.engine.server_version
124+
stats["database_engine"] = store.db_pool.engine.module.__name__
125+
stats["database_server_version"] = store.db_pool.engine.server_version
124126

125127
#
126128
# Logging configuration

0 commit comments

Comments
 (0)