rack-mini-profiler 0.1.25 → 0.1.30
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rack-mini-profiler might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Ruby/CHANGELOG +26 -0
- data/Ruby/README.md +11 -0
- data/Ruby/lib/html/flamegraph.html +32 -6
- data/Ruby/lib/html/includes.js +82 -67
- data/Ruby/lib/html/includes.tmpl +2 -0
- data/Ruby/lib/mini_profiler/client_settings.rb +11 -11
- data/Ruby/lib/mini_profiler/config.rb +10 -9
- data/Ruby/lib/mini_profiler/flame_graph.rb +4 -4
- data/Ruby/lib/mini_profiler/page_timer_struct.rb +4 -4
- data/Ruby/lib/mini_profiler/profiler.rb +78 -40
- data/Ruby/lib/mini_profiler/profiling_methods.rb +31 -11
- data/Ruby/lib/mini_profiler/request_timer_struct.rb +5 -5
- data/Ruby/lib/mini_profiler/sql_timer_struct.rb +1 -1
- data/Ruby/lib/mini_profiler/storage/abstract_store.rb +4 -3
- data/Ruby/lib/mini_profiler/storage/redis_store.rb +3 -3
- data/Ruby/lib/mini_profiler/version.rb +1 -1
- data/Ruby/lib/mini_profiler_rails/railtie.rb +44 -40
- data/Ruby/lib/patches/sql_patches.rb +6 -1
- data/rack-mini-profiler.gemspec +2 -1
- metadata +5 -4
@@ -3,7 +3,7 @@ module Rack
|
|
3
3
|
class RedisStore < AbstractStore
|
4
4
|
|
5
5
|
EXPIRES_IN_SECONDS = 60 * 60 * 24
|
6
|
-
|
6
|
+
|
7
7
|
def initialize(args = nil)
|
8
8
|
@args = args || {}
|
9
9
|
@prefix = @args.delete(:prefix) || 'MPRedisStore'
|
@@ -12,7 +12,7 @@ module Rack
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def save(page_struct)
|
15
|
-
redis.setex "#{@prefix}#{page_struct['Id']}", @expires_in_seconds, Marshal::dump(page_struct)
|
15
|
+
redis.setex "#{@prefix}#{page_struct['Id']}", @expires_in_seconds, Marshal::dump(page_struct)
|
16
16
|
end
|
17
17
|
|
18
18
|
def load(id)
|
@@ -41,7 +41,7 @@ unviewed_ids: #{get_unviewed_ids(user)}
|
|
41
41
|
"
|
42
42
|
end
|
43
43
|
|
44
|
-
private
|
44
|
+
private
|
45
45
|
|
46
46
|
def redis
|
47
47
|
return @redis_connection if @redis_connection
|
@@ -1,61 +1,65 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
|
3
|
-
module MiniProfilerRails
|
3
|
+
module Rack::MiniProfilerRails
|
4
4
|
|
5
|
-
|
5
|
+
# call direct if needed to do a defer init
|
6
|
+
def self.initialize!(app)
|
7
|
+
c = Rack::MiniProfiler.config
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
+
# By default, only show the MiniProfiler in development mode, in production allow profiling if post_authorize_cb is set
|
10
|
+
c.pre_authorize_cb = lambda { |env|
|
11
|
+
!Rails.env.test?
|
12
|
+
}
|
9
13
|
|
10
|
-
|
11
|
-
c.pre_authorize_cb = lambda { |env|
|
12
|
-
!Rails.env.test?
|
13
|
-
}
|
14
|
+
c.skip_paths ||= []
|
14
15
|
|
15
|
-
|
16
|
+
if Rails.env.development?
|
17
|
+
c.skip_paths << "/assets/"
|
18
|
+
c.skip_schema_queries = true
|
19
|
+
end
|
16
20
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
+
if Rails.env.production?
|
22
|
+
c.authorization_mode = :whitelist
|
23
|
+
end
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
+
# The file store is just so much less flaky
|
26
|
+
tmp = Rails.root.to_s + "/tmp/miniprofiler"
|
27
|
+
FileUtils.mkdir_p(tmp) unless File.exists?(tmp)
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
FileUtils.mkdir_p(tmp) unless File.exists?(tmp)
|
29
|
+
c.storage_options = {:path => tmp}
|
30
|
+
c.storage = Rack::MiniProfiler::FileStore
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
+
# Quiet the SQL stack traces
|
33
|
+
c.backtrace_remove = Rails.root.to_s + "/"
|
34
|
+
c.backtrace_includes = [/^\/?(app|config|lib|test)/]
|
35
|
+
c.skip_schema_queries = Rails.env != 'production'
|
32
36
|
|
33
|
-
|
34
|
-
|
35
|
-
c.backtrace_includes = [/^\/?(app|config|lib|test)/]
|
36
|
-
c.skip_schema_queries = Rails.env != 'production'
|
37
|
+
# Install the Middleware
|
38
|
+
app.middleware.insert(0, Rack::MiniProfiler)
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
+
# Attach to various Rails methods
|
41
|
+
::Rack::MiniProfiler.profile_method(ActionController::Base, :process) {|action| "Executing action: #{action}"}
|
42
|
+
::Rack::MiniProfiler.profile_method(ActionView::Template, :render) {|x,y| "Rendering: #{@virtual_path}"}
|
43
|
+
end
|
40
44
|
|
41
|
-
|
42
|
-
::Rack::MiniProfiler.profile_method(ActionController::Base, :process) {|action| "Executing action: #{action}"}
|
43
|
-
::Rack::MiniProfiler.profile_method(ActionView::Template, :render) {|x,y| "Rendering: #{@virtual_path}"}
|
45
|
+
class Railtie < ::Rails::Railtie
|
44
46
|
|
47
|
+
initializer "rack_mini_profiler.configure_rails_initialization" do |app|
|
48
|
+
Rack::MiniProfilerRails.initialize!(app)
|
45
49
|
end
|
46
50
|
|
47
51
|
# TODO: Implement something better here
|
48
|
-
# config.after_initialize do
|
49
|
-
#
|
50
|
-
# class ::ActionView::Helpers::AssetTagHelper::JavascriptIncludeTag
|
52
|
+
# config.after_initialize do
|
53
|
+
#
|
54
|
+
# class ::ActionView::Helpers::AssetTagHelper::JavascriptIncludeTag
|
51
55
|
# alias_method :asset_tag_orig, :asset_tag
|
52
56
|
# def asset_tag(source,options)
|
53
|
-
# current = Rack::MiniProfiler.current
|
54
|
-
# return asset_tag_orig(source,options) unless current
|
57
|
+
# current = Rack::MiniProfiler.current
|
58
|
+
# return asset_tag_orig(source,options) unless current
|
55
59
|
# wrapped = ""
|
56
60
|
# unless current.mpt_init
|
57
61
|
# current.mpt_init = true
|
58
|
-
# wrapped << Rack::MiniProfiler::ClientTimerStruct.init_instrumentation
|
62
|
+
# wrapped << Rack::MiniProfiler::ClientTimerStruct.init_instrumentation
|
59
63
|
# end
|
60
64
|
# name = source.split('/')[-1]
|
61
65
|
# wrapped << Rack::MiniProfiler::ClientTimerStruct.instrument(name, asset_tag_orig(source,options)).html_safe
|
@@ -63,15 +67,15 @@ module MiniProfilerRails
|
|
63
67
|
# end
|
64
68
|
# end
|
65
69
|
|
66
|
-
# class ::ActionView::Helpers::AssetTagHelper::StylesheetIncludeTag
|
70
|
+
# class ::ActionView::Helpers::AssetTagHelper::StylesheetIncludeTag
|
67
71
|
# alias_method :asset_tag_orig, :asset_tag
|
68
72
|
# def asset_tag(source,options)
|
69
|
-
# current = Rack::MiniProfiler.current
|
70
|
-
# return asset_tag_orig(source,options) unless current
|
73
|
+
# current = Rack::MiniProfiler.current
|
74
|
+
# return asset_tag_orig(source,options) unless current
|
71
75
|
# wrapped = ""
|
72
76
|
# unless current.mpt_init
|
73
77
|
# current.mpt_init = true
|
74
|
-
# wrapped << Rack::MiniProfiler::ClientTimerStruct.init_instrumentation
|
78
|
+
# wrapped << Rack::MiniProfiler::ClientTimerStruct.init_instrumentation
|
75
79
|
# end
|
76
80
|
# name = source.split('/')[-1]
|
77
81
|
# wrapped << Rack::MiniProfiler::ClientTimerStruct.instrument(name, asset_tag_orig(source,options)).html_safe
|
@@ -200,7 +200,12 @@ if SqlPatches.class_exists?("RSolr::Connection") && RSolr::VERSION[0] != "0" #
|
|
200
200
|
|
201
201
|
data = "#{request_context[:method].upcase} #{request_context[:uri]}"
|
202
202
|
if request_context[:method] == :post and request_context[:data]
|
203
|
-
|
203
|
+
if request_context[:headers].include?("Content-Type") and request_context[:headers]["Content-Type"] == "text/xml"
|
204
|
+
# it's xml, unescaping isn't needed
|
205
|
+
data << "\n#{request_context[:data]}"
|
206
|
+
else
|
207
|
+
data << "\n#{Rack::Utils.unescape(request_context[:data])}"
|
208
|
+
end
|
204
209
|
end
|
205
210
|
result.instance_variable_set("@miniprofiler_sql_id", ::Rack::MiniProfiler.record_sql(data, elapsed_time))
|
206
211
|
|
data/rack-mini-profiler.gemspec
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "rack-mini-profiler"
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.30"
|
4
4
|
s.summary = "Profiles loading speed for rack applications."
|
5
5
|
s.authors = ["Sam Saffron", "Robin Ward","Aleks Totic"]
|
6
6
|
s.description = "Profiling toolkit for Rack applications with Rails integration. Client Side profiling, DB profiling and Server profiling."
|
7
7
|
s.email = "sam.saffron@gmail.com"
|
8
8
|
s.homepage = "http://miniprofiler.com"
|
9
|
+
s.license = "MIT"
|
9
10
|
s.files = [
|
10
11
|
'rack-mini-profiler.gemspec',
|
11
12
|
].concat( Dir.glob('Ruby/lib/**/*').reject {|f| File.directory?(f) || f =~ /~$/ } )
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-mini-profiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-08-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
@@ -116,7 +116,8 @@ files:
|
|
116
116
|
- Ruby/README.md
|
117
117
|
- Ruby/CHANGELOG
|
118
118
|
homepage: http://miniprofiler.com
|
119
|
-
licenses:
|
119
|
+
licenses:
|
120
|
+
- MIT
|
120
121
|
metadata: {}
|
121
122
|
post_install_message:
|
122
123
|
rdoc_options: []
|
@@ -134,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
135
|
version: '0'
|
135
136
|
requirements: []
|
136
137
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.0.
|
138
|
+
rubygems_version: 2.0.3
|
138
139
|
signing_key:
|
139
140
|
specification_version: 4
|
140
141
|
summary: Profiles loading speed for rack applications.
|