This gem makes it easy to use statsd with sucker_punch.
Add this line to your application's Gemfile:
gem 'sucker_punch-statsd'
And then execute:
$ bundle
Or install it yourself as:
$ gem install sucker_punch-statsd
First, configure SuckerPunch::Statsd
with a :client
and optional
:namespace
.
SuckerPunch::Statsd.configure client: statsd_client, prefix: 'my_app'
Now, include the module in any job class that you want to measure
class LogJob
include SuckerPunch::Job
include SuckerPunch::Statsd
# The perform method is automatically wrapped in a Statsd measure
# block.
def perform
Log.new(event).track
end
end
The :client
argument should be a Statsd instance that
responds to a measure
method. Any of the following should work:
The measure metrics produced by this gem will use the Job's class name
as the metric name. The optional :namespace
argument will be prepended
to every metric name when this argument is provided.
The gem is available as open source under the terms of the MIT License.
It was built in my spare time to support my work at Knotch, where we help make brands smarter!
Everyone interacting in the SuckerPunch::Statsd project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.