rails_spotlight 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/lib/rails_spotlight/app_notifications.rb +13 -0
- data/lib/rails_spotlight/configuration.rb +22 -1
- data/lib/rails_spotlight/render_view_reporter.rb +32 -0
- data/lib/rails_spotlight/version.rb +1 -1
- data/lib/rails_spotlight.rb +10 -9
- data/lib/tasks/init.rake +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e36512b12e263c5853279d061fe2760ad7fff28c754c3362f8c848867845477
|
4
|
+
data.tar.gz: cc4696e37e250be0413f0286503f8a63fa18a2c43353114720e9580fa4fc646e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd8e249fcfe8ced528c2f60225b00e8142e93989736d77090b9cc3ad0a9cf8c50dcbc85b9f76f196168ab1e6946f85d594c48935fe0751e8675d612f2d3fffa1
|
7
|
+
data.tar.gz: 925e741a5c6b755deed002c3833da4487a24a530d025177373fa86fca3a5ad2ef84d1730497c7c2ad128a2c9bf526127166252793b056e587ed43ab6a585dbea
|
data/README.md
CHANGED
@@ -38,6 +38,7 @@ file will be created in `config/rails_spotlight.yml`
|
|
38
38
|
LOGGER: <%=Logger.new(Rails.root.join('log', 'rails_spotlight.log'))%>
|
39
39
|
MIDDLEWARE_SKIPPED_PATHS: []
|
40
40
|
NOT_ENCODABLE_EVENT_VALUES:
|
41
|
+
SKIP_RENDERED_IVARS: []
|
41
42
|
# Rest of the configuration is required for ActionCable. It will be disabled automatically in when ActionCable is not available.
|
42
43
|
# LIVE_CONSOLE_ENABLED from version 0.2.3 do not require ActionCable to be enabled.
|
43
44
|
LIVE_CONSOLE_ENABLED: false
|
@@ -49,6 +50,16 @@ file will be created in `config/rails_spotlight.yml`
|
|
49
50
|
BLOCK_EDITING_FILES_OUTSIDE_OF_THE_PROJECT: true
|
50
51
|
```
|
51
52
|
|
53
|
+
## Additional metrics
|
54
|
+
|
55
|
+
To enable additional rendering metrics like local variables, instance variables, params etc. add to your layout file:
|
56
|
+
|
57
|
+
```erb
|
58
|
+
<% if Rails.env.development? %>
|
59
|
+
<%= RailsSpotlight::RenderViewReporter.report_rendered_view_locals(self, locals: local_assigns, params: params, skip_vars: %i[current_template], metadata: { just_test: 'Works' }) %>
|
60
|
+
<% end %>
|
61
|
+
```
|
62
|
+
|
52
63
|
## Troubleshooting
|
53
64
|
|
54
65
|
Known issue:
|
@@ -31,6 +31,11 @@ module RailsSpotlight
|
|
31
31
|
Event.new(name, start, ending, transaction_id, payload)
|
32
32
|
}
|
33
33
|
|
34
|
+
VIEW_LOCALS_BLOCK = proc { |*args|
|
35
|
+
name, start, ending, transaction_id, payload = args
|
36
|
+
Event.new(name, start, ending, transaction_id, payload)
|
37
|
+
}
|
38
|
+
|
34
39
|
# sql processing block - used for sql.active_record and sql.sequel
|
35
40
|
|
36
41
|
# HACK: we hardcode the event name to 'sql.active_record' so that the ui will
|
@@ -75,6 +80,14 @@ module RailsSpotlight
|
|
75
80
|
.subscribe('cache_write.active_support', &CACHE_BLOCK)
|
76
81
|
.subscribe('cache_delete.active_support', &CACHE_BLOCK)
|
77
82
|
.subscribe('cache_exist?.active_support', &CACHE_BLOCK)
|
83
|
+
.subscribe('render_view.locals', &VIEW_LOCALS_BLOCK)
|
84
|
+
|
85
|
+
# TODO: Consider adding these events
|
86
|
+
# start_processing.action_controller: Triggered when a controller action starts processing a request.
|
87
|
+
# send_file.action_controller: Triggered when a file is sent as a response.
|
88
|
+
# redirect_to.action_controller: Triggered when a redirect response is sent.
|
89
|
+
# halted_callback.action_controller: Triggered when a filter or callback halts the request.
|
90
|
+
# render_collection.action_view: This event is triggered when a collection is rendered using a partial. It includes details about the collection being rendered, such as the collection name and the partial being used to render each item.
|
78
91
|
end
|
79
92
|
|
80
93
|
def subscribe(event_name)
|
@@ -10,9 +10,29 @@ module RailsSpotlight
|
|
10
10
|
'ActionDispatch' => ['ActionDispatch::Request', 'ActionDispatch::Response']
|
11
11
|
}.freeze
|
12
12
|
|
13
|
+
SKIP_RENDERED_IVARS = %i[
|
14
|
+
@_routes
|
15
|
+
@_config
|
16
|
+
@view_renderer
|
17
|
+
@lookup_context
|
18
|
+
@_assigns
|
19
|
+
@_controller
|
20
|
+
@_request
|
21
|
+
@_default_form_builder
|
22
|
+
@view_flow
|
23
|
+
@output_buffer
|
24
|
+
@virtual_path
|
25
|
+
@tag_builder
|
26
|
+
@assets_environment
|
27
|
+
@asset_resolver_strategies
|
28
|
+
@_main_app
|
29
|
+
@_devise_route_context
|
30
|
+
@devise_mapping
|
31
|
+
].freeze
|
32
|
+
|
13
33
|
attr_reader :project_name, :source_path, :logger, :storage_path, :storage_pool_size, :middleware_skipped_paths,
|
14
34
|
:not_encodable_event_values, :action_cable_mount_path,
|
15
|
-
:block_editing_files, :block_editing_files_outside_of_the_project
|
35
|
+
:block_editing_files, :block_editing_files_outside_of_the_project, :skip_rendered_ivars
|
16
36
|
|
17
37
|
def initialize(opts = {}) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
|
18
38
|
@project_name = opts[:project_name] || detect_project_name
|
@@ -28,6 +48,7 @@ module RailsSpotlight
|
|
28
48
|
@action_cable_mount_path = opts[:action_cable_mount_path] || '/cable'
|
29
49
|
@block_editing_files = opts[:block_editing_files].nil? ? false : true?(opts[:block_editing_files])
|
30
50
|
@block_editing_files_outside_of_the_project = opts[:block_editing_files_outside_of_the_project].nil? ? true : true?(opts[:block_editing_files_outside_of_the_project])
|
51
|
+
@skip_rendered_ivars = SKIP_RENDERED_IVARS + (opts[:skip_rendered_ivars] || []).map(&:to_sym)
|
31
52
|
end
|
32
53
|
|
33
54
|
def live_console_enabled
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RailsSpotlight
|
2
|
+
class RenderViewReporter
|
3
|
+
def self.report_rendered_view_locals(view, locals: nil, params: nil, show_devise: false, skip_vars: [], metadata: {})
|
4
|
+
ActiveSupport::Notifications.instrument(
|
5
|
+
'render_view.locals',
|
6
|
+
params: params,
|
7
|
+
locals: serialize_as_json(locals),
|
8
|
+
instance_variables: dev_instance_variables(view, skip_vars: skip_vars, show_devise: show_devise),
|
9
|
+
metadata: metadata
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.serialize_as_json(value)
|
14
|
+
value.respond_to?(:as_json) ? value.as_json : nil
|
15
|
+
rescue => e
|
16
|
+
{
|
17
|
+
__serialization_error: e.message,
|
18
|
+
__source: value.inspect
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.dev_instance_variables(source, skip_vars: [], show_devise: false)
|
23
|
+
source.instance_variables.map do |name|
|
24
|
+
next if skip_vars.include?(name)
|
25
|
+
next if RailsSpotlight.config.skip_rendered_ivars.include?(name)
|
26
|
+
next if !show_devise && name == :@devise_parameter_sanitizer
|
27
|
+
|
28
|
+
[name[1..], source.instance_variable_get(name)]
|
29
|
+
end.compact.to_h
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/rails_spotlight.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module RailsSpotlight
|
4
|
-
autoload :VERSION,
|
5
|
-
autoload :Configuration,
|
6
|
-
autoload :Storage,
|
7
|
-
autoload :Event,
|
8
|
-
autoload :AppRequest,
|
9
|
-
autoload :Middlewares,
|
10
|
-
autoload :LogInterceptor,
|
11
|
-
autoload :AppNotifications,
|
12
|
-
autoload :Utils,
|
4
|
+
autoload :VERSION, 'rails_spotlight/version'
|
5
|
+
autoload :Configuration, 'rails_spotlight/configuration'
|
6
|
+
autoload :Storage, 'rails_spotlight/storage'
|
7
|
+
autoload :Event, 'rails_spotlight/event'
|
8
|
+
autoload :AppRequest, 'rails_spotlight/app_request'
|
9
|
+
autoload :Middlewares, 'rails_spotlight/middlewares'
|
10
|
+
autoload :LogInterceptor, 'rails_spotlight/log_interceptor'
|
11
|
+
autoload :AppNotifications, 'rails_spotlight/app_notifications'
|
12
|
+
autoload :Utils, 'rails_spotlight/utils'
|
13
|
+
autoload :RenderViewReporter, 'rails_spotlight/render_view_reporter'
|
13
14
|
|
14
15
|
class << self
|
15
16
|
def config
|
data/lib/tasks/init.rake
CHANGED
@@ -18,6 +18,7 @@ namespace :rails_spotlight do # rubocop:disable Metrics/BlockLength
|
|
18
18
|
LOGGER: <%=Logger.new(Rails.root.join('log', 'rails_spotlight.log'))%>
|
19
19
|
MIDDLEWARE_SKIPPED_PATHS: []
|
20
20
|
NOT_ENCODABLE_EVENT_VALUES:
|
21
|
+
SKIP_RENDERED_IVARS: []
|
21
22
|
# Rest of the configuration is required for ActionCable. It will be disabled automatically in when ActionCable is not available.
|
22
23
|
# LIVE_CONSOLE_ENABLED from version 0.2.3 do not require ActionCable to be enabled.
|
23
24
|
LIVE_CONSOLE_ENABLED: false
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_spotlight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pawel Niemczyk
|
@@ -260,6 +260,7 @@ files:
|
|
260
260
|
- lib/rails_spotlight/middlewares/request_handler.rb
|
261
261
|
- lib/rails_spotlight/rails_command_executor.rb
|
262
262
|
- lib/rails_spotlight/railtie.rb
|
263
|
+
- lib/rails_spotlight/render_view_reporter.rb
|
263
264
|
- lib/rails_spotlight/storage.rb
|
264
265
|
- lib/rails_spotlight/utils.rb
|
265
266
|
- lib/rails_spotlight/version.rb
|