diff --git a/lib/patches_for_sentry.rb b/lib/patches_for_sentry.rb index 7f91dd1cb32075c7b6fa9d465e8d8a96cd74138a..3d75b7d819c343247a320ce36067d0fa7f04e933 100644 --- a/lib/patches_for_sentry.rb +++ b/lib/patches_for_sentry.rb @@ -52,3 +52,29 @@ module SentryEMHiredis end EM::Hiredis::Client.include SentryEMHiredis + +module SentryIQManager + def record_span(description) + transaction = Sentry.get_current_scope.get_transaction + return yield unless transaction&.sampled + + span = transaction.start_child( + op: "xmpp.iq", + description: description + ) + + yield.then { span.finish } + end + + def stanza_description(stanza) + node = stanza.respond_to?(:node) ? stanza.node : stanza.child&.name + "iq #{stanza.type} #{stanza.to} #{node}" + end + + def write(stanza) + # Outgoing IQ already logged by blather + record_span(stanza_description(stanza)) { super } + end +end + +IQ_MANAGER.extend SentryIQManager diff --git a/sgx_jmp.rb b/sgx_jmp.rb index 841b99a40892a239cd756e31879d4082893418c0..2c6dcd9db52dc3c0e91f9212a111aac51553c508 100644 --- a/sgx_jmp.rb +++ b/sgx_jmp.rb @@ -56,6 +56,16 @@ singleton_class.class_eval do Blather::DSL.append_features(self) end +require_relative "lib/session_manager" + +IQ_MANAGER = SessionManager.new(self, :id) +COMMAND_MANAGER = SessionManager.new( + self, + :sessionid, + timeout: 60 * 60, + error_if: ->(s) { s.cancel? } +) + require_relative "lib/polyfill" require_relative "lib/alt_top_up_form" require_relative "lib/admin_command" @@ -89,7 +99,6 @@ require_relative "lib/postgres" require_relative "lib/registration" require_relative "lib/transaction" require_relative "lib/tel_selections" -require_relative "lib/session_manager" require_relative "lib/snikket" require_relative "lib/statsd" require_relative "web" @@ -357,14 +366,6 @@ message do |m| } end -IQ_MANAGER = SessionManager.new(self, :id) -COMMAND_MANAGER = SessionManager.new( - self, - :sessionid, - timeout: 60 * 60, - error_if: ->(s) { s.cancel? } -) - disco_info to: Blather::JID.new(CONFIG[:component][:jid]) do |iq| reply = iq.reply reply.identities = [{