flyerhzm/bullet

Using Bullet With Sidekiq Worker Middleware

dalezak opened this issue · 3 comments

I'm trying to get Bullet to work with Sidekiq workers, however having an issue with stack trace.

Here's my middleware:

module Sidekiq
  module Middleware
    class BulletProfiler
      def call(worker, job, queue)
        if defined?(Bullet) && Bullet.enable?
          Bullet.profile do
            yield
          end
        else
          yield
        end
      end
    end
  end  
end  

And here's how I add server_middleware to Sidekiq.

Sidekiq.configure_server do |config|
  config.server_middleware do |chain|
    chain.add Sidekiq::Middleware::BulletProfiler
  end
end

It appears to be working, however stacktrace says sidekiq_middleware_bullet_profiler and not the actual background worker.

AVOID eager loading detected
 User => [:transactions, :sites]
 Remove from your query: .includes([:transactions, :sites])
Call stack
 /src/base/config/initializers/sidekiq_middleware_bullet_profiler.rb:6:in `call'

I tried adding stacktrace_excludes but it doesn't seem to help.

Bullet.stacktrace_excludes = ['sidekiq_middleware_bullet_profiler.rb']

Any ideas how the stack trace could show the actual worker instead of the middleware?

I used bullet 7.0.4 in a rails project with sidekiq, but I do see correct stacktrace in log.

Thanks @flyerhzm, we'll upgrade to 7.0.4 and see if it helps 👍

I believe the problem might be on our end due to our use of sub projects, closing issue.