resque-statsd 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ # gem "rspec", "~> 2.3.0"
10
+ gem "yard", "~> 0.6.0"
11
+ gem "bundler", "~> 1.0.0"
12
+ gem "jeweler", "~> 1.5.2"
13
+ # gem "rcov", ">= 0"
14
+ end
15
+
16
+ gem 'jamster-statsd'
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jamster-statsd (0.1.0)
6
+ jeweler (1.5.2)
7
+ bundler (~> 1.0.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ rake (0.8.7)
11
+ yard (0.6.5)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ bundler (~> 1.0.0)
18
+ jamster-statsd
19
+ jeweler (~> 1.5.2)
20
+ yard (~> 0.6.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Jason Amster
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,45 @@
1
+ = resque-statsd
2
+
3
+ Resque Statsd is a Resque plugin that will wrap the enqueueing, performing, failing, as well as timeing job run times withing Graphite monitoring.
4
+
5
+ == CURRENT STATUS
6
+
7
+ COMPLETELY UNTESTED (NOT EVEN TRIED OUT)
8
+
9
+ == Background Reading
10
+
11
+ === Graphite
12
+
13
+ http://graphite.wikidot.com/
14
+
15
+ === StatsD Comes From Etsy
16
+
17
+ The folks at Etsy (kastner) have come up with a neat node.js app to listen for Graphite stats.
18
+
19
+ * http://codeascraft.etsy.com/2010/12/08/track-every-release/
20
+ * http://codeascraft.etsy.com/2011/02/15/measure-anything-measure-everything/
21
+ * https://github.com/etsy/statsd
22
+
23
+ === Ruby StatsD Client
24
+
25
+ I've required a particular version (jnunemaker's) of the ruby StatsD client
26
+ Read the post here
27
+
28
+ * http://railstips.org/blog/archives/2011/03/21/hi-my-name-is-john/
29
+ * A Ruby statsd client (https://github.com/etsy/statsd)
30
+
31
+ == Contributing to resque-statsd
32
+
33
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
34
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
35
+ * Fork the project
36
+ * Start a feature/bugfix branch
37
+ * Commit and push until you are happy with your contribution
38
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
39
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
40
+
41
+ == Copyright
42
+
43
+ Copyright (c) 2011 Jason Amster. See LICENSE.txt for
44
+ further details.
45
+
data/Rakefile ADDED
@@ -0,0 +1,43 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "resque-statsd"
16
+ gem.homepage = "http://github.com/jamster/resque-statsd"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Adds simple counters and timers for statsd into your Resque jobs}
19
+ gem.description = %Q{Will add a counter for enqueuing, performing, failing and timing Jobs}
20
+ gem.email = "jayamster@gmail.com"
21
+ gem.authors = ["Jason Amster"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ # require 'rspec/core'
30
+ # require 'rspec/core/rake_task'
31
+ # RSpec::Core::RakeTask.new(:spec) do |spec|
32
+ # spec.pattern = FileList['spec/**/*_spec.rb']
33
+ # end
34
+ #
35
+ # RSpec::Core::RakeTask.new(:rcov) do |spec|
36
+ # spec.pattern = 'spec/**/*_spec.rb'
37
+ # spec.rcov = true
38
+ # end
39
+ #
40
+ # task :default => :spec
41
+
42
+ require 'yard'
43
+ YARD::Rake::YardocTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,31 @@
1
+ module Resque
2
+ module Plugins
3
+ module Statsd
4
+
5
+ def after_enqueue_statsd(*args)
6
+ $resque_statsd.increment("#{@queue}.en@queued")
7
+ $resque_statsd.increment("total.en@queued")
8
+
9
+ end
10
+
11
+ def after_perform_statsd(*args)
12
+ $resque_statsd.increment("#{@queue}.finished")
13
+ $resque_statsd.increment("total.finished")
14
+ end
15
+
16
+ def on_failure_statsd(*args)
17
+ $resque_statsd.increment("#{@queue}.failed")
18
+ $resque_statsd.increment("total.failed")
19
+ end
20
+
21
+ def around_perform_statsd(*args)
22
+ $resque_statsd.time("#{@queue}.processed") do
23
+ yield
24
+ end
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+
31
+
@@ -0,0 +1,20 @@
1
+ require 'rubygems'
2
+ require 'statsd' # Really Jnunemakers's mine branch of statsd
3
+ require 'resque/plugins/statsd'
4
+
5
+ # Set up the client
6
+ $resque_statsd = Statsd.new(ENV['GRAPHITE_HOST'], 8125)
7
+ $resque_statsd.namespace="#{ENV['APP_NAME']}_#{ENV['RAILS_ENV']}.resque"
8
+ puts $resque_statsd.namespace
9
+
10
+
11
+
12
+ module Resque
13
+ module Plugins
14
+ module Statsd
15
+
16
+ VERSION = "0.0.1"
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "ResqueStatsd" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'resque-statsd'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: resque-statsd
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 0
10
+ version: 0.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Jason Amster
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-23 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ type: :runtime
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ version_requirements: *id001
33
+ name: jamster-statsd
34
+ prerelease: false
35
+ - !ruby/object:Gem::Dependency
36
+ type: :development
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ hash: 7
43
+ segments:
44
+ - 0
45
+ - 6
46
+ - 0
47
+ version: 0.6.0
48
+ version_requirements: *id002
49
+ name: yard
50
+ prerelease: false
51
+ - !ruby/object:Gem::Dependency
52
+ type: :development
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 23
59
+ segments:
60
+ - 1
61
+ - 0
62
+ - 0
63
+ version: 1.0.0
64
+ version_requirements: *id003
65
+ name: bundler
66
+ prerelease: false
67
+ - !ruby/object:Gem::Dependency
68
+ type: :development
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ hash: 7
75
+ segments:
76
+ - 1
77
+ - 5
78
+ - 2
79
+ version: 1.5.2
80
+ version_requirements: *id004
81
+ name: jeweler
82
+ prerelease: false
83
+ description: Will add a counter for enqueuing, performing, failing and timing Jobs
84
+ email: jayamster@gmail.com
85
+ executables: []
86
+
87
+ extensions: []
88
+
89
+ extra_rdoc_files:
90
+ - LICENSE.txt
91
+ - README.rdoc
92
+ files:
93
+ - .document
94
+ - .rspec
95
+ - Gemfile
96
+ - Gemfile.lock
97
+ - LICENSE.txt
98
+ - README.rdoc
99
+ - Rakefile
100
+ - VERSION
101
+ - lib/resque-statsd.rb
102
+ - lib/resque/plugins/statsd.rb
103
+ - spec/resque-statsd_spec.rb
104
+ - spec/spec_helper.rb
105
+ has_rdoc: true
106
+ homepage: http://github.com/jamster/resque-statsd
107
+ licenses:
108
+ - MIT
109
+ post_install_message:
110
+ rdoc_options: []
111
+
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ hash: 3
120
+ segments:
121
+ - 0
122
+ version: "0"
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ hash: 3
129
+ segments:
130
+ - 0
131
+ version: "0"
132
+ requirements: []
133
+
134
+ rubyforge_project:
135
+ rubygems_version: 1.6.2
136
+ signing_key:
137
+ specification_version: 3
138
+ summary: Adds simple counters and timers for statsd into your Resque jobs
139
+ test_files:
140
+ - spec/resque-statsd_spec.rb
141
+ - spec/spec_helper.rb