diff --git a/app/services/user_access_key.rb b/app/services/user_access_key.rb index 4d4b94ad7a4..bc06e7e669d 100644 --- a/app/services/user_access_key.rb +++ b/app/services/user_access_key.rb @@ -9,8 +9,6 @@ # Store F (User.encrypted_password) and D (User.encryption_key) in db class UserAccessKey - include ::NewRelic::Agent::MethodTracer - attr_accessor :cost, :encrypted_d, :salt, :z1, :z2, :random_r def initialize(password:, salt:, cost: nil) @@ -86,7 +84,6 @@ def build(password, pw_salt) self.z1, self.z2 = build_segments(scrypted) self.random_r = Pii::Cipher.random_key end - add_method_tracer :build, 'Custom/UserAccessKey/build' def build_segments(scrypted) hashed = SCrypt::Password.new(scrypted).digest diff --git a/config/initializers/new_relic_tracers.rb b/config/initializers/new_relic_tracers.rb new file mode 100644 index 00000000000..4d07429e10b --- /dev/null +++ b/config/initializers/new_relic_tracers.rb @@ -0,0 +1,47 @@ +## Add NR tracers to methods so we can trace execution in the NR dashboard +## Ref: https://docs.newrelic.com/docs/agents/ruby-agent/api-guides/ruby-custom-instrumentation +require 'new_relic/agent/method_tracer' +require 'aws/ses' + +Aws::SES::Base.class_eval do + include ::NewRelic::Agent::MethodTracer + add_method_tracer :initialize, "Custom/#{name}/initialize" + add_method_tracer :deliver, "Custom/#{name}/deliver" + add_method_tracer :deliver!, "Custom/#{name}/deliver!" + add_method_tracer :ses_client, "Custom/#{name}/ses_client" +end + +ConfirmationEmailPresenter.class_eval do + include ::NewRelic::Agent::MethodTracer + add_method_tracer :initialize, "Custom/#{name}/initialize" + add_method_tracer :first_sentence, "Custom/#{name}/first_sentence" + add_method_tracer :confirmation_period, "Custom/#{name}/confirmation_period" +end + +CustomDeviseMailer.class_eval do + include ::NewRelic::Agent::MethodTracer + add_method_tracer :initialize, "Custom/#{name}/initialize" + add_method_tracer :confirmation_instructions, "Custom/#{name}/confirmation_instructions" + add_method_tracer :initialize_from_record, "Custom/#{name}/initialize_from_record" + add_method_tracer :mail, "Custom/#{name}/mail" +end + +Mail::Message.class_eval do + include ::NewRelic::Agent::MethodTracer + add_method_tracer :initialize, "Custom/#{name}/initialize" + add_method_tracer :deliver, "Custom/#{name}/deliver" + add_method_tracer :deliver!, "Custom/#{name}/deliver!" +end + +User.class_eval do + include ::NewRelic::Agent::MethodTracer + add_method_tracer :send_devise_notification, "Custom/#{name}/send_devise_notification" + add_method_tracer( + :send_custom_confirmation_instructions, "Custom/#{name}/send_custom_confirmation_instructions" + ) +end + +UserAccessKey.class_eval do + include ::NewRelic::Agent::MethodTracer + add_method_tracer :build, "Custom/#{name}/build" +end