6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/logstasher/rails_ext/action_controller/metal/instrumentation.rb', line 6
def process_action(*args)
raw_payload = {
controller: self.class.name,
action: action_name,
params: request.filtered_parameters,
format: request.format.try(:ref),
method: request.method,
path: begin
request.fullpath
rescue StandardError
'unknown'
end
}
LogStasher.add_default_fields_to_payload(raw_payload, request)
LogStasher.clear_request_context
LogStasher.add_default_fields_to_request_context(request)
ActiveSupport::Notifications.instrument('start_processing.action_controller', raw_payload.dup)
ActiveSupport::Notifications.instrument('process_action.action_controller', raw_payload) do |payload|
if respond_to?(:logstasher_add_custom_fields_to_request_context)
logstasher_add_custom_fields_to_request_context(LogStasher.request_context)
end
if respond_to?(:logstasher_add_custom_fields_to_payload)
before_keys = raw_payload.keys.clone
logstasher_add_custom_fields_to_payload(raw_payload)
after_keys = raw_payload.keys
LogStasher::CustomFields.add(*(after_keys - before_keys))
end
result = super
payload[:status] = response.status
append_info_to_payload(payload)
LogStasher.store.each do |key, value|
payload[key] = value
end
LogStasher.request_context.each do |key, value|
payload[key] = value
end
result
end
end
|