~singpolyma/sgx-jmp

633d2094118c19ce31c4f015a44624f575ca6852 — Stephen Paul Weber 1 year, 10 months ago 2b25bd9
Spans for iqs
2 files changed, 36 insertions(+), 9 deletions(-)

M lib/patches_for_sentry.rb
M sgx_jmp.rb
M lib/patches_for_sentry.rb => lib/patches_for_sentry.rb +26 -0
@@ 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

M sgx_jmp.rb => sgx_jmp.rb +10 -9
@@ 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 = [{