-
-
Save fbjork/5451e660a973c3d353e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AbstractWorker | |
include Sidekiq::Worker | |
include ActiveSupport::Benchmarkable | |
include NewRelic::Agent::Instrumentation::ControllerInstrumentation | |
def wrap(description, &block) | |
begin | |
description = "#{self}(#{description})" | |
benchmark(description, level: :debug) do | |
Mongoid.unit_of_work { yield } | |
end | |
rescue Exception => e | |
Rails.logger.error("Error processing job: #{description}: #{e}\n" + e.backtrace.join("\n")) | |
# TODO: Should email notify. | |
raise e | |
end | |
end | |
def perform | |
raise NotImplementedError | |
end | |
add_transaction_tracer :perform, category: :task | |
def logger | |
Rails.logger | |
end | |
end |
Howdy - I work at New Relic, and we've recently released a beta of the newrelic_rpm gem that includes official Sidekiq support, which you can find here:
http://rubygems.org/gems/newrelic_rpm/versions/3.6.0.74.beta
We'd love to hear any feedback you have on it - feel free to contact me directly with feedback.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This has worked for me but seemed to cause problems with thread safety and I stated to get hanging sidekiq workers and thread errors.