From 1578f1a10b90306041c887cfd03cb96bf9ff26d9 Mon Sep 17 00:00:00 2001 From: Aaron Chapman Date: Fri, 21 Jun 2019 16:39:31 -0400 Subject: [PATCH] add new relic tracers for backgroud jobs --- app/services/job_runner/lock_referee.rb | 16 ++++++++-------- config/initializers/new_relic_tracers.rb | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/app/services/job_runner/lock_referee.rb b/app/services/job_runner/lock_referee.rb index 9f884a9540c..b67aad64a2b 100644 --- a/app/services/job_runner/lock_referee.rb +++ b/app/services/job_runner/lock_referee.rb @@ -22,6 +22,14 @@ def acquire_lock_and_run_callback_if_needed log_done_message end + def log_executing_job_message + Rails.logger.info("#{job_configuration}: Executing job") + end + + def log_done_message + Rails.logger.debug("#{job_configuration}: Done") + end + private def run_needed? @@ -40,14 +48,6 @@ def log_race_lost_message Rails.logger.info(race_lost_message) end - def log_executing_job_message - Rails.logger.info("#{job_configuration}: Executing job") - end - - def log_done_message - Rails.logger.debug("#{job_configuration}: Done") - end - def log_run_not_needed_message(last_run) Rails.logger.info("#{job_configuration}: Not yet due to run. Last run: #{last_run}") end diff --git a/config/initializers/new_relic_tracers.rb b/config/initializers/new_relic_tracers.rb index 8ab0ae76993..43c3402a1b1 100644 --- a/config/initializers/new_relic_tracers.rb +++ b/config/initializers/new_relic_tracers.rb @@ -3,6 +3,7 @@ require 'new_relic/agent/method_tracer' require 'aws/ses' require 'cloudhsm_jwt' +require 'newrelic_rpm' Aws::SES::Base.class_eval do include ::NewRelic::Agent::MethodTracer @@ -81,3 +82,18 @@ add_method_tracer :place_call, "Custom/#{name}/place_call" add_method_tracer :send_sms, "Custom/#{name}/send_sms" end + +JobRunner::LockReferee.class_eval do + include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation + add_transaction_tracer :log_executing_job_message, :category => :task +end + +JobRunner::LockReferee.class_eval do + include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation + add_transaction_tracer :log_done_message, :category => :task +end + +UspsConfirmationUploader.class_eval do + include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation + add_transaction_tracer :run, :category => :task +end \ No newline at end of file