rails_spotlight 0.2.3 → 0.2.5
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/README.md +14 -1
- data/lib/rails_spotlight/app_notifications.rb +13 -0
- data/lib/rails_spotlight/configuration.rb +27 -6
- 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 +4 -1
- 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,8 +38,11 @@ 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
|
-
LIVE_CONSOLE_ENABLED
|
43
|
+
# LIVE_CONSOLE_ENABLED from version 0.2.3 do not require ActionCable to be enabled.
|
44
|
+
LIVE_CONSOLE_ENABLED: false
|
45
|
+
# Experimental feature.
|
43
46
|
REQUEST_COMPLETED_BROADCAST_ENABLED: false
|
44
47
|
AUTO_MOUNT_ACTION_CABLE: false
|
45
48
|
ACTION_CABLE_MOUNT_PATH: /cable
|
@@ -47,6 +50,16 @@ file will be created in `config/rails_spotlight.yml`
|
|
47
50
|
BLOCK_EDITING_FILES_OUTSIDE_OF_THE_PROJECT: true
|
48
51
|
```
|
49
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
|
+
|
50
63
|
## Troubleshooting
|
51
64
|
|
52
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
|
@@ -20,14 +40,15 @@ module RailsSpotlight
|
|
20
40
|
@logger = opts[:logger] || Logger.new(File.join(self.class.rails_root, 'log', 'rails_spotlight.log'))
|
21
41
|
@storage_path = opts[:storage_path] || File.join(self.class.rails_root, 'tmp', 'data', 'rails_spotlight')
|
22
42
|
@storage_pool_size = opts[:storage_pool_size] || 20
|
23
|
-
@live_console_enabled = opts[:live_console_enabled].nil? ?
|
24
|
-
@request_completed_broadcast_enabled = true?(opts[:request_completed_broadcast_enabled])
|
43
|
+
@live_console_enabled = opts[:live_console_enabled].nil? ? false : true?(opts[:live_console_enabled])
|
44
|
+
@request_completed_broadcast_enabled = opts[:request_completed_broadcast_enabled].nil? ? false : true?(opts[:request_completed_broadcast_enabled])
|
25
45
|
@middleware_skipped_paths = opts[:middleware_skipped_paths] || []
|
26
46
|
@not_encodable_event_values = DEFAULT_NOT_ENCODABLE_EVENT_VALUES.merge(opts[:not_encodable_event_values] || {})
|
27
|
-
@auto_mount_action_cable = opts[:auto_mount_action_cable].nil? ?
|
47
|
+
@auto_mount_action_cable = opts[:auto_mount_action_cable].nil? ? false : true?(opts[:auto_mount_action_cable])
|
28
48
|
@action_cable_mount_path = opts[:action_cable_mount_path] || '/cable'
|
29
|
-
@block_editing_files = opts[:block_editing_files].nil? ?
|
30
|
-
@block_editing_files_outside_of_the_project = opts[:block_editing_files_outside_of_the_project].nil? ?
|
49
|
+
@block_editing_files = opts[:block_editing_files].nil? ? false : true?(opts[:block_editing_files])
|
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,8 +18,11 @@ 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
|
-
LIVE_CONSOLE_ENABLED
|
23
|
+
# LIVE_CONSOLE_ENABLED from version 0.2.3 do not require ActionCable to be enabled.
|
24
|
+
LIVE_CONSOLE_ENABLED: false
|
25
|
+
# Experimental feature.
|
23
26
|
REQUEST_COMPLETED_BROADCAST_ENABLED: false
|
24
27
|
AUTO_MOUNT_ACTION_CABLE: false
|
25
28
|
ACTION_CABLE_MOUNT_PATH: /cable
|
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
|