fiveruns-dash-rails 0.7.5 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +9 -1
- data/lib/fiveruns/dash/rails.rb +59 -0
- data/lib/fiveruns/dash/recipes/activerecord.rb +5 -5
- data/lib/fiveruns/dash/recipes/rails.rb +1 -1
- data/version.yml +1 -1
- metadata +2 -4
- data/lib/tasks/dash.rake +0 -57
data/README.rdoc
CHANGED
@@ -23,11 +23,19 @@ The FiveRuns Development Team & Dash community
|
|
23
23
|
* The fiveruns-dash-ruby gem (see http://github.com/fiveruns/dash-ruby)
|
24
24
|
* The json gem (as a dependency for fiveruns-dash-ruby)
|
25
25
|
|
26
|
+
== Verifying your setup
|
27
|
+
|
28
|
+
Once you've configured your app for Dash, you can run the following command to make sure everything is in order:
|
29
|
+
|
30
|
+
script/runner 'Fiveruns::Dash::Rails.verify'
|
31
|
+
|
32
|
+
This will make sure dash-rails is properly loaded, there are no known compatibility problems and that you've properly set your token and your app can communicate with the Dash servers.
|
33
|
+
|
26
34
|
== Rails versions
|
27
35
|
|
28
36
|
Dash has been tested with Rails 2.2 and 2.1. It may (or may not) work with Rails 2.0 applications.
|
29
37
|
|
30
|
-
We
|
38
|
+
We have verified an incompatibility that occurs when the +json+ gem is unpacked. The recommended workaround is to use a localized +GEM_HOME+ or a system gem.
|
31
39
|
|
32
40
|
== Platforms
|
33
41
|
|
data/lib/fiveruns/dash/rails.rb
CHANGED
@@ -98,6 +98,65 @@ if START_FIVERUNS_DASH_RAILS
|
|
98
98
|
ENV['RAILS_ENV'] # <= Rails 2.0
|
99
99
|
end
|
100
100
|
|
101
|
+
def self.verify
|
102
|
+
puts ""
|
103
|
+
puts "FiveRuns Dash installation verification"
|
104
|
+
puts "======================================="
|
105
|
+
puts ""
|
106
|
+
Fiveruns::Dash.logger = Logger.new(STDOUT)
|
107
|
+
Fiveruns::Dash.logger.level = Logger::WARN
|
108
|
+
test('FiveRuns Dash loaded',
|
109
|
+
'The FiveRuns Dash plugin has not been loaded. Verify you are initializing Dash in config/initializers/dash.rb.') do
|
110
|
+
defined? ::Fiveruns::Dash::Rails
|
111
|
+
end
|
112
|
+
test('FiveRuns Dash configuration',
|
113
|
+
"No application token was found for the #{Rails.env} environment.") do
|
114
|
+
Fiveruns::Dash.configuration.options[:app]
|
115
|
+
end
|
116
|
+
test('FiveRuns Dash session running', "FiveRuns Dash session is not active") do
|
117
|
+
Fiveruns::Dash.session.reporter.alive?
|
118
|
+
end
|
119
|
+
test('JSON compatibility', "Looks like you've run afoul of an ActiveSupport and JSON incompatibility. The easiest way to fix this is to load json from a gem, instead of unpacking it. See http://support.fiveruns.com/faqs/dash/json-compatibility for details.") do
|
120
|
+
begin
|
121
|
+
info = Fiveruns::Dash.session.info
|
122
|
+
payload = Fiveruns::Dash::InfoPayload.new(info, Time.now)
|
123
|
+
result = payload.to_json
|
124
|
+
rescue ArgumentError
|
125
|
+
false
|
126
|
+
end
|
127
|
+
end
|
128
|
+
test('FiveRuns Dash network connectivity') do
|
129
|
+
Fiveruns::Dash.session.reporter.ping
|
130
|
+
end
|
131
|
+
puts ""
|
132
|
+
puts "All appears normal. If you are experiencing a problem, please email support@fiveruns.com with details about the problem and your environment."
|
133
|
+
puts ""
|
134
|
+
rescue ArgumentError
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.test(test, fail=nil)
|
138
|
+
$test_count = ($test_count || 0) + 1
|
139
|
+
print " #{$test_count}. #{test}..."
|
140
|
+
begin
|
141
|
+
result = yield
|
142
|
+
if result
|
143
|
+
puts "OK." if fail
|
144
|
+
else
|
145
|
+
if fail
|
146
|
+
puts "FAIL!"
|
147
|
+
puts fail
|
148
|
+
end
|
149
|
+
raise ArgumentError
|
150
|
+
end
|
151
|
+
rescue ArgumentError => ex
|
152
|
+
raise ex
|
153
|
+
rescue => e
|
154
|
+
puts "FAIL!"
|
155
|
+
puts fail
|
156
|
+
raise e
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
101
160
|
module ActionContext
|
102
161
|
|
103
162
|
def self.included(base)
|
@@ -64,19 +64,19 @@ end
|
|
64
64
|
# ActiveRecord ################################################################
|
65
65
|
|
66
66
|
Fiveruns::Dash.register_recipe :activerecord, :url => 'http://dash.fiveruns.com' do |recipe|
|
67
|
-
recipe.time :ar_time, 'ActiveRecord Time', :methods => Fiveruns::Dash::ActiveRecordContext.all_methods, :reentrant => true
|
68
|
-
recipe.time :db_time, 'Database Time', :methods => %w(ActiveRecord::ConnectionAdapters::AbstractAdapter#log)
|
69
|
-
|
70
67
|
# We need a way to get the total time for a request/operation so that we can
|
71
68
|
# calculate the relative percentage used by AR/DB. Default to "response_time" for the Rails
|
72
69
|
# recipe but daemons can set this constant to provide their own total time metric.
|
73
70
|
total_time = recipe.options[:ar_total_time] ? recipe.options[:ar_total_time] : "response_time"
|
74
71
|
|
72
|
+
recipe.time :ar_time, 'ActiveRecord Time', :methods => Fiveruns::Dash::ActiveRecordContext.all_methods, :reentrant => true, :only_within => total_time
|
73
|
+
recipe.time :db_time, 'Database Time', :methods => %w(ActiveRecord::ConnectionAdapters::AbstractAdapter#log), :only_within => total_time
|
74
|
+
|
75
75
|
recipe.percentage :ar_util, 'ActiveRecord Utilization', :sources => ["ar_time", total_time] do |ar_time, all_time|
|
76
|
-
(ar_time / all_time) * 100.0
|
76
|
+
all_time == 0 ? 0 : (ar_time / all_time) * 100.0
|
77
77
|
end
|
78
78
|
recipe.percentage :db_util, 'Database Utilization', :sources => ["db_time", total_time] do |db_time, all_time|
|
79
|
-
(db_time / all_time) * 100.0
|
79
|
+
all_time == 0 ? 0 : (db_time / all_time) * 100.0
|
80
80
|
end
|
81
81
|
|
82
82
|
recipe.modify :recipe_name => :activerecord, :recipe_url => 'http://dash.fiveruns.com' do |metric|
|
@@ -15,7 +15,7 @@ end
|
|
15
15
|
|
16
16
|
# ActionPack ##################################################################
|
17
17
|
Fiveruns::Dash.register_recipe :actionpack, :url => 'http://dash.fiveruns.com' do |recipe|
|
18
|
-
recipe.time :response_time, :method => 'ActionController::Base#perform_action'
|
18
|
+
recipe.time :response_time, :method => 'ActionController::Base#perform_action', :mark => true
|
19
19
|
recipe.counter :requests, 'Requests', :incremented_by => 'ActionController::Base#perform_action'
|
20
20
|
|
21
21
|
targets = []
|
data/version.yml
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fiveruns-dash-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FiveRuns Development Team
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02-
|
12
|
+
date: 2009-02-06 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -45,8 +45,6 @@ files:
|
|
45
45
|
- lib/fiveruns/dash/recipes/rails.rb
|
46
46
|
- lib/fiveruns/dash/template_context.rb
|
47
47
|
- lib/fiveruns_dash_rails.rb
|
48
|
-
- lib/tasks
|
49
|
-
- lib/tasks/dash.rake
|
50
48
|
- rails/init.rb
|
51
49
|
- test/activerecord_test.rb
|
52
50
|
- test/test_helper.rb
|
data/lib/tasks/dash.rake
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
namespace :dash do
|
2
|
-
desc "Verify FiveRuns Dash connectivity and configuration"
|
3
|
-
task :test => :environment do
|
4
|
-
unless $tested
|
5
|
-
$tested = true
|
6
|
-
begin
|
7
|
-
puts ""
|
8
|
-
puts "FiveRuns Dash installation verification"
|
9
|
-
puts "======================================="
|
10
|
-
puts ""
|
11
|
-
RAILS_DEFAULT_LOGGER = Fiveruns::Dash.logger = Logger.new(STDOUT)
|
12
|
-
Fiveruns::Dash.logger.level = Logger::WARN
|
13
|
-
verify('FiveRuns Dash loaded',
|
14
|
-
'The FiveRuns Dash plugin has not been loaded. Verify you are initializing Dash in config/initializers/dash.rb.') do
|
15
|
-
defined? ::Fiveruns::Dash::Rails
|
16
|
-
end
|
17
|
-
verify('FiveRuns Dash configuration',
|
18
|
-
"No application token was found for the #{Rails.env} environment.") do
|
19
|
-
Fiveruns::Dash.configuration.options[:app]
|
20
|
-
end
|
21
|
-
verify('FiveRuns Dash session running', "FiveRuns Dash session is not active") do
|
22
|
-
Fiveruns::Dash.session.reporter.alive?
|
23
|
-
end
|
24
|
-
verify('FiveRuns Dash network connectivity') do
|
25
|
-
Fiveruns::Dash.session.reporter.ping
|
26
|
-
end
|
27
|
-
puts ""
|
28
|
-
puts "All appears normal. If you are experiencing a problem, please email support@fiveruns.com with details about the problem and your environment."
|
29
|
-
puts ""
|
30
|
-
rescue ArgumentError
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def verify(test, fail=nil)
|
37
|
-
$test_count = ($test_count || 0) + 1
|
38
|
-
print " #{$test_count}. #{test}..."
|
39
|
-
begin
|
40
|
-
result = yield
|
41
|
-
if result
|
42
|
-
puts "OK." if fail
|
43
|
-
else
|
44
|
-
if fail
|
45
|
-
puts "FAIL!"
|
46
|
-
puts fail
|
47
|
-
end
|
48
|
-
raise ArgumentError
|
49
|
-
end
|
50
|
-
rescue ArgumentError => ex
|
51
|
-
raise ex
|
52
|
-
rescue => e
|
53
|
-
puts "FAIL!"
|
54
|
-
puts fail
|
55
|
-
raise e
|
56
|
-
end
|
57
|
-
end
|