mini-sharp-hub 0.0.1
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 +7 -0
- data/mini-sharp-hub.gemspec +12 -0
- data/rack-mini-profiler-4.0.1/CHANGELOG.md +424 -0
- data/rack-mini-profiler-4.0.1/README.md +542 -0
- data/rack-mini-profiler-4.0.1/lib/enable_rails_patches.rb +5 -0
- data/rack-mini-profiler-4.0.1/lib/generators/rack_mini_profiler/USAGE +9 -0
- data/rack-mini-profiler-4.0.1/lib/generators/rack_mini_profiler/install_generator.rb +13 -0
- data/rack-mini-profiler-4.0.1/lib/generators/rack_mini_profiler/templates/rack_mini_profiler.rb +8 -0
- data/rack-mini-profiler-4.0.1/lib/generators/rack_profiler/USAGE +2 -0
- data/rack-mini-profiler-4.0.1/lib/generators/rack_profiler/install_generator.rb +16 -0
- data/rack-mini-profiler-4.0.1/lib/html/dot.1.1.2.min.js +2 -0
- data/rack-mini-profiler-4.0.1/lib/html/includes.css +474 -0
- data/rack-mini-profiler-4.0.1/lib/html/includes.js +1520 -0
- data/rack-mini-profiler-4.0.1/lib/html/includes.scss +698 -0
- data/rack-mini-profiler-4.0.1/lib/html/includes.tmpl +333 -0
- data/rack-mini-profiler-4.0.1/lib/html/pretty-print.js +810 -0
- data/rack-mini-profiler-4.0.1/lib/html/profile_handler.js +1 -0
- data/rack-mini-profiler-4.0.1/lib/html/rack-mini-profiler.css +3 -0
- data/rack-mini-profiler-4.0.1/lib/html/rack-mini-profiler.js +2 -0
- data/rack-mini-profiler-4.0.1/lib/html/share.html +10 -0
- data/rack-mini-profiler-4.0.1/lib/html/speedscope/LICENSE +21 -0
- data/rack-mini-profiler-4.0.1/lib/html/speedscope/README.md +3 -0
- data/rack-mini-profiler-4.0.1/lib/html/speedscope/demangle-cpp.1768f4cc.js +4 -0
- data/rack-mini-profiler-4.0.1/lib/html/speedscope/favicon-16x16.f74b3187.png +0 -0
- data/rack-mini-profiler-4.0.1/lib/html/speedscope/favicon-32x32.bc503437.png +0 -0
- data/rack-mini-profiler-4.0.1/lib/html/speedscope/file-format-schema.json +324 -0
- data/rack-mini-profiler-4.0.1/lib/html/speedscope/fonts/source-code-pro-regular.css +8 -0
- data/rack-mini-profiler-4.0.1/lib/html/speedscope/fonts/source-code-pro-v13-regular.woff +0 -0
- data/rack-mini-profiler-4.0.1/lib/html/speedscope/fonts/source-code-pro-v13-regular.woff2 +0 -0
- data/rack-mini-profiler-4.0.1/lib/html/speedscope/import.8ae8aa3d.js +123 -0
- data/rack-mini-profiler-4.0.1/lib/html/speedscope/index.html +2 -0
- data/rack-mini-profiler-4.0.1/lib/html/speedscope/release.txt +3 -0
- data/rack-mini-profiler-4.0.1/lib/html/speedscope/reset.8c46b7a1.css +2 -0
- data/rack-mini-profiler-4.0.1/lib/html/speedscope/source-map.438fa06b.js +24 -0
- data/rack-mini-profiler-4.0.1/lib/html/speedscope/speedscope.f27db165.js +193 -0
- data/rack-mini-profiler-4.0.1/lib/html/vendor.js +848 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/actions.rb +157 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/asset_version.rb +6 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/client_settings.rb +127 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/config.rb +146 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/context.rb +14 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/gc_profiler.rb +158 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/profiling_methods.rb +167 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/snapshots_transporter.rb +111 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/storage/abstract_store.rb +97 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/storage/file_store.rb +179 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/storage/memcache_store.rb +105 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/storage/memory_store.rb +233 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/storage/redis_store.rb +353 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/storage.rb +7 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct/base.rb +39 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct/client.rb +90 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct/custom.rb +25 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct/page.rb +146 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct/request.rb +186 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct/sql.rb +89 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct.rb +8 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/version.rb +8 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler/views.rb +198 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler.rb +670 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler_rails/railtie.rb +234 -0
- data/rack-mini-profiler-4.0.1/lib/mini_profiler_rails/railtie_methods.rb +61 -0
- data/rack-mini-profiler-4.0.1/lib/patches/db/activerecord.rb +44 -0
- data/rack-mini-profiler-4.0.1/lib/patches/db/mongo.rb +18 -0
- data/rack-mini-profiler-4.0.1/lib/patches/db/moped.rb +14 -0
- data/rack-mini-profiler-4.0.1/lib/patches/db/mysql2/alias_method.rb +30 -0
- data/rack-mini-profiler-4.0.1/lib/patches/db/mysql2/prepend.rb +34 -0
- data/rack-mini-profiler-4.0.1/lib/patches/db/mysql2.rb +7 -0
- data/rack-mini-profiler-4.0.1/lib/patches/db/neo4j.rb +16 -0
- data/rack-mini-profiler-4.0.1/lib/patches/db/nobrainer.rb +31 -0
- data/rack-mini-profiler-4.0.1/lib/patches/db/oracle_enhanced.rb +70 -0
- data/rack-mini-profiler-4.0.1/lib/patches/db/pg/alias_method.rb +121 -0
- data/rack-mini-profiler-4.0.1/lib/patches/db/pg/prepend.rb +115 -0
- data/rack-mini-profiler-4.0.1/lib/patches/db/pg.rb +7 -0
- data/rack-mini-profiler-4.0.1/lib/patches/db/plucky.rb +49 -0
- data/rack-mini-profiler-4.0.1/lib/patches/db/riak.rb +105 -0
- data/rack-mini-profiler-4.0.1/lib/patches/db/rsolr.rb +26 -0
- data/rack-mini-profiler-4.0.1/lib/patches/db/sequel.rb +12 -0
- data/rack-mini-profiler-4.0.1/lib/patches/net_patches.rb +27 -0
- data/rack-mini-profiler-4.0.1/lib/patches/sql_patches.rb +74 -0
- data/rack-mini-profiler-4.0.1/lib/prepend_mysql2_patch.rb +5 -0
- data/rack-mini-profiler-4.0.1/lib/prepend_net_http_patch.rb +5 -0
- data/rack-mini-profiler-4.0.1/lib/prepend_pg_patch.rb +5 -0
- data/rack-mini-profiler-4.0.1/lib/rack-mini-profiler.rb +13 -0
- data/rack-mini-profiler-4.0.1/rack-mini-profiler.gemspec +49 -0
- metadata +125 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class PG::Result
|
|
4
|
+
module MiniProfiler
|
|
5
|
+
def values(*args, &blk)
|
|
6
|
+
return super unless defined?(@miniprofiler_sql_id)
|
|
7
|
+
mp_report_sql do
|
|
8
|
+
super
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def each(*args, &blk)
|
|
13
|
+
return super unless defined?(@miniprofiler_sql_id)
|
|
14
|
+
mp_report_sql do
|
|
15
|
+
super
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def mp_report_sql(&block)
|
|
20
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
21
|
+
result = yield
|
|
22
|
+
elapsed_time = SqlPatches.elapsed_time(start)
|
|
23
|
+
@miniprofiler_sql_id.report_reader_duration(elapsed_time)
|
|
24
|
+
result
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
prepend MiniProfiler
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
class PG::Connection
|
|
32
|
+
module MiniProfiler
|
|
33
|
+
def prepare(*args, &blk)
|
|
34
|
+
# we have no choice but to do this here,
|
|
35
|
+
# if we do the check for profiling first, our cache may miss critical stuff
|
|
36
|
+
|
|
37
|
+
@prepare_map ||= {}
|
|
38
|
+
@prepare_map[args[0]] = args[1]
|
|
39
|
+
# dont leak more than 10k ever
|
|
40
|
+
@prepare_map = {} if @prepare_map.length > 1000
|
|
41
|
+
|
|
42
|
+
return super unless SqlPatches.should_measure?
|
|
43
|
+
super
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def exec(*args, &blk)
|
|
47
|
+
return super unless SqlPatches.should_measure?
|
|
48
|
+
|
|
49
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
50
|
+
result = super
|
|
51
|
+
elapsed_time = SqlPatches.elapsed_time(start)
|
|
52
|
+
record = ::Rack::MiniProfiler.record_sql(args[0], elapsed_time)
|
|
53
|
+
result.instance_variable_set("@miniprofiler_sql_id", record) if result
|
|
54
|
+
|
|
55
|
+
result
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
if Gem::Version.new(PG::VERSION) >= Gem::Version.new("1.1.0")
|
|
59
|
+
def exec_params(*args, &blk)
|
|
60
|
+
return super unless SqlPatches.should_measure?
|
|
61
|
+
|
|
62
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
63
|
+
result = super
|
|
64
|
+
elapsed_time = SqlPatches.elapsed_time(start)
|
|
65
|
+
record = ::Rack::MiniProfiler.record_sql(args[0], elapsed_time)
|
|
66
|
+
result.instance_variable_set("@miniprofiler_sql_id", record) if result
|
|
67
|
+
|
|
68
|
+
result
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def exec_prepared(*args, &blk)
|
|
73
|
+
return super unless SqlPatches.should_measure?
|
|
74
|
+
|
|
75
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
76
|
+
result = super
|
|
77
|
+
elapsed_time = SqlPatches.elapsed_time(start)
|
|
78
|
+
mapped = args[0]
|
|
79
|
+
mapped = @prepare_map[mapped] || args[0] if @prepare_map
|
|
80
|
+
record = ::Rack::MiniProfiler.record_sql(mapped, elapsed_time)
|
|
81
|
+
result.instance_variable_set("@miniprofiler_sql_id", record) if result
|
|
82
|
+
|
|
83
|
+
result
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def send_query_prepared(*args, &blk)
|
|
87
|
+
return super unless SqlPatches.should_measure?
|
|
88
|
+
|
|
89
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
90
|
+
result = super
|
|
91
|
+
elapsed_time = SqlPatches.elapsed_time(start)
|
|
92
|
+
mapped = args[0]
|
|
93
|
+
mapped = @prepare_map[mapped] || args[0] if @prepare_map
|
|
94
|
+
record = ::Rack::MiniProfiler.record_sql(mapped, elapsed_time)
|
|
95
|
+
result.instance_variable_set("@miniprofiler_sql_id", record) if result
|
|
96
|
+
|
|
97
|
+
result
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def async_exec(*args, &blk)
|
|
101
|
+
return super unless SqlPatches.should_measure?
|
|
102
|
+
|
|
103
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
104
|
+
result = super
|
|
105
|
+
elapsed_time = SqlPatches.elapsed_time(start)
|
|
106
|
+
record = ::Rack::MiniProfiler.record_sql(args[0], elapsed_time)
|
|
107
|
+
result.instance_variable_set("@miniprofiler_sql_id", record) if result
|
|
108
|
+
|
|
109
|
+
result
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
prepend MiniProfiler
|
|
114
|
+
alias_method :query, :exec
|
|
115
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# mongo_mapper patches
|
|
4
|
+
# TODO: Include overrides for distinct, update, cursor, and create
|
|
5
|
+
class Plucky::Query
|
|
6
|
+
alias_method :find_each_without_profiling, :find_each
|
|
7
|
+
alias_method :find_one_without_profiling, :find_one
|
|
8
|
+
alias_method :count_without_profiling, :count
|
|
9
|
+
alias_method :remove_without_profiling, :remove
|
|
10
|
+
|
|
11
|
+
def find_each(*args, &blk)
|
|
12
|
+
profile_database_operation(__callee__, filtered_inspect(), *args, &blk)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def find_one(*args, &blk)
|
|
16
|
+
profile_database_operation(__callee__, filtered_inspect(args[0]), *args, &blk)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def count(*args, &blk)
|
|
20
|
+
profile_database_operation(__callee__, filtered_inspect(), *args, &blk)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def remove(*args, &blk)
|
|
24
|
+
profile_database_operation(__callee__, filtered_inspect(), *args, &blk)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
def profile_database_operation(method, message, *args, &blk)
|
|
30
|
+
return self.send("#{method.id2name}_without_profiling", *args, &blk) unless SqlPatches.should_measure?
|
|
31
|
+
|
|
32
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
33
|
+
result = self.send("#{method.id2name}_without_profiling", *args, &blk)
|
|
34
|
+
elapsed_time = SqlPatches.elapsed_time(start)
|
|
35
|
+
|
|
36
|
+
query_message = "#{@collection.name}.#{method.id2name} => #{message}"
|
|
37
|
+
::Rack::MiniProfiler.record_sql(query_message, elapsed_time)
|
|
38
|
+
|
|
39
|
+
result
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def filtered_inspect(hash = to_hash())
|
|
43
|
+
hash_string = hash.reject { |key| key == :transformer }.collect do |key, value|
|
|
44
|
+
" #{key}: #{value.inspect}"
|
|
45
|
+
end.join(",\n")
|
|
46
|
+
|
|
47
|
+
"{\n#{hash_string}\n}"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# riak-client 2.2.2 patches
|
|
4
|
+
class Riak::Multiget
|
|
5
|
+
class << self
|
|
6
|
+
alias_method :get_all_without_profiling, :get_all
|
|
7
|
+
def get_all(client, fetch_list)
|
|
8
|
+
return get_all_without_profiling(client, fetch_list) unless SqlPatches.should_measure?
|
|
9
|
+
|
|
10
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
11
|
+
result = get_all_without_profiling(client, fetch_list)
|
|
12
|
+
elapsed_time = SqlPatches.elapsed_time(start)
|
|
13
|
+
record = ::Rack::MiniProfiler.record_sql("get_all size=#{fetch_list.size}", elapsed_time)
|
|
14
|
+
|
|
15
|
+
result
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class Riak::Client
|
|
21
|
+
|
|
22
|
+
alias_method :buckets_without_profiling, :buckets
|
|
23
|
+
def buckets(options = {}, &blk)
|
|
24
|
+
profile("buckets #{options}") { buckets_without_profiling(options, &blk) }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
alias_method :client_id_without_profiling, :client_id
|
|
28
|
+
def client_id
|
|
29
|
+
profile("client_id") { client_id_without_profiling }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
alias_method :delete_object_without_profiling, :delete_object
|
|
33
|
+
def delete_object(bucket, key, options = {})
|
|
34
|
+
profile("delete_object bucket=#{bucket.name} key=#{key} options=#{options}") { delete_object_without_profiling(bucket, key, options) }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
alias_method :get_bucket_props_without_profiling, :get_bucket_props
|
|
38
|
+
def get_bucket_props(bucket, options = {})
|
|
39
|
+
profile("get_bucket_props bucket=#{bucket.name} options=#{options}") { get_bucket_props_without_profiling(bucket, options) }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
alias_method :get_index_without_profiling, :get_index
|
|
43
|
+
def get_index(bucket, index, query, options = {})
|
|
44
|
+
profile("get_index bucket=#{bucket.name} index=#{index} query=#{query} options=#{options}") { get_index_without_profiling(bucket, index, query, options) }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
alias_method :get_preflist_without_profiling, :get_preflist
|
|
48
|
+
def get_preflist(bucket, key, type = nil, options = {})
|
|
49
|
+
profile("get_preflist bucket=#{bucket.name} key=#{key} type=#{type} options=#{options}") { get_preflist_without_profiling(bucket, key, type, options) }
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
alias_method :get_object_without_profiling, :get_object
|
|
53
|
+
def get_object(bucket, key, options = {})
|
|
54
|
+
profile("get_object bucket=#{bucket.name} key=#{key} options=#{options}") { get_object_without_profiling(bucket, key, options) }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
alias_method :list_keys_without_profiling, :list_keys
|
|
58
|
+
def list_keys(bucket, options = {}, &block)
|
|
59
|
+
profile("list_keys bucket=#{bucket.name} options=#{options}") { list_keys_without_profiling(bucket, options, &block) }
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
alias_method :mapred_without_profiling, :mapred
|
|
63
|
+
def mapred(mr, &block)
|
|
64
|
+
profile("mapred") { mapred_without_profiling(mr, &block) }
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
alias_method :ping_without_profiling, :ping
|
|
68
|
+
def ping
|
|
69
|
+
profile("ping") { ping_without_profiling }
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
alias_method :reload_object_without_profiling, :reload_object
|
|
73
|
+
def reload_object(object, options = {})
|
|
74
|
+
profile("reload_object bucket=#{object.bucket.name} key=#{object.key} vclock=#{object.vclock} options=#{options}") { reload_object_without_profiling(object, options) }
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
alias_method :set_bucket_props_without_profiling, :set_bucket_props
|
|
78
|
+
def set_bucket_props(bucket, properties, type = nil)
|
|
79
|
+
profile("set_bucket_props bucket=#{bucket.name} type=#{type}") { set_bucket_props_without_profiling(bucket, properties, type) }
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
alias_method :clear_bucket_props_without_profiling, :clear_bucket_props
|
|
83
|
+
def clear_bucket_props(bucket, options = {})
|
|
84
|
+
profile("clear_bucket_props bucket=#{bucket.name} options=#{options}") { clear_bucket_props_without_profiling(bucket, options) }
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
alias_method :store_object_without_profiling, :store_object
|
|
88
|
+
def store_object(object, options = {})
|
|
89
|
+
profile("store_object bucket=#{object.bucket.name} key=#{object.key} vclock=#{object.vclock} options=#{options}") { store_object_without_profiling(object, options) }
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
private
|
|
93
|
+
|
|
94
|
+
def profile(request, &blk)
|
|
95
|
+
return yield unless SqlPatches.should_measure?
|
|
96
|
+
|
|
97
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
98
|
+
result = yield
|
|
99
|
+
elapsed_time = SqlPatches.elapsed_time(start)
|
|
100
|
+
record = ::Rack::MiniProfiler.record_sql(request, elapsed_time)
|
|
101
|
+
|
|
102
|
+
result
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class RSolr::Connection
|
|
4
|
+
alias_method :execute_without_profiling, :execute
|
|
5
|
+
def execute_with_profiling(client, request_context)
|
|
6
|
+
return execute_without_profiling(client, request_context) unless SqlPatches.should_measure?
|
|
7
|
+
|
|
8
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
9
|
+
result = execute_without_profiling(client, request_context)
|
|
10
|
+
elapsed_time = SqlPatches.elapsed_time(start)
|
|
11
|
+
|
|
12
|
+
data = "#{request_context[:method].upcase} #{request_context[:uri]}".dup
|
|
13
|
+
if (request_context[:method] == :post) && request_context[:data]
|
|
14
|
+
if request_context[:headers].include?("Content-Type") && (request_context[:headers]["Content-Type"] == "text/xml")
|
|
15
|
+
# it's xml, unescaping isn't needed
|
|
16
|
+
data << "\n#{request_context[:data]}"
|
|
17
|
+
else
|
|
18
|
+
data << "\n#{Rack::Utils.unescape(request_context[:data])}"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
::Rack::MiniProfiler.record_sql(data, elapsed_time)
|
|
22
|
+
|
|
23
|
+
result
|
|
24
|
+
end
|
|
25
|
+
alias_method :execute, :execute_with_profiling
|
|
26
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Sequel
|
|
4
|
+
class Database
|
|
5
|
+
alias_method :log_duration_original, :log_duration
|
|
6
|
+
def log_duration(duration, message)
|
|
7
|
+
# `duration` will be in seconds, but we need it in milliseconds for internal consistency.
|
|
8
|
+
::Rack::MiniProfiler.record_sql(message, duration * 1000)
|
|
9
|
+
log_duration_original(duration, message)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
if ENV['RACK_MINI_PROFILER_PATCH_NET_HTTP'] != 'false'
|
|
4
|
+
if (defined?(Net) && defined?(Net::HTTP))
|
|
5
|
+
if defined?(Rack::MINI_PROFILER_PREPEND_NET_HTTP_PATCH)
|
|
6
|
+
module NetHTTPWithMiniProfiler
|
|
7
|
+
def request(request, *args, &block)
|
|
8
|
+
Rack::MiniProfiler.step("Net::HTTP #{request.method} #{request.path}") do
|
|
9
|
+
super
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
Net::HTTP.prepend(NetHTTPWithMiniProfiler)
|
|
14
|
+
else
|
|
15
|
+
Net::HTTP.class_eval do
|
|
16
|
+
def request_with_mini_profiler(*args, &block)
|
|
17
|
+
request = args[0]
|
|
18
|
+
Rack::MiniProfiler.step("Net::HTTP #{request.method} #{request.path}") do
|
|
19
|
+
request_without_mini_profiler(*args, &block)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
alias request_without_mini_profiler request
|
|
23
|
+
alias request request_with_mini_profiler
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class SqlPatches
|
|
4
|
+
def self.correct_version?(required_version, klass)
|
|
5
|
+
Gem::Dependency.new('', required_version).match?('', klass::VERSION)
|
|
6
|
+
rescue NameError
|
|
7
|
+
false
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.record_sql(statement, parameters = nil, &block)
|
|
11
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
12
|
+
result = yield
|
|
13
|
+
record = ::Rack::MiniProfiler.record_sql(statement, elapsed_time(start), parameters)
|
|
14
|
+
[result, record]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.should_measure?
|
|
18
|
+
current = ::Rack::MiniProfiler.current
|
|
19
|
+
(current && current.measure)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.elapsed_time(start_time)
|
|
23
|
+
((Process.clock_gettime(Process::CLOCK_MONOTONIC) - start_time).to_f * 1000).round(1)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.patch_rails?
|
|
27
|
+
::Rack::MiniProfiler.patch_rails?
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.sql_patches
|
|
31
|
+
patches = []
|
|
32
|
+
|
|
33
|
+
patches << 'mysql2' if defined?(Mysql2::Client) && Mysql2::Client.class == Class && patch_rails?
|
|
34
|
+
patches << 'pg' if defined?(PG::Result) && PG::Result.class == Class && patch_rails?
|
|
35
|
+
patches << 'oracle_enhanced' if defined?(ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter) && ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.class == Class &&
|
|
36
|
+
SqlPatches.correct_version?('~> 1.5.0', ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter) &&
|
|
37
|
+
patch_rails?
|
|
38
|
+
# if the adapters were directly patched, don't patch again
|
|
39
|
+
if !patches.empty?
|
|
40
|
+
Rack::MiniProfiler.subscribe_sql_active_record = false
|
|
41
|
+
return patches
|
|
42
|
+
end
|
|
43
|
+
patches << 'sequel' if defined?(Sequel::Database) && Sequel::Database.class == Class
|
|
44
|
+
patches << 'activerecord' if defined?(ActiveRecord) && ActiveRecord.class == Module && patch_rails?
|
|
45
|
+
Rack::MiniProfiler.subscribe_sql_active_record = patches.empty? && !patch_rails?
|
|
46
|
+
patches
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def self.other_patches
|
|
50
|
+
patches = []
|
|
51
|
+
patches << 'mongo' if defined?(Mongo::Server::Connection) && Mongo.class == Module
|
|
52
|
+
patches << 'moped' if defined?(Moped::Node) && Moped::Node.class == Class
|
|
53
|
+
patches << 'plucky' if defined?(Plucky::Query) && Plucky::Query.class == Class
|
|
54
|
+
patches << 'rsolr' if defined?(RSolr::Connection) && RSolr::Connection.class == Class && RSolr::VERSION[0] != "0"
|
|
55
|
+
patches << 'nobrainer' if defined?(NoBrainer) && NoBrainer.class == Module
|
|
56
|
+
patches << 'riak' if defined?(Riak) && Riak.class == Module
|
|
57
|
+
patches << 'neo4j' if defined?(Neo4j::Core) && Neo4j::Core::Query.class == Class
|
|
58
|
+
patches
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def self.all_patch_files
|
|
62
|
+
env_var = ENV["RACK_MINI_PROFILER_PATCH"]
|
|
63
|
+
return [] if env_var == "false"
|
|
64
|
+
env_var ? env_var.split(",").map(&:strip) : sql_patches + other_patches
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def self.patch(patch_files = all_patch_files)
|
|
68
|
+
patch_files.each do |patch_file|
|
|
69
|
+
require "patches/db/#{patch_file}"
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
SqlPatches.patch
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'mini_profiler/version'
|
|
4
|
+
require 'mini_profiler/asset_version'
|
|
5
|
+
|
|
6
|
+
require 'mini_profiler'
|
|
7
|
+
|
|
8
|
+
require 'patches/sql_patches'
|
|
9
|
+
require 'patches/net_patches'
|
|
10
|
+
|
|
11
|
+
if defined?(::Rails) && defined?(::Rails::VERSION) && ::Rails::VERSION::MAJOR.to_i >= 3
|
|
12
|
+
require 'mini_profiler_rails/railtie'
|
|
13
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
4
|
+
$LOAD_PATH.unshift(lib) if !$LOAD_PATH.include?(lib)
|
|
5
|
+
require 'mini_profiler/version'
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |s|
|
|
8
|
+
s.name = "rack-mini-profiler"
|
|
9
|
+
s.version = Rack::MiniProfiler::VERSION
|
|
10
|
+
s.summary = "Profiles loading speed for rack applications."
|
|
11
|
+
s.authors = ["Sam Saffron", "Robin Ward", "Aleks Totic"]
|
|
12
|
+
s.description = "Profiling toolkit for Rack applications with Rails integration. Client Side profiling, DB profiling and Server profiling."
|
|
13
|
+
s.email = "sam.saffron@gmail.com"
|
|
14
|
+
s.homepage = "https://miniprofiler.com"
|
|
15
|
+
s.license = "MIT"
|
|
16
|
+
s.files = [
|
|
17
|
+
'rack-mini-profiler.gemspec',
|
|
18
|
+
].concat(Dir.glob('lib/**/*').reject { |f| File.directory?(f) || f =~ /~$/ })
|
|
19
|
+
s.extra_rdoc_files = [
|
|
20
|
+
"README.md",
|
|
21
|
+
"CHANGELOG.md"
|
|
22
|
+
]
|
|
23
|
+
s.add_runtime_dependency 'rack', '>= 1.2.0'
|
|
24
|
+
s.required_ruby_version = '>= 3.1.0'
|
|
25
|
+
|
|
26
|
+
s.metadata = {
|
|
27
|
+
'source_code_uri' => Rack::MiniProfiler::SOURCE_CODE_URI,
|
|
28
|
+
'changelog_uri' => 'https://github.com/MiniProfiler/rack-mini-profiler/blob/master/CHANGELOG.md'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
s.add_development_dependency 'rake'
|
|
32
|
+
s.add_development_dependency 'rack-test'
|
|
33
|
+
s.add_development_dependency 'dalli'
|
|
34
|
+
s.add_development_dependency 'rspec', '~> 3.12.0'
|
|
35
|
+
s.add_development_dependency 'redis'
|
|
36
|
+
s.add_development_dependency 'sassc'
|
|
37
|
+
s.add_development_dependency 'stackprof'
|
|
38
|
+
s.add_development_dependency 'rubocop'
|
|
39
|
+
s.add_development_dependency 'mini_racer'
|
|
40
|
+
s.add_development_dependency 'nokogiri'
|
|
41
|
+
s.add_development_dependency 'rubocop-discourse'
|
|
42
|
+
s.add_development_dependency 'listen'
|
|
43
|
+
s.add_development_dependency 'webpacker'
|
|
44
|
+
s.add_development_dependency 'rails', '>= 7.1'
|
|
45
|
+
s.add_development_dependency 'webmock', '3.9.1'
|
|
46
|
+
s.add_development_dependency 'rubyzip'
|
|
47
|
+
|
|
48
|
+
s.require_paths = ["lib"]
|
|
49
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: mini-sharp-hub
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Andrey78
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 2026-07-06 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: University research based on rack-mini-profiler
|
|
13
|
+
email:
|
|
14
|
+
- cakoc614@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- mini-sharp-hub.gemspec
|
|
20
|
+
- rack-mini-profiler-4.0.1/CHANGELOG.md
|
|
21
|
+
- rack-mini-profiler-4.0.1/README.md
|
|
22
|
+
- rack-mini-profiler-4.0.1/lib/enable_rails_patches.rb
|
|
23
|
+
- rack-mini-profiler-4.0.1/lib/generators/rack_mini_profiler/USAGE
|
|
24
|
+
- rack-mini-profiler-4.0.1/lib/generators/rack_mini_profiler/install_generator.rb
|
|
25
|
+
- rack-mini-profiler-4.0.1/lib/generators/rack_mini_profiler/templates/rack_mini_profiler.rb
|
|
26
|
+
- rack-mini-profiler-4.0.1/lib/generators/rack_profiler/USAGE
|
|
27
|
+
- rack-mini-profiler-4.0.1/lib/generators/rack_profiler/install_generator.rb
|
|
28
|
+
- rack-mini-profiler-4.0.1/lib/html/dot.1.1.2.min.js
|
|
29
|
+
- rack-mini-profiler-4.0.1/lib/html/includes.css
|
|
30
|
+
- rack-mini-profiler-4.0.1/lib/html/includes.js
|
|
31
|
+
- rack-mini-profiler-4.0.1/lib/html/includes.scss
|
|
32
|
+
- rack-mini-profiler-4.0.1/lib/html/includes.tmpl
|
|
33
|
+
- rack-mini-profiler-4.0.1/lib/html/pretty-print.js
|
|
34
|
+
- rack-mini-profiler-4.0.1/lib/html/profile_handler.js
|
|
35
|
+
- rack-mini-profiler-4.0.1/lib/html/rack-mini-profiler.css
|
|
36
|
+
- rack-mini-profiler-4.0.1/lib/html/rack-mini-profiler.js
|
|
37
|
+
- rack-mini-profiler-4.0.1/lib/html/share.html
|
|
38
|
+
- rack-mini-profiler-4.0.1/lib/html/speedscope/LICENSE
|
|
39
|
+
- rack-mini-profiler-4.0.1/lib/html/speedscope/README.md
|
|
40
|
+
- rack-mini-profiler-4.0.1/lib/html/speedscope/demangle-cpp.1768f4cc.js
|
|
41
|
+
- rack-mini-profiler-4.0.1/lib/html/speedscope/favicon-16x16.f74b3187.png
|
|
42
|
+
- rack-mini-profiler-4.0.1/lib/html/speedscope/favicon-32x32.bc503437.png
|
|
43
|
+
- rack-mini-profiler-4.0.1/lib/html/speedscope/file-format-schema.json
|
|
44
|
+
- rack-mini-profiler-4.0.1/lib/html/speedscope/fonts/source-code-pro-regular.css
|
|
45
|
+
- rack-mini-profiler-4.0.1/lib/html/speedscope/fonts/source-code-pro-v13-regular.woff
|
|
46
|
+
- rack-mini-profiler-4.0.1/lib/html/speedscope/fonts/source-code-pro-v13-regular.woff2
|
|
47
|
+
- rack-mini-profiler-4.0.1/lib/html/speedscope/import.8ae8aa3d.js
|
|
48
|
+
- rack-mini-profiler-4.0.1/lib/html/speedscope/index.html
|
|
49
|
+
- rack-mini-profiler-4.0.1/lib/html/speedscope/release.txt
|
|
50
|
+
- rack-mini-profiler-4.0.1/lib/html/speedscope/reset.8c46b7a1.css
|
|
51
|
+
- rack-mini-profiler-4.0.1/lib/html/speedscope/source-map.438fa06b.js
|
|
52
|
+
- rack-mini-profiler-4.0.1/lib/html/speedscope/speedscope.f27db165.js
|
|
53
|
+
- rack-mini-profiler-4.0.1/lib/html/vendor.js
|
|
54
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler.rb
|
|
55
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/actions.rb
|
|
56
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/asset_version.rb
|
|
57
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/client_settings.rb
|
|
58
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/config.rb
|
|
59
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/context.rb
|
|
60
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/gc_profiler.rb
|
|
61
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/profiling_methods.rb
|
|
62
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/snapshots_transporter.rb
|
|
63
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/storage.rb
|
|
64
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/storage/abstract_store.rb
|
|
65
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/storage/file_store.rb
|
|
66
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/storage/memcache_store.rb
|
|
67
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/storage/memory_store.rb
|
|
68
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/storage/redis_store.rb
|
|
69
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct.rb
|
|
70
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct/base.rb
|
|
71
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct/client.rb
|
|
72
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct/custom.rb
|
|
73
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct/page.rb
|
|
74
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct/request.rb
|
|
75
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/timer_struct/sql.rb
|
|
76
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/version.rb
|
|
77
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler/views.rb
|
|
78
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler_rails/railtie.rb
|
|
79
|
+
- rack-mini-profiler-4.0.1/lib/mini_profiler_rails/railtie_methods.rb
|
|
80
|
+
- rack-mini-profiler-4.0.1/lib/patches/db/activerecord.rb
|
|
81
|
+
- rack-mini-profiler-4.0.1/lib/patches/db/mongo.rb
|
|
82
|
+
- rack-mini-profiler-4.0.1/lib/patches/db/moped.rb
|
|
83
|
+
- rack-mini-profiler-4.0.1/lib/patches/db/mysql2.rb
|
|
84
|
+
- rack-mini-profiler-4.0.1/lib/patches/db/mysql2/alias_method.rb
|
|
85
|
+
- rack-mini-profiler-4.0.1/lib/patches/db/mysql2/prepend.rb
|
|
86
|
+
- rack-mini-profiler-4.0.1/lib/patches/db/neo4j.rb
|
|
87
|
+
- rack-mini-profiler-4.0.1/lib/patches/db/nobrainer.rb
|
|
88
|
+
- rack-mini-profiler-4.0.1/lib/patches/db/oracle_enhanced.rb
|
|
89
|
+
- rack-mini-profiler-4.0.1/lib/patches/db/pg.rb
|
|
90
|
+
- rack-mini-profiler-4.0.1/lib/patches/db/pg/alias_method.rb
|
|
91
|
+
- rack-mini-profiler-4.0.1/lib/patches/db/pg/prepend.rb
|
|
92
|
+
- rack-mini-profiler-4.0.1/lib/patches/db/plucky.rb
|
|
93
|
+
- rack-mini-profiler-4.0.1/lib/patches/db/riak.rb
|
|
94
|
+
- rack-mini-profiler-4.0.1/lib/patches/db/rsolr.rb
|
|
95
|
+
- rack-mini-profiler-4.0.1/lib/patches/db/sequel.rb
|
|
96
|
+
- rack-mini-profiler-4.0.1/lib/patches/net_patches.rb
|
|
97
|
+
- rack-mini-profiler-4.0.1/lib/patches/sql_patches.rb
|
|
98
|
+
- rack-mini-profiler-4.0.1/lib/prepend_mysql2_patch.rb
|
|
99
|
+
- rack-mini-profiler-4.0.1/lib/prepend_net_http_patch.rb
|
|
100
|
+
- rack-mini-profiler-4.0.1/lib/prepend_pg_patch.rb
|
|
101
|
+
- rack-mini-profiler-4.0.1/lib/rack-mini-profiler.rb
|
|
102
|
+
- rack-mini-profiler-4.0.1/rack-mini-profiler.gemspec
|
|
103
|
+
homepage: https://rubygems.org/profiles/Andrey78
|
|
104
|
+
licenses:
|
|
105
|
+
- MIT
|
|
106
|
+
metadata:
|
|
107
|
+
source_code_uri: https://github.com/Andrey78/mini-sharp-hub
|
|
108
|
+
rdoc_options: []
|
|
109
|
+
require_paths:
|
|
110
|
+
- lib
|
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
|
+
requirements:
|
|
113
|
+
- - ">="
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
115
|
+
version: '0'
|
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
|
+
requirements:
|
|
118
|
+
- - ">="
|
|
119
|
+
- !ruby/object:Gem::Version
|
|
120
|
+
version: '0'
|
|
121
|
+
requirements: []
|
|
122
|
+
rubygems_version: 3.6.2
|
|
123
|
+
specification_version: 4
|
|
124
|
+
summary: Research test
|
|
125
|
+
test_files: []
|