aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_s2s_bidi.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2024-08-11 17:25:47 +0200
committerKim Alvefur <zash@zash.se>2024-08-11 17:25:47 +0200
commitffbf4e39d2bfb4ffa36d5d8252da4b8004458a45 (patch)
tree3a3890daae0d1790b30cc25674ce3737672c7bee /plugins/mod_s2s_bidi.lua
parent04f45b1afabb85163f72febd6000038102457812 (diff)
downloadprosody-ffbf4e39d2bfb4ffa36d5d8252da4b8004458a45.tar.gz
prosody-ffbf4e39d2bfb4ffa36d5d8252da4b8004458a45.zip
mod_s2s_bidi: Collect some metrics
Diffstat (limited to 'plugins/mod_s2s_bidi.lua')
-rw-r--r--plugins/mod_s2s_bidi.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/plugins/mod_s2s_bidi.lua b/plugins/mod_s2s_bidi.lua
index 22415293..3ef7aa3b 100644
--- a/plugins/mod_s2s_bidi.lua
+++ b/plugins/mod_s2s_bidi.lua
@@ -12,10 +12,15 @@ local xmlns_bidi = "urn:xmpp:bidi";
local require_encryption = module:get_option_boolean("s2s_require_encryption", true);
+local offers_sent = module:metric("counter", "offers_sent", "", "Bidirectional connection offers sent");
+local offers_recv = module:metric("counter", "offers_recv", "", "Bidirectional connection offers received");
+local offers_taken = module:metric("counter", "offers_taken", "", "Bidirectional connection offers taken");
+
module:hook("s2s-stream-features", function(event)
local origin, features = event.origin, event.features;
if origin.type == "s2sin_unauthed" and (not require_encryption or origin.secure) then
features:tag("bidi", { xmlns = xmlns_bidi_feature }):up();
+ offers_sent:with_labels():add(1);
end
end);
@@ -28,6 +33,7 @@ module:hook_tag("http://etherx.jabber.org/streams", "features", function (sessio
local request_bidi = st.stanza("bidi", { xmlns = xmlns_bidi });
module:fire_event("s2sout-stream-features", { origin = session, features = request_bidi });
session.sends2s(request_bidi);
+ offers_taken:with_labels():add(1);
end
end
end, 200);
@@ -36,6 +42,7 @@ module:hook_tag("urn:xmpp:bidi", "bidi", function(session)
if session.type == "s2sin_unauthed" and (not require_encryption or session.secure) then
session.log("debug", "Requested bidirectional stream");
session.outgoing = true;
+ offers_recv:with_labels():add(1);
return true;
end
end);