app_profiler 0.0.1 → 0.0.7
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/lib/app_profiler.rb +15 -1
- data/lib/app_profiler/middleware/upload_action.rb +5 -1
- data/lib/app_profiler/profiler.rb +16 -16
- data/lib/app_profiler/railtie.rb +1 -0
- data/lib/app_profiler/request_parameters.rb +2 -2
- data/lib/app_profiler/storage/file_storage.rb +4 -0
- data/lib/app_profiler/version.rb +1 -1
- data/lib/app_profiler/viewer/speedscope_viewer.rb +9 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b93daeac19342da210b998d381259941dc1d12c96fa5d58097423d86b32c03f3
|
4
|
+
data.tar.gz: d7b50f279a8b197ba847363db5a6e92b394ac506804d9a499c519dcd36b6071c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d996e6faf3bb8c02e8f34e462d3c74beac53d656d188330972ecba83770524b42dbc36132aa8b6e2cadd57fe0b6b5504a548a1d96ae58b3e7e14ac504d672f2e
|
7
|
+
data.tar.gz: 124bc292cff5decf4cdf7f7d4b8b22cc2820123a1fbda5f56970a1fd76da74675e68dbb5a953024c778eb64bb5c9a7ff8b41f0a62be5dcbdd0f6e214a7cc8fc7
|
data/lib/app_profiler.rb
CHANGED
@@ -24,7 +24,7 @@ module AppProfiler
|
|
24
24
|
autoload :Profiler, "app_profiler/profiler"
|
25
25
|
autoload :Profile, "app_profiler/profile"
|
26
26
|
|
27
|
-
mattr_accessor :logger
|
27
|
+
mattr_accessor :logger, default: Logger.new($stdout)
|
28
28
|
mattr_accessor :root
|
29
29
|
mattr_accessor :profile_root
|
30
30
|
|
@@ -32,6 +32,7 @@ module AppProfiler
|
|
32
32
|
mattr_accessor :autoredirect, default: false
|
33
33
|
mattr_reader :profile_header, default: "X-Profile"
|
34
34
|
mattr_accessor :context, default: nil
|
35
|
+
mattr_reader :profile_url_formatter, default: nil
|
35
36
|
|
36
37
|
mattr_accessor :storage, default: Storage::FileStorage
|
37
38
|
mattr_accessor :viewer, default: Viewer::SpeedscopeViewer
|
@@ -42,6 +43,15 @@ module AppProfiler
|
|
42
43
|
Profiler.run(*args, &block)
|
43
44
|
end
|
44
45
|
|
46
|
+
def start(*args)
|
47
|
+
Profiler.start(*args)
|
48
|
+
end
|
49
|
+
|
50
|
+
def stop
|
51
|
+
Profiler.stop
|
52
|
+
Profiler.results
|
53
|
+
end
|
54
|
+
|
45
55
|
def profile_header=(profile_header)
|
46
56
|
@@profile_header = profile_header # rubocop:disable Style/ClassVars
|
47
57
|
@@request_profile_header = nil # rubocop:disable Style/ClassVars
|
@@ -57,5 +67,9 @@ module AppProfiler
|
|
57
67
|
def profile_data_header
|
58
68
|
@@profile_data_header ||= profile_header.dup << "-Data" # rubocop:disable Style/ClassVars
|
59
69
|
end
|
70
|
+
|
71
|
+
def profile_url_formatter=(block)
|
72
|
+
@@profile_url_formatter = block # rubocop:disable Style/ClassVars
|
73
|
+
end
|
60
74
|
end
|
61
75
|
end
|
@@ -34,7 +34,11 @@ module AppProfiler
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def profile_url(upload)
|
37
|
-
|
37
|
+
if AppProfiler.profile_url_formatter.nil?
|
38
|
+
"#{AppProfiler.speedscope_host}#profileURL=#{upload.url}"
|
39
|
+
else
|
40
|
+
AppProfiler.profile_url_formatter.call(upload)
|
41
|
+
end
|
38
42
|
end
|
39
43
|
|
40
44
|
def profile_data_url(upload)
|
@@ -24,28 +24,13 @@ module AppProfiler
|
|
24
24
|
stop if started
|
25
25
|
end
|
26
26
|
|
27
|
-
def results
|
28
|
-
stackprof_profile = stackprof_results
|
29
|
-
|
30
|
-
return unless stackprof_profile
|
31
|
-
|
32
|
-
Profile.from_stackprof(stackprof_profile)
|
33
|
-
rescue => error
|
34
|
-
AppProfiler.logger.info(
|
35
|
-
"[Profiler] failed to obtain the profile error_class=#{error.class} error_message=#{error.message}"
|
36
|
-
)
|
37
|
-
nil
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
27
|
def start(params = {})
|
43
28
|
# Do not start the profiler if StackProf was started somewhere else.
|
44
29
|
return false if running?
|
45
30
|
|
46
31
|
clear
|
47
32
|
|
48
|
-
StackProf.start(DEFAULTS
|
33
|
+
StackProf.start(**DEFAULTS, **params)
|
49
34
|
rescue => error
|
50
35
|
AppProfiler.logger.info(
|
51
36
|
"[Profiler] failed to start the profiler error_class=#{error.class} error_message=#{error.message}"
|
@@ -59,6 +44,21 @@ module AppProfiler
|
|
59
44
|
StackProf.stop
|
60
45
|
end
|
61
46
|
|
47
|
+
def results
|
48
|
+
stackprof_profile = stackprof_results
|
49
|
+
|
50
|
+
return unless stackprof_profile
|
51
|
+
|
52
|
+
Profile.from_stackprof(stackprof_profile)
|
53
|
+
rescue => error
|
54
|
+
AppProfiler.logger.info(
|
55
|
+
"[Profiler] failed to obtain the profile error_class=#{error.class} error_message=#{error.message}"
|
56
|
+
)
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
62
|
def stackprof_results
|
63
63
|
StackProf.results
|
64
64
|
end
|
data/lib/app_profiler/railtie.rb
CHANGED
@@ -25,6 +25,7 @@ module AppProfiler
|
|
25
25
|
"tmp", "app_profiler"
|
26
26
|
)
|
27
27
|
AppProfiler.context = app.config.app_profiler.context || Rails.env
|
28
|
+
AppProfiler.profile_url_formatter = app.config.app_profiler.profile_url_formatter
|
28
29
|
end
|
29
30
|
|
30
31
|
initializer "app_profiler.add_middleware" do |app|
|
@@ -4,8 +4,8 @@ require "rack"
|
|
4
4
|
|
5
5
|
module AppProfiler
|
6
6
|
class RequestParameters
|
7
|
-
DEFAULT_INTERVALS = { "cpu" => 1000, "wall" => 1000, "object" =>
|
8
|
-
MIN_INTERVALS = { "cpu" => 200, "wall" => 200, "object" =>
|
7
|
+
DEFAULT_INTERVALS = { "cpu" => 1000, "wall" => 1000, "object" => 2000 }.freeze
|
8
|
+
MIN_INTERVALS = { "cpu" => 200, "wall" => 200, "object" => 400 }.freeze
|
9
9
|
MODES = DEFAULT_INTERVALS.keys.freeze
|
10
10
|
|
11
11
|
def initialize(request)
|
data/lib/app_profiler/version.rb
CHANGED
@@ -14,6 +14,7 @@ module AppProfiler
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def initialize(profile)
|
17
|
+
super()
|
17
18
|
@profile = profile
|
18
19
|
end
|
19
20
|
|
@@ -33,7 +34,10 @@ module AppProfiler
|
|
33
34
|
def setup_yarn
|
34
35
|
ensure_yarn_installed
|
35
36
|
yarn("init --yes") unless package_json_exists?
|
36
|
-
|
37
|
+
# We currently only support this gem in the root Gemfile.
|
38
|
+
# See https://github.com/Shopify/app_profiler/issues/15
|
39
|
+
# for more information
|
40
|
+
yarn("add --dev --ignore-workspace-root-check speedscope") unless speedscope_added?
|
37
41
|
end
|
38
42
|
|
39
43
|
def ensure_yarn_installed
|
@@ -53,6 +57,10 @@ module AppProfiler
|
|
53
57
|
AppProfiler.root.join("package.json").exist?
|
54
58
|
end
|
55
59
|
|
60
|
+
def speedscope_added?
|
61
|
+
AppProfiler.root.join("node_modules/speedscope").exist?
|
62
|
+
end
|
63
|
+
|
56
64
|
def exec(command)
|
57
65
|
system(command).tap do |return_code|
|
58
66
|
yield unless return_code
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app_profiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gannon McGibbon
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date:
|
16
|
+
date: 2021-02-19 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: activesupport
|
@@ -165,7 +165,8 @@ files:
|
|
165
165
|
- lib/app_profiler/viewer/speedscope_viewer.rb
|
166
166
|
homepage: https://github.com/Shopify/app_profiler
|
167
167
|
licenses: []
|
168
|
-
metadata:
|
168
|
+
metadata:
|
169
|
+
allowed_push_host: https://rubygems.org
|
169
170
|
post_install_message:
|
170
171
|
rdoc_options: []
|
171
172
|
require_paths:
|