measuring using middleware

13 views
Skip to first unread message

John Bachir

unread,
Jun 19, 2015, 9:23:54 PM6/19/15
to sid...@googlegroups.com
I want to do two things:

1. keep track of the size of the backlog (see also: https://groups.google.com/forum/#!topic/sidekiq/SyzhnO_U_DM )
2. measure how long each type of worker takes to run

I want to use Librato for both of these: https://github.com/librato/librato-rails#quick-start

I'm thinking to do something like this:

class AcmeCo::MyMiddleware
  def call(worker_class, msg, queue)
    Librato.timing "sidekiq.#{worker_class}" do
      yield
    end
    queue_constant = "Sidekiq::#{queue.capitalize}".constantize
    Librato.measure "sidekiq.queue_size.#{queue}", queue_constant.new.size
  end
end

(the Librato namespacing may be changed, I need to look into their conventions)

Any feedback is highly appreciated!

John

Mike Perham

unread,
Jun 19, 2015, 11:25:26 PM6/19/15
to sid...@googlegroups.com
That's about it.  Pretty straightforward.

--
You received this message because you are subscribed to the Google Groups "Sidekiq" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sidekiq+u...@googlegroups.com.
To post to this group, send email to sid...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sidekiq/e0f31d1c-5734-4e88-8845-6c9826ccca3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Mike Perham – CEO, Contributed Systems
Smart, effective open source infrastructure for your apps.

John Bachir

unread,
Jul 3, 2015, 10:08:24 PM7/3/15
to sid...@googlegroups.com
Here's my final code that I went with (using the librato-metrics gem, not the librato-rails gem):

class SidekiqMetrics
  def call(worker, msg, queue)
    librato_queue = Librato::Metrics::Queue.new
    librato_queue.time "sidekiq.execution_time", source: worker.class.to_s.underscore.gsub("/","-") do
      yield
    end

    librato_queue.submit
  end
end

Reply all
Reply to author
Forward
0 new messages