~singpolyma/sgx-jmp

5b36a8cd3f3f94f3006ffcbe879948a66e96992c — Stephen Paul Weber 1 year, 10 months ago 2c2975d
Funnel statsd for registration
2 files changed, 35 insertions(+), 1 deletions(-)

A lib/statsd.rb
M sgx_jmp.rb
A lib/statsd.rb => lib/statsd.rb +33 -0
@@ 0,0 1,33 @@
# frozen_string_literal: true

require "statsd-instrument"

# These are basically data, not code, I find them more readable on one line each
# rubocop:disable Metrics/LineLength

Registration::Registered.extend StatsD::Instrument
Registration::Registered.statsd_count :write, "registration.registered"

Registration::Activation.extend StatsD::Instrument
Registration::Activation.statsd_count :write, "registration.activation"

Registration::Payment::Bitcoin.extend StatsD::Instrument
Registration::Payment::Bitcoin.statsd_count :write, "registration.payment.bitcoin"

Registration::Payment::CreditCard.extend StatsD::Instrument
Registration::Payment::CreditCard.statsd_count :write, "registration.payment.credit_card"

Registration::Payment::CreditCard::Activate.extend StatsD::Instrument
Registration::Payment::CreditCard::Activate.statsd_count :write, "registration.payment.credit_card.activate"
Registration::Payment::CreditCard::Activate.statsd_count :declined, "registration.payment.credit_card.activate_declined"

Registration::Payment::InviteCode.extend StatsD::Instrument
Registration::Payment::InviteCode.statsd_count :write, "registration.payment.invite_code"

Registration::Payment::Mail.extend StatsD::Instrument
Registration::Payment::Mail.statsd_count :write, "registration.payment.mail"

Registration::Finish.extend StatsD::Instrument
Registration::Finish.statsd_count :write, "registration.payment.finish"

# rubocop:enable Metrics/LineLength

M sgx_jmp.rb => sgx_jmp.rb +2 -1
@@ 39,6 39,7 @@ require_relative "lib/payment_methods"
require_relative "lib/registration"
require_relative "lib/transaction"
require_relative "lib/web_register_manager"
require_relative "lib/statsd"

ELECTRUM = Electrum.new(**CONFIG[:electrum])



@@ 368,7 369,7 @@ command :execute?, node: "jabber:iq:register", sessionid: nil do |iq|
			iq,
			customer,
			web_register_manager
		).then(&:write)
		).then(&:write).then { StatsD.increment("registration.completed") }
	}.catch_only(Blather::Stanza) { |reply|
		self << reply
	}.catch { |e| panic(e, sentry_hub) }