From ffbf4e39d2bfb4ffa36d5d8252da4b8004458a45 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 11 Aug 2024 17:25:47 +0200 Subject: mod_s2s_bidi: Collect some metrics --- plugins/mod_s2s_bidi.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'plugins') 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); -- cgit v1.2.3