Class: ActionController::StructuredEventSubscriber
Do not use. This class is for internal use only.
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
|
|
|
Instance Chain:
|
|
| Inherits: |
ActiveSupport::StructuredEventSubscriber
|
| Defined in: | actionpack/lib/action_controller/structured_event_subscriber.rb |
Constant Summary
-
INTERNAL_PARAMS =
# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 5%w(controller action format _method only_path)
::ActiveSupport::StructuredEventSubscriber - Inherited
Class Attribute Summary
::ActiveSupport::StructuredEventSubscriber - Inherited
::ActiveSupport::Subscriber - Inherited
Class Method Summary
::ActiveSupport::StructuredEventSubscriber - Inherited
::ActiveSupport::Subscriber - Inherited
| .attach_to | Attach the subscriber to a namespace. |
| .detach_from | Detach the subscriber from a namespace. |
| .method_added | Adds event subscribers for all new methods added to the class. |
| .new, .subscribers, .add_event_subscriber, .fetch_public_methods, .find_attached_subscriber, .invalid_event?, .pattern_subscribed?, .prepare_pattern, .remove_event_subscriber | |
Instance Attribute Summary
::ActiveSupport::StructuredEventSubscriber - Inherited
::ActiveSupport::Subscriber - Inherited
Instance Method Summary
- #exist_fragment?(event) ⇒ Boolean
- #expire_fragment(event)
- #halted_callback(event)
- #process_action(event)
- #read_fragment(event)
- #redirect_to(event)
- #rescue_from_callback(event)
- #send_data(event)
- #send_file(event)
- #start_processing(event)
- #unpermitted_parameters(event)
- #write_fragment(event)
- #additions_for(payload) private
- #fragment_cache(method_name, event) private
::ActiveSupport::StructuredEventSubscriber - Inherited
| #call, | |
| #emit_debug_event | Like |
| #emit_event | Emit a structured event via Rails.event.notify. |
| #silenced?, #handle_event_error | |
::ActiveSupport::Subscriber - Inherited
Constructor Details
This class inherits a constructor from ActiveSupport::StructuredEventSubscriber
Instance Method Details
#additions_for(payload) (private)
[ GitHub ]# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 106
def additions_for(payload) payload.slice(:view_runtime, :db_runtime, :queries_count, :cached_queries_count) end
#exist_fragment?(event) ⇒ Boolean
# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 87
def exist_fragment?(event) fragment_cache(__method__, event) end
#expire_fragment(event)
[ GitHub ]# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 91
def expire_fragment(event) fragment_cache(__method__, event) end
#fragment_cache(method_name, event) (private)
[ GitHub ]# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 96
def fragment_cache(method_name, event) key = ActiveSupport::Cache.(event.payload[:key] || event.payload[:path]) emit_event("action_controller.fragment_cache", method: "#{method_name}", key: key, duration_ms: event.duration.round(1) ) end
#halted_callback(event)
[ GitHub ]# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 43
def halted_callback(event) emit_event("action_controller.callback_halted", filter: event.payload[:filter]) end
#process_action(event)
[ GitHub ]# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 25
def process_action(event) payload = event.payload status = payload[:status] if status.nil? && (exception_class_name = payload[:exception]&.first) status = ActionDispatch::ExceptionWrapper.status_code_for_exception(exception_class_name) end emit_event("action_controller.request_completed", { controller: payload[:controller], action: payload[:action], status: status, **additions_for(payload), duration_ms: event.duration.round(2), gc_time_ms: event.gc_time.round(1), }.compact) end
#read_fragment(event)
[ GitHub ]# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 83
def read_fragment(event) fragment_cache(__method__, event) end
#redirect_to(event)
[ GitHub ]# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 60
def redirect_to(event) emit_event("action_controller.redirected", location: event.payload[:location]) end
#rescue_from_callback(event)
[ GitHub ]# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 47
def rescue_from_callback(event) exception = event.payload[:exception] emit_event("action_controller.rescue_from_handled", exception_class: exception.class.name, exception_message: exception., exception_backtrace: exception.backtrace&.first&.delete_prefix("#{Rails.root}/") ) end
#send_data(event)
[ GitHub ]# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 64
def send_data(event) emit_event("action_controller.data_sent", filename: event.payload[:filename], duration_ms: event.duration.round(1)) end
#send_file(event)
[ GitHub ]# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 56
def send_file(event) emit_event("action_controller.file_sent", path: event.payload[:path], duration_ms: event.duration.round(1)) end
#start_processing(event)
[ GitHub ]# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 7
def start_processing(event) payload = event.payload params = {} payload[:params].each_pair do |k, v| params[k] = v unless INTERNAL_PARAMS.include?(k) end format = payload[:format] format = format.to_s.upcase if format.is_a?(Symbol) format = "*/*" if format.nil? emit_event("action_controller.request_started", controller: payload[:controller], action: payload[:action], format:, params:, ) end
#unpermitted_parameters(event)
[ GitHub ]# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 68
def unpermitted_parameters(event) unpermitted_keys = event.payload[:keys] context = event.payload[:context] emit_debug_event("action_controller.unpermitted_parameters", unpermitted_keys:, context: context.except(:request) ) end
#write_fragment(event)
[ GitHub ]# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 79
def write_fragment(event) fragment_cache(__method__, event) end