# HG changeset patch # User Kim Alvefur # Date 1723389947 -7200 # Node ID 4fb6a3eb9c29f9a8608161d651474a567a7437fe # Parent 1b81a7b7c9b8b4b10ccafd09af6caa129db16da6 mod_s2s_bidi: Collect some metrics diff -r 1b81a7b7c9b8 -r 4fb6a3eb9c29 plugins/mod_s2s_bidi.lua --- a/plugins/mod_s2s_bidi.lua Fri Aug 09 20:23:46 2024 +0200 +++ b/plugins/mod_s2s_bidi.lua Sun Aug 11 17:25:47 2024 +0200 @@ -12,10 +12,15 @@ 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 @@ 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 @@ 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);