Mercurial > prosody-modules
annotate mod_measure_client_features/mod_measure_client_features.lua @ 5173:460f78654864
mod_muc_rtbl: also filter messages
This was a bit tricky because we don't want to run the JIDs
through SHA256 on each message. Took a while to come up with this
simple plan of just caching the SHA256 of the JIDs on the
occupants.
This will leave some dirt in the occupants after unloading the
module, but that should be ok; once they cycle the room, the
hashes will be gone.
This is direly needed, otherwise, there is a tight race between
the moderation activities and the actors joining the room.
author | Jonas Schäfer <jonas@wielicki.name> |
---|---|
date | Tue, 21 Feb 2023 21:37:27 +0100 |
parents | 5fdbf416bd40 |
children |
rev | line source |
---|---|
3374
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
1 module:set_global(); |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
2 |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
3 local measure = require"core.statsmanager".measure; |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
4 |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
5 local disco_ns = "http://jabber.org/protocol/disco#info"; |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
6 |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
7 local counters = { |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
8 total = measure("amount", "client_features.total"); |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
9 }; |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
10 |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
11 module:hook("stats-update", function () |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
12 local total = 0; |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
13 local buckets = {}; |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
14 for _, session in pairs(prosody.full_sessions) do |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
15 local disco_info = session.caps_cache; |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
16 if disco_info ~= nil then |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
17 for feature in disco_info:childtags("feature", disco_ns) do |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
18 local var = feature.attr.var; |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
19 if var ~= nil then |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
20 if buckets[var] == nil then |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
21 buckets[var] = 0; |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
22 end |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
23 buckets[var] = buckets[var] + 1; |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
24 end |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
25 end |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
26 total = total + 1; |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
27 end |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
28 end |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
29 for bucket, count in pairs(buckets) do |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
30 if counters[bucket] == nil then |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
31 counters[bucket] = measure("amount", "client_features."..bucket); |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
32 end |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
33 counters[bucket](count); |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
34 end |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
35 counters.total(total); |
5fdbf416bd40
mod_measure_client_features: Add a module to count the features of each connected client
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
36 end) |