rack-metrics 0.2.0 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fef07a7c21b2fc9e7eae4003d64f75e5ee0972de
4
- data.tar.gz: 4fe8867da81f4f9510813699dab1ee80af64f121
3
+ metadata.gz: 3de48a8bcf3f5ac836018a935b8d6d78261192de
4
+ data.tar.gz: 92e9866fc44a73a8cbc2a03eba42d4ebb696bc75
5
5
  SHA512:
6
- metadata.gz: 5b6a8e2ee0a2b0601edb901bfbf956cc8f024d223e0db289b06c99459a41d390116dee03f1266ab9161c3cebd0c0229516873415a7835bb7d0aabdbbee1e9b4f
7
- data.tar.gz: 27bafde80fafbcb5de8d40b0129210b39ecbdd152d6adb6ffdde77d387ef610530596089f8ef86fde206b508f27da779d98f74e9254ffb27017333ed7b9fe59a
6
+ metadata.gz: 0486d7ff39469aeed504055eed2c57d97247392e2fadb677a9216155f87c59412c67a32668689bbd9d308e949c00eaec1883052fcfa0c2a472b69588c33bcd77
7
+ data.tar.gz: 7e1d5fb7f9f12006c48920690a2b635084a9a00a3edcfe04f95aeac1b17dde206537f226fb6b9010fd1869211991c3e6b2dd2d2fc11e0f63e41458d61bc68e29
data/.travis.yml CHANGED
@@ -3,5 +3,9 @@ rvm:
3
3
  - 2.0.0
4
4
  - 1.9.3
5
5
  gemfile:
6
- - gemfiles/rails_4.gemfile
6
+ - gemfiles/rails_3_0.gemfile
7
+ - gemfiles/rails_3_1.gemfile
8
+ - gemfiles/rails_3_2.gemfile
9
+ - gemfiles/rails_4_0.gemfile
10
+ - gemfiles/rails_4_1.gemfile
7
11
  script: 'bundle exec rake test'
data/lib/rack/metrics.rb CHANGED
@@ -93,6 +93,19 @@ module Rack
93
93
  end
94
94
  end
95
95
  end
96
+
97
+ ActiveSupport::Notifications.subscribe "query.moped" do |*args|
98
+ query = Event.new *args
99
+ if Metrics.current.is_a?(Rack::Metrics::Event)
100
+ query.payload['stacktrace'] = Metrics.parse_stack(caller(2)).join("\r\n")
101
+ query.payload['sql'] = query.payload[:ops][0].log_inspect unless query.payload[:ops].nil? or !query.payload[:ops][0].respond_to?(:log_inspect)
102
+ if Metrics.current.stack.empty?
103
+ Metrics.current.template.queries<< query
104
+ else
105
+ Metrics.current.stack.peek.queries<< query
106
+ end
107
+ end
108
+ end
96
109
  end
97
110
  end
98
111
  end
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module Metrics
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.3"
4
4
  end
5
5
  end
data/rack-metrics.gemspec CHANGED
@@ -19,7 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency 'sqlite3'
23
22
  spec.add_development_dependency 'appraisal'
24
23
  spec.add_development_dependency "rake"
25
24
  end
@@ -12,18 +12,23 @@ class MetricsTest < ActiveSupport::TestCase
12
12
 
13
13
  test "it subscribes to sql.active_record" do
14
14
  ActiveSupport::Notifications.instrument('sql.active_record'){}
15
- refute_empty Rack::Metrics.current.template.queries
15
+ assert !Rack::Metrics.current.template.queries.empty?
16
+ end
17
+
18
+ test "it subscribes to query.moped" do
19
+ ActiveSupport::Notifications.instrument('query.moped'){}
20
+ assert !Rack::Metrics.current.template.queries.empty?
16
21
  end
17
22
 
18
23
  test "it subscribes to render_template.action_view" do
19
24
  ActiveSupport::Notifications.instrument('render_template.action_view'){}
20
- refute_nil Rack::Metrics.current.template
25
+ assert !Rack::Metrics.current.template.nil?
21
26
  end
22
27
 
23
28
  test "it subscribes to render_partial.action_view" do
24
29
  ActiveSupport::Notifications.instrument('start_render_partial.action_view'){}
25
30
  ActiveSupport::Notifications.instrument('render_partial.action_view'){}
26
- refute_empty Rack::Metrics.current.template.partials
31
+ assert !Rack::Metrics.current.template.partials.empty?
27
32
  end
28
33
 
29
34
  test "it nests render_partial.action_view" do
@@ -35,9 +40,9 @@ class MetricsTest < ActiveSupport::TestCase
35
40
  ActiveSupport::Notifications.instrument('render_partial.action_view'){}
36
41
  end
37
42
  end
38
- refute_empty Rack::Metrics.current.template.partials
43
+ assert !Rack::Metrics.current.template.partials.empty?
39
44
  assert_equal 1, Rack::Metrics.current.template.partials.count
40
- refute_empty Rack::Metrics.current.template.partials[0].partials
45
+ assert !Rack::Metrics.current.template.partials[0].partials.empty?
41
46
  end
42
47
 
43
48
  test "it adds query to nested render_partial.action_view" do
@@ -48,7 +53,7 @@ class MetricsTest < ActiveSupport::TestCase
48
53
  ActiveSupport::Notifications.instrument('render_partial.action_view') do
49
54
  end
50
55
  end
51
- refute_empty Rack::Metrics.current.template.partials
56
+ assert !Rack::Metrics.current.template.partials.empty?
52
57
  assert_equal 1, Rack::Metrics.current.template.partials.count
53
58
  assert_equal 0, Rack::Metrics.current.template.queries.count
54
59
  assert_equal 1, Rack::Metrics.current.template.partials[0].partials[0].queries.count
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Molnar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-21 00:00:00.000000000 Z
11
+ date: 2014-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
- - !ruby/object:Gem::Dependency
28
- name: sqlite3
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: appraisal
43
29
  requirement: !ruby/object:Gem::Requirement