Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tracers to methods called by action mailer #2030

Merged
merged 1 commit into from
Feb 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app/services/user_access_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
47 changes: 47 additions & 0 deletions config/initializers/new_relic_tracers.rb
Original file line number Diff line number Diff line change
@@ -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