https://github.com/mjc-gh/sucker_punch-statsd
Seamlessly integrate statsd with your sucker_punch jobs
https://github.com/mjc-gh/sucker_punch-statsd
background-jobs monitoring ruby statsd
Last synced: over 1 year ago
JSON representation
Seamlessly integrate statsd with your sucker_punch jobs
- Host: GitHub
- URL: https://github.com/mjc-gh/sucker_punch-statsd
- Owner: mjc-gh
- License: mit
- Created: 2019-05-30T23:23:10.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-29T17:15:32.000Z (over 6 years ago)
- Last Synced: 2025-03-15T08:33:34.757Z (over 1 year ago)
- Topics: background-jobs, monitoring, ruby, statsd
- Language: Ruby
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# SuckerPunch::Statsd
This gem makes it easy to use statsd with
[sucker_punch](https://github.com/brandonhilkert/sucker_punch).
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'sucker_punch-statsd'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install sucker_punch-statsd
## Usage
First, configure `SuckerPunch::Statsd` with a `:client` and optional
`:namespace`.
```ruby
SuckerPunch::Statsd.configure client: statsd_client, prefix: 'my_app'
```
Now, include the module in any job class that you want to measure
```ruby
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
```
### Configuration Arguments
The `:client` argument should be a Statsd instance that
responds to a `measure` method. Any of the following should work:
- [statsd](https://github.com/reinh/statsd)
- [statsd-instrument](https://github.com/Shopify/statsd-instrument)
- [dogstatsd-ruby](https://github.com/DataDog/dogstatsd-ruby)
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.
## License
The gem is available as open source under the terms of the [MIT
License](https://opensource.org/licenses/MIT).
It was built in my spare time to support my work at
[Knotch](https://www.knotch.it), where we help make brands smarter!
## Code of Conduct
Everyone interacting in the SuckerPunch::Statsd project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mjc-gh/sucker_punch-statsd/blob/master/CODE_OF_CONDUCT.md).