statify 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.rdoc +4 -1
- data/Gemfile +2 -3
- data/README.md +13 -5
- data/Rakefile +1 -1
- data/lib/statify.rb +50 -42
- data/lib/statify/version.rb +1 -1
- data/statify.gemspec +3 -3
- metadata +27 -48
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2aaaa4b73b1745e8e89525bac18f9bddd12b6cea
|
4
|
+
data.tar.gz: 0e659c97cb0c2f5cfbf06e045ada161dcac8e759
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7f270745229a128bc248898a33b01b2bfa0e36c4dcefc9e5b7efa2324cb4e66f05306b46e70acf6613c6e968f33be753aa29adf542a8b4ba9ed2278e0c35f022
|
7
|
+
data.tar.gz: 9549f3b21247da82c4b202870f02f3f2f61a48a0aa4df46d521ea83432c9112c078cf60f6d1bdad932a64263fbcbc4b28e531c600a3c5ecb045a67889f3025c2
|
data/.travis.yml
ADDED
data/CHANGELOG.rdoc
CHANGED
data/Gemfile
CHANGED
@@ -2,13 +2,12 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in statify.gemspec
|
4
4
|
gemspec
|
5
|
+
gem 'statsd', '~> 0.5.4'
|
6
|
+
gem "statsd-ruby", '~> 1.2.0'#, :require => "statsd"
|
5
7
|
|
6
|
-
gem "statsd-ruby", :require => "statsd"
|
7
8
|
# We need atleast activesupport
|
8
9
|
gem 'rails', '~> 3.0'
|
9
10
|
|
10
|
-
gem 'debugger'
|
11
|
-
|
12
11
|
group :deveopment, :test do
|
13
12
|
gem 'rspec-rails'
|
14
13
|
end
|
data/README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# Statify
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/Spokeo/statify.png?branch=master)](https://travis-ci.org/Spokeo/statify)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
-
|
5
|
+
Pop this gem in your rails >= 3 application. Simply give this gem the location of your statsd instance and it can seamlessly track the following:
|
6
|
+
|
7
|
+
- Performance stats broken down by controller and action and further broken down by view, database, and overall runtimes
|
8
|
+
- Overall SQL calls durations
|
9
|
+
- Ruby garbage collection stats (this will run after every controller response cycle)
|
8
10
|
- Cache hit and miss rates
|
9
11
|
|
10
12
|
## Installation
|
@@ -34,10 +36,16 @@ In your Rails App put these following lines in your config/application.rb:
|
|
34
36
|
|
35
37
|
Obviously put in the address of your own statsD ip address and port into the statsd.new call. The categories are opt-in, so put in what you want to use.
|
36
38
|
|
39
|
+
### Ruby Notes
|
40
|
+
|
41
|
+
Ruby 1.8.7: 1.8.7 has a different call for GC stats that I haven't looked into it yet. You can install this gem on your 1.8.7 codebase for now just omit the garbage_collection category.
|
42
|
+
|
43
|
+
|
44
|
+
|
37
45
|
|
38
46
|
### Supported categories
|
39
47
|
|
40
|
-
- garbage_collection
|
48
|
+
- garbage_collection
|
41
49
|
- controller
|
42
50
|
- cache
|
43
51
|
- sql
|
data/Rakefile
CHANGED
@@ -19,6 +19,6 @@ require 'rspec/core'
|
|
19
19
|
require 'rspec/core/rake_task'
|
20
20
|
|
21
21
|
desc "Run all specs in spec directory (excluding plugin specs)"
|
22
|
-
RSpec::Core::RakeTask.new(:spec => 'app:db:
|
22
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:migrate')
|
23
23
|
|
24
24
|
task :default => :spec
|
data/lib/statify.rb
CHANGED
@@ -22,64 +22,72 @@ module Statify
|
|
22
22
|
|
23
23
|
def self.categories=(categories)
|
24
24
|
@@categories = categories
|
25
|
+
|
26
|
+
# If you're running ruby-1.8.7 and your trying to get GC stats
|
27
|
+
if @@categories.include?(:garbage_collection)
|
28
|
+
if RUBY_VERSION < '1.9'
|
29
|
+
# Fail and tell the user to remove the GC stats
|
30
|
+
fail "The GC stats don't work in Ruby 1.8.7. Please remove the :grabage_collection from the categories"
|
31
|
+
@@stats.delete(:grabage_collection)
|
32
|
+
end
|
33
|
+
end
|
25
34
|
end
|
26
35
|
|
27
36
|
def self.categories
|
28
37
|
@@categories
|
29
38
|
end
|
30
39
|
|
31
|
-
|
32
40
|
def self.subscribe
|
33
41
|
if Statify.categories.include?(:sql)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
42
|
+
# This should give us reports on response times to queries
|
43
|
+
ActiveSupport::Notifications.subscribe "sql.active_record" do |*args|
|
44
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
45
|
+
# Don't include explains or schema DB calls
|
46
|
+
unless ["EXPLAIN", "SCHEMA"].include?(event.payload[:name])
|
47
|
+
# # We are hoping this gives us basic metris for query durations for us to track.
|
48
|
+
@@statsd.timing "#{event.name}", event.duration
|
42
49
|
end
|
43
50
|
end
|
51
|
+
end
|
44
52
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
53
|
+
if Statify.categories.include?(:garbage_collection) || Statify.categories.include?(:controller)
|
54
|
+
# This should give us reports on average response times by controller and action
|
55
|
+
ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*args|
|
56
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
57
|
+
|
58
|
+
if Statify.categories.include?(:garbage_collection)
|
59
|
+
# Let's log the GC
|
60
|
+
gc_stats = GC::stat
|
61
|
+
@@statsd.count('gc_count', gc_stats[:count])
|
62
|
+
@@statsd.count('gc_heap_used', gc_stats[:heap_used])
|
63
|
+
@@statsd.count('gc_heap_length', gc_stats[:heap_length])
|
64
|
+
@@statsd.count('gc_heap_increment', gc_stats[:heap_increment])
|
65
|
+
@@statsd.count('gc_heap_live_num', gc_stats[:heap_live_num])
|
66
|
+
@@statsd.count('gc_heap_free_num', gc_stats[:heap_live_num])
|
67
|
+
@@statsd.count('gc_heap_final_num', gc_stats[:heap_live_num])
|
68
|
+
end
|
61
69
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
70
|
+
if Statify.categories.include?(:controller)
|
71
|
+
# Track overall, db and view durations
|
72
|
+
@@statsd.timing "overall_duration|#{event.payload[:controller]}/#{event.payload[:action]}", event.duration
|
73
|
+
@@statsd.timing "db_runtime|#{event.payload[:controller]}/#{event.payload[:action]}", event.payload[:db_runtime]
|
74
|
+
@@statsd.timing "view_runtime|#{event.payload[:controller]}/#{event.payload[:action]}", event.payload[:view_runtime]
|
68
75
|
end
|
69
76
|
end
|
77
|
+
end
|
70
78
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
79
|
+
if Statify.categories.include?(:cache)
|
80
|
+
# I want to keep track of how many cache hits we get as opposed to cache misses
|
81
|
+
ActiveSupport::Notifications.subscribe "cache_fetch_hit.active_support" do |*args|
|
82
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
83
|
+
@@statsd.increment('cache_hit', 1)
|
84
|
+
end
|
77
85
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
end
|
86
|
+
# I want to keep track of how many cache misses we get as opposed to cache hits
|
87
|
+
ActiveSupport::Notifications.subscribe "cache_write.active_support" do |*args|
|
88
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
89
|
+
@@statsd.increment('cache_miss', 1)
|
83
90
|
end
|
91
|
+
end
|
84
92
|
end
|
85
93
|
end
|
data/lib/statify/version.rb
CHANGED
data/statify.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.email = ["austin@spokeo.com"]
|
11
11
|
gem.description = "Pop this gem in your rails >= 3 application. This gem will utilize statsd and easily track basic performance stats for your application."
|
12
12
|
gem.summary = "Pop this gem in your rails >= 3 application. This gem will utilize statsd and easily track basic performance stats for your application."
|
13
|
-
gem.homepage = "
|
13
|
+
gem.homepage = "https://github.com/spokeo/statify"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -23,6 +23,6 @@ Gem::Specification.new do |gem|
|
|
23
23
|
gem.add_development_dependency 'rails'
|
24
24
|
gem.add_development_dependency 'statsd'
|
25
25
|
|
26
|
-
gem.add_dependency 'statsd'
|
27
|
-
gem.add_dependency 'statsd-ruby'
|
26
|
+
gem.add_dependency 'statsd', '~> 0.5.4'
|
27
|
+
gem.add_dependency 'statsd-ruby', '~> 1.2.0'
|
28
28
|
end
|
metadata
CHANGED
@@ -1,128 +1,113 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Austin Fonacier
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-03-14 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: sqlite3
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rails
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: statsd
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - '>='
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - '>='
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: statsd
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - ~>
|
100
88
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
89
|
+
version: 0.5.4
|
102
90
|
type: :runtime
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - ~>
|
108
95
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
96
|
+
version: 0.5.4
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: statsd-ruby
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - ~>
|
116
102
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
103
|
+
version: 1.2.0
|
118
104
|
type: :runtime
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - ~>
|
124
109
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
110
|
+
version: 1.2.0
|
126
111
|
description: Pop this gem in your rails >= 3 application. This gem will utilize statsd
|
127
112
|
and easily track basic performance stats for your application.
|
128
113
|
email:
|
@@ -133,6 +118,7 @@ extra_rdoc_files: []
|
|
133
118
|
files:
|
134
119
|
- .gitignore
|
135
120
|
- .rspec
|
121
|
+
- .travis.yml
|
136
122
|
- CHANGELOG.rdoc
|
137
123
|
- Gemfile
|
138
124
|
- LICENSE.txt
|
@@ -207,35 +193,28 @@ files:
|
|
207
193
|
- spec/spec_helper.rb
|
208
194
|
- spec/sql_notification_spec.rb
|
209
195
|
- statify.gemspec
|
210
|
-
homepage:
|
196
|
+
homepage: https://github.com/spokeo/statify
|
211
197
|
licenses: []
|
198
|
+
metadata: {}
|
212
199
|
post_install_message:
|
213
200
|
rdoc_options: []
|
214
201
|
require_paths:
|
215
202
|
- lib
|
216
203
|
required_ruby_version: !ruby/object:Gem::Requirement
|
217
|
-
none: false
|
218
204
|
requirements:
|
219
|
-
- -
|
205
|
+
- - '>='
|
220
206
|
- !ruby/object:Gem::Version
|
221
207
|
version: '0'
|
222
|
-
segments:
|
223
|
-
- 0
|
224
|
-
hash: 3261311351692405632
|
225
208
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
226
|
-
none: false
|
227
209
|
requirements:
|
228
|
-
- -
|
210
|
+
- - '>='
|
229
211
|
- !ruby/object:Gem::Version
|
230
212
|
version: '0'
|
231
|
-
segments:
|
232
|
-
- 0
|
233
|
-
hash: 3261311351692405632
|
234
213
|
requirements: []
|
235
214
|
rubyforge_project:
|
236
|
-
rubygems_version:
|
215
|
+
rubygems_version: 2.0.0
|
237
216
|
signing_key:
|
238
|
-
specification_version:
|
217
|
+
specification_version: 4
|
239
218
|
summary: Pop this gem in your rails >= 3 application. This gem will utilize statsd
|
240
219
|
and easily track basic performance stats for your application.
|
241
220
|
test_files:
|