A Ruby client for HostedGraphite
Add this line to your application's Gemfile:
gem 'hosted_graphite'
And then execute:
$ bundle
Or install it yourself as:
$ gem install hosted_graphite
Set ENV['HOSTEDGRAPHITE_APIKEY']
to your hosted graphite API key.
Your API key can be found on your account home page.
You can also set the hosted graphite API key programatically with:
HostedGraphite.api_key = 'YOUR API KEY'
HostedGraphite.protocol = :udp
HostedGraphite.send_metric('foo.udp', 1.2)
HostedGraphite.protocol = :tcp
HostedGraphite.send_metric('foo.tcp', 1.2)
HostedGraphite.protocol = :http
HostedGraphite.send_metric('foo.http', 1.2)
Enable Statsd on your account
Ensure these line are present in your application's Gemfile:
gem 'hosted_graphite'
gem 'statsd-ruby'
HostedGraphite.protocol = :statsd
# Send some stats
HostedGraphite.increment 'page_views'
HostedGraphite.decrement 'likes_count'
HostedGraphite.timing 'foo', 320
HostedGraphite.gauge 'bar', 100
# Use {#time} to time the execution of a block
HostedGraphite.time('newsletter.monthly') { @newsletter.deliver_now }
require 'hosted_graphite/ext/sidekiq'
Sidekiq.configure_server do |config|
config.server_middleware do |chain|
# my_app is an optional namespace
# chain.prepend HostedGraphite::Ext::Sidekiq::StatsdMetrics, 'my_app'
# or
# chain.prepend HostedGraphite::Ext::Sidekiq::Metrics
end
end
- Fork it ( https://github.com/seuros/hosted_graphite/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request