rails-webprofiler 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 +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +2 -2
- data/lib/rails/web_profiler.rb +15 -10
- data/lib/rails/web_profiler/collectors/action_view_collector.rb +8 -3
- data/lib/rails/web_profiler/collectors/active_record_collector.rb +25 -1
- data/lib/rails/web_profiler/collectors/rails_collector.rb +1 -1
- data/lib/rails/web_profiler/notification_handler.rb +0 -1
- data/lib/rails/web_profiler/railtie.rb +21 -14
- data/lib/rails/web_profiler/version.rb +1 -1
- data/rails-webprofiler.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a63d72241be08bb543bd3f463571bd7c560acf3
|
4
|
+
data.tar.gz: 2baccab9e96c4377e5be9d61e23e68bc4500218d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07ddd1fb120f61f05023d3aa1146a64a7292261e0089a186ffa36d9d3d719155f2da6110584f6d8abf2cb190d0d15eb9038e66b7036edc7dc6d7785ee3fa994a
|
7
|
+
data.tar.gz: b1836c45195e1dfae91d31723beb449f2c6fc8027d70e6e32e64ea67eeb4da4dbdb00a43e0f02697dbc551edc2b351baf09663e607273eb775bead4e0406bb30
|
data/CHANGELOG.md
CHANGED
@@ -9,6 +9,22 @@
|
|
9
9
|
* Create a collector to show the Rails logger informations.
|
10
10
|
|
11
11
|
|
12
|
+
## v0.1.1
|
13
|
+
|
14
|
+
Use `rack-webprofiler` >= `0.1.3`.
|
15
|
+
|
16
|
+
### Features
|
17
|
+
|
18
|
+
* Show connection informations on ActiveRecordCollector.
|
19
|
+
|
20
|
+
### Fixes
|
21
|
+
|
22
|
+
* Optimize the Railtie implementation.
|
23
|
+
* Optimize ActionViewCollector (#10).
|
24
|
+
* Load profiler only for Rails 4.2+.
|
25
|
+
* Small code cleanup.
|
26
|
+
|
27
|
+
|
12
28
|
## v0.1.0
|
13
29
|
|
14
30
|
### Features
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Rails WebProfiler
|
2
2
|
|
3
|
-
A web profiler for Rails applications based on
|
3
|
+
A web profiler for Rails +4.2 applications based on
|
4
4
|
[`rack-webprofiler`](https://github.com/rack-webprofiler/rack-webprofiler/).
|
5
5
|
|
6
6
|
[![Version ](http://img.shields.io/gem/v/rails-webprofiler.svg) ](https://rubygems.org/gems/rails-webprofiler)
|
@@ -27,7 +27,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
27
27
|
|
28
28
|
## Contributing
|
29
29
|
|
30
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
30
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rack-webprofiler/rails-webprofiler. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
31
31
|
|
32
32
|
|
33
33
|
## License
|
data/lib/rails/web_profiler.rb
CHANGED
@@ -1,16 +1,21 @@
|
|
1
1
|
require "rack/webprofiler"
|
2
|
+
require "rails/version"
|
3
|
+
require "rails/railtie"
|
2
4
|
|
3
|
-
|
5
|
+
module Rails
|
6
|
+
class WebProfiler
|
7
|
+
autoload :VERSION, "rails/web_profiler/version"
|
8
|
+
autoload :NotificationHandler, "rails/web_profiler/notification_handler"
|
4
9
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
autoload :RailsCollector, "rails/web_profiler/collectors/rails_collector"
|
12
|
-
autoload :RequestCollector, "rails/web_profiler/collectors/request_collector"
|
10
|
+
module Collectors
|
11
|
+
autoload :ActionViewCollector, "rails/web_profiler/collectors/action_view_collector"
|
12
|
+
autoload :ActiveRecordCollector, "rails/web_profiler/collectors/active_record_collector"
|
13
|
+
autoload :RailsCollector, "rails/web_profiler/collectors/rails_collector"
|
14
|
+
autoload :RequestCollector, "rails/web_profiler/collectors/request_collector"
|
15
|
+
end
|
13
16
|
end
|
14
17
|
end
|
15
18
|
|
16
|
-
|
19
|
+
if defined?(::Rails) && ::Rails.version >= "4.2.0"
|
20
|
+
require "rails/web_profiler/railtie"
|
21
|
+
end
|
@@ -10,11 +10,16 @@ ICON
|
|
10
10
|
label "ActionView"
|
11
11
|
position 9
|
12
12
|
|
13
|
-
collect do
|
13
|
+
collect do
|
14
14
|
data = ::Rack::WebProfiler.data("rails.events")
|
15
15
|
|
16
16
|
events = []
|
17
|
-
|
17
|
+
if !data.nil?
|
18
|
+
events = data.by_event_names(%w(render_template.action_view render_partial.action_view))
|
19
|
+
events.each do |e|
|
20
|
+
e.payload.delete_if { |k, _v| !%w( identifier layout ).include?(k.to_s) }
|
21
|
+
end
|
22
|
+
end
|
18
23
|
|
19
24
|
total_duration = events.inject(0) { |sum, e| sum + e.duration }
|
20
25
|
|
@@ -25,7 +30,7 @@ ICON
|
|
25
30
|
|
26
31
|
template __FILE__, type: :DATA
|
27
32
|
|
28
|
-
is_enabled? -> { defined? ::
|
33
|
+
is_enabled? -> { defined? ::ActionView }
|
29
34
|
end
|
30
35
|
end
|
31
36
|
|
@@ -10,12 +10,18 @@ ICON
|
|
10
10
|
label "ActiveRecord"
|
11
11
|
position 10
|
12
12
|
|
13
|
-
collect do
|
13
|
+
collect do
|
14
14
|
data = ::Rack::WebProfiler.data("rails.events")
|
15
15
|
|
16
16
|
events = []
|
17
17
|
events = data.by_event_name("sql.active_record") unless data.nil?
|
18
18
|
|
19
|
+
ar_conn = ActiveRecord::Base.connection
|
20
|
+
store :connection, {
|
21
|
+
adapter_class: ar_conn.class.name,
|
22
|
+
adapter_name: ar_conn.adapter_name,
|
23
|
+
}
|
24
|
+
|
19
25
|
total_duration = events.inject(0) { |sum, e| sum + e.duration }
|
20
26
|
|
21
27
|
store :events, events
|
@@ -85,4 +91,22 @@ __END__
|
|
85
91
|
<p><span class="text__no-value">No queries executed.</span></p>
|
86
92
|
<% end %>
|
87
93
|
</div>
|
94
|
+
|
95
|
+
<div class="block">
|
96
|
+
<h3>Connection</h3>
|
97
|
+
|
98
|
+
<% conn = data(:connection) %>
|
99
|
+
<table>
|
100
|
+
<tbody>
|
101
|
+
<tr>
|
102
|
+
<th>Adapter class</th>
|
103
|
+
<td><code><%=h conn[:adapter_class] %></code></td>
|
104
|
+
</tr>
|
105
|
+
<tr>
|
106
|
+
<th>Adapter name</th>
|
107
|
+
<td><%=h conn[:adapter_name] %></td>
|
108
|
+
</tr>
|
109
|
+
</tbody>
|
110
|
+
</table>
|
111
|
+
</div>
|
88
112
|
<% end %>
|
@@ -1,20 +1,15 @@
|
|
1
|
-
require "rails"
|
2
|
-
|
3
1
|
module Rails
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
app.middleware.use ::Rack::WebProfiler do |c|
|
8
|
-
c.tmp_dir = ::File.expand_path(::File.join(Rails.root, "tmp"), __FILE__)
|
9
|
-
end
|
2
|
+
class WebProfiler
|
3
|
+
def self.initialize!(app)
|
4
|
+
raise "Rails::WebProfiler initialized twice. Set `require: false' for rails-webprofiler in your Gemfile" if @already_initialized
|
10
5
|
|
11
|
-
::Rack::WebProfiler
|
12
|
-
# ::Rack::WebProfiler::Collectors::ExceptionCollector,
|
13
|
-
::Rack::WebProfiler::Collectors::RackCollector,
|
14
|
-
::Rack::WebProfiler::Collectors::RequestCollector,
|
15
|
-
]
|
6
|
+
app.middleware.insert(0, ::Rack::WebProfiler)
|
16
7
|
|
17
|
-
::Rack::WebProfiler.
|
8
|
+
::Rack::WebProfiler.reset_collectors!
|
9
|
+
|
10
|
+
::Rack::WebProfiler.register_collectors [
|
11
|
+
::Rack::WebProfiler::Collectors::RubyCollector,
|
12
|
+
::Rack::WebProfiler::Collectors::TimeCollector,
|
18
13
|
Rails::WebProfiler::Collectors::ActionViewCollector,
|
19
14
|
Rails::WebProfiler::Collectors::ActiveRecordCollector,
|
20
15
|
Rails::WebProfiler::Collectors::RailsCollector,
|
@@ -24,6 +19,18 @@ module Rails
|
|
24
19
|
# Subscrine all Rails notifications.
|
25
20
|
handler = Rails::WebProfiler::NotificationHandler.new
|
26
21
|
ActiveSupport::Notifications.subscribe(/.+/, handler)
|
22
|
+
|
23
|
+
c = ::Rack::WebProfiler.config
|
24
|
+
|
25
|
+
c.tmp_dir = ::File.expand_path(::File.join(Rails.root, "tmp"), __FILE__)
|
26
|
+
|
27
|
+
@already_initialized = true
|
28
|
+
end
|
29
|
+
|
30
|
+
class Railtie < ::Rails::Railtie # :nodoc:
|
31
|
+
initializer "rails-webprofiler.configure_rails_initialization" do |app|
|
32
|
+
Rails::WebProfiler.initialize!(app)
|
33
|
+
end
|
27
34
|
end
|
28
35
|
end
|
29
36
|
end
|
data/rails-webprofiler.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
33
|
spec.add_dependency "rails", ">= 5.0.0"
|
34
|
-
spec.add_dependency "rack-webprofiler", "~> 0.1.
|
34
|
+
spec.add_dependency "rack-webprofiler", "~> 0.1.3"
|
35
35
|
|
36
36
|
spec.add_development_dependency "bundler", "~> 1.12"
|
37
37
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-webprofiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Brousse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.1.
|
33
|
+
version: 0.1.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.1.
|
40
|
+
version: 0.1.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.6.8
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: A web profiler for Rails applications.
|