rack-metrics 0.2.0 → 0.2.3
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.
- checksums.yaml +4 -4
- data/.travis.yml +5 -1
- data/lib/rack/metrics.rb +13 -0
- data/lib/rack/metrics/version.rb +1 -1
- data/rack-metrics.gemspec +0 -1
- data/test/unit/metrics_test.rb +11 -6
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3de48a8bcf3f5ac836018a935b8d6d78261192de
|
4
|
+
data.tar.gz: 92e9866fc44a73a8cbc2a03eba42d4ebb696bc75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0486d7ff39469aeed504055eed2c57d97247392e2fadb677a9216155f87c59412c67a32668689bbd9d308e949c00eaec1883052fcfa0c2a472b69588c33bcd77
|
7
|
+
data.tar.gz: 7e1d5fb7f9f12006c48920690a2b635084a9a00a3edcfe04f95aeac1b17dde206537f226fb6b9010fd1869211991c3e6b2dd2d2fc11e0f63e41458d61bc68e29
|
data/.travis.yml
CHANGED
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
|
data/lib/rack/metrics/version.rb
CHANGED
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
|
data/test/unit/metrics_test.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
43
|
+
assert !Rack::Metrics.current.template.partials.empty?
|
39
44
|
assert_equal 1, Rack::Metrics.current.template.partials.count
|
40
|
-
|
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
|
-
|
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.
|
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-
|
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
|