Class: ActionController::StructuredEventSubscriber
Overview
Constant Summary
collapse
- INTERNAL_PARAMS =
%w(controller action format _method only_path)
ActiveSupport::StructuredEventSubscriber::DEBUG_CHECK
Instance Attribute Summary
#silenced_events
#patterns
Instance Method Summary
collapse
attach_to, #call, #emit_debug_event, #emit_event, #initialize, #silenced?
attach_to, #call, detach_from, #initialize, method_added, subscribers
Instance Method Details
#csrf_javascript_blocked(event) ⇒ Object
102
103
104
|
# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 102
def csrf_javascript_blocked(event)
emit_csrf_event "action_controller.csrf_javascript_blocked", event.payload
end
|
#csrf_request_blocked(event) ⇒ Object
98
99
100
|
# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 98
def csrf_request_blocked(event)
emit_csrf_event "action_controller.csrf_request_blocked", event.payload
end
|
#csrf_token_fallback(event) ⇒ Object
94
95
96
|
# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 94
def csrf_token_fallback(event)
emit_csrf_event "action_controller.csrf_token_fallback", event.payload
end
|
#exist_fragment?(event) ⇒ Boolean
122
123
124
|
# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 122
def exist_fragment?(event)
fragment_cache(__method__, event)
end
|
#expire_fragment(event) ⇒ Object
126
127
128
|
# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 126
def expire_fragment(event)
fragment_cache(__method__, event)
end
|
#halted_callback(event) ⇒ Object
43
44
45
|
# 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
|
#open_redirect(event) ⇒ Object
72
73
74
75
76
77
78
79
80
81
|
# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 72
def open_redirect(event)
payload = event.payload
emit_event("action_controller.open_redirect",
location: payload[:location],
request_method: payload[:request]&.method,
request_path: payload[:request]&.path,
stacktrace: payload[:stack_trace],
)
end
|
#process_action(event) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# 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) ⇒ Object
118
119
120
|
# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 118
def read_fragment(event)
fragment_cache(__method__, event)
end
|
#redirect_to(event) ⇒ Object
64
65
66
|
# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 64
def redirect_to(event)
emit_event("action_controller.redirected", location: event.payload[:location])
end
|
#rescue_from_callback(event) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 47
def rescue_from_callback(event)
exception = event.payload[:exception]
exception_backtrace = exception.backtrace&.first
exception_backtrace = exception_backtrace&.delete_prefix("#{Rails.root}/") if defined?(Rails.root) && Rails.root
emit_event("action_controller.rescue_from_handled",
exception_class: exception.class.name,
exception_message: exception.message,
exception_backtrace:
)
end
|
#send_data(event) ⇒ Object
68
69
70
|
# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 68
def send_data(event)
emit_event("action_controller.data_sent", filename: event.payload[:filename], duration_ms: event.duration.round(1))
end
|
#send_file(event) ⇒ Object
60
61
62
|
# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 60
def send_file(event)
emit_event("action_controller.file_sent", path: event.payload[:path], duration_ms: event.duration.round(1))
end
|
#start_processing(event) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# 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) ⇒ Object
83
84
85
86
87
88
89
90
91
|
# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 83
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) ⇒ Object
114
115
116
|
# File 'actionpack/lib/action_controller/structured_event_subscriber.rb', line 114
def write_fragment(event)
fragment_cache(__method__, event)
end
|