summary refs log tree commit diff
path: root/synapse/storage/databases/main/metrics.py
diff options
context:
space:
mode:
authorAndrew Morgan <1342360+anoadragon453@users.noreply.github.com>2025-04-15 07:49:08 -0700
committerGitHub <noreply@github.com>2025-04-15 07:49:08 -0700
commita832375bfb5b0327e73d2b5cf9104b555308e827 (patch)
tree6f30896e44135db79faccb73df7d35ea79f97418 /synapse/storage/databases/main/metrics.py
parentAdd caches to new hot path functions (#18337) (diff)
downloadsynapse-a832375bfb5b0327e73d2b5cf9104b555308e827.tar.xz
Add total event, unencrypted message, and e2ee event counts to stats reporting (#18260)
Co-authored-by: Eric Eastwood <erice@element.io>
Diffstat (limited to 'synapse/storage/databases/main/metrics.py')
-rw-r--r--synapse/storage/databases/main/metrics.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/synapse/storage/databases/main/metrics.py b/synapse/storage/databases/main/metrics.py

index 9ce1100b5c..a9cecc4bc1 100644 --- a/synapse/storage/databases/main/metrics.py +++ b/synapse/storage/databases/main/metrics.py
@@ -126,6 +126,44 @@ class ServerMetricsStore(EventPushActionsWorkerStore, SQLBaseStore): return await self.db_pool.runInteraction("count_e2ee_messages", _count_messages) + async def count_total_events(self) -> int: + """ + Returns the total number of events present on the server. + """ + + return await self.db_pool.simple_select_one_onecol( + table="event_stats", + keyvalues={}, + retcol="total_event_count", + desc="count_total_events", + ) + + async def count_total_messages(self) -> int: + """ + Returns the total number of `m.room.message` events present on the + server. + """ + + return await self.db_pool.simple_select_one_onecol( + table="event_stats", + keyvalues={}, + retcol="unencrypted_message_count", + desc="count_total_messages", + ) + + async def count_total_e2ee_events(self) -> int: + """ + Returns the total number of `m.room.encrypted` events present on the + server. + """ + + return await self.db_pool.simple_select_one_onecol( + table="event_stats", + keyvalues={}, + retcol="e2ee_event_count", + desc="count_total_e2ee_events", + ) + async def count_daily_sent_e2ee_messages(self) -> int: def _count_messages(txn: LoggingTransaction) -> int: # This is good enough as if you have silly characters in your own