Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@fbjork
Created February 14, 2012 02:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fbjork/5451e660a973c3d353e7 to your computer and use it in GitHub Desktop.
Save fbjork/5451e660a973c3d353e7 to your computer and use it in GitHub Desktop.
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
@bnorton
Copy link

bnorton commented Dec 17, 2012

This has worked for me but seemed to cause problems with thread safety and I stated to get hanging sidekiq workers and thread errors.

@benweint
Copy link

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