[Ruby] Cron job, invoking Rails model class method, not added to non-web Transactions

I am trying to monitor certain cron job, which runs each minute:

every 1.minutes do
runner ‘Order.schedule’, …
end

Inside Order model i’ve made following changes:

require 'newrelic_rpm'

class Order < ApplicationRecord

def self.schedule
‘Some code’
end

class << self
include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation

add_transaction_tracer :schedule, :category => :task

end

After deploying the above code , I can not see any changes in Transactions under Non-web transactions.

Anything that I’m doing wrong?

P.S. New Relic is up and running, showing both Web and Non-Web transactions, except this change is not modifying/adding new non-web transaction in the UI.

Hi @kevin.leuvering

It looks like your Order class is utilizing class inheritance. Given that have you reviewed the solutions outlined in this post to see if implementing one of them might resolve this issue?

Thanks,

I was able to fix the issue by wrapping the entire cron job with a tracer. If anyone has similar issue, this might come handy: ruby on rails - How to trap errors in Whenever cron jobs? - Stack Overflow

1 Like