Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

setting up client

  • Loading branch information...
commit 1ee3b197fae0a368f5633de3233e894f8884a9ce 1 parent c2e2345
@jamster authored
Showing with 20 additions and 11 deletions.
  1. +10 −3 lib/resque-statsd.rb
  2. +10 −8 lib/resque/plugins/statsd.rb
View
13 lib/resque-statsd.rb
@@ -1,13 +1,20 @@
require 'rubygems'
require 'statsd' # Really Jnunemakers's mine branch of statsd
-$statsd = Statsd.new(ENV['GRAPHITE_HOST'], 8125)
-$statsd.namespace="#{ENV['APP_NAME']}_#{ENV['RAILS_ENV']}.resque"
+require 'resque/plugins/statsd'
+
+# Set up the client
+$resque_statsd = Statsd.new(ENV['GRAPHITE_HOST'], 8125)
+$resque_statsd.namespace="#{ENV['APP_NAME']}_#{ENV['RAILS_ENV']}.resque"
+puts $resque_statsd.namespace
+
+
module Resque
module Plugins
module Statsd
+
VERSION = "0.0.1"
+
end
end
end
-
View
18 lib/resque/plugins/statsd.rb
@@ -1,25 +1,25 @@
module Resque
module Plugins
module Statsd
-
+
def after_enqueue_statsd(*args)
- $statsd.increment("#{@queue}.enqueued")
- $statsd.increment("total.enqueued")
+ $resque_statsd.increment("#{@queue}.en@queued")
+ $resque_statsd.increment("total.en@queued")
end
def after_perform_statsd(*args)
- $statsd.increment("#{@queue}.finished")
- $statsd.increment("total.finished")
+ $resque_statsd.increment("#{@queue}.finished")
+ $resque_statsd.increment("total.finished")
end
def on_failure_statsd(*args)
- $statsd.increment("#{@queue}.failed")
- $statsd.increment("total.failed")
+ $resque_statsd.increment("#{@queue}.failed")
+ $resque_statsd.increment("total.failed")
end
def around_perform_statsd(*args)
- $statsd.time("#{@queue}.processed") do
+ $resque_statsd.time("#{@queue}.processed") do
yield
end
end
@@ -27,3 +27,5 @@ def around_perform_statsd(*args)
end
end
end
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.