<commit_before>module ActionController
  module Instrumentation
    def process_action(*args)
      raw_payload = {
          :controller => self.class.name,
          :action     => self.action_name,
          :params     => request.filtered_parameters,
          :format     => request.format.try(:ref),
          :method     => request.method,
          :path       => (request.fullpath rescue "unknown")
      }

      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 self.respond_to?(:logstasher_add_custom_fields_to_request_context)
          logstasher_add_custom_fields_to_request_context(LogStasher.request_context)
        end

        result = super

        if self.respond_to?(:logtasher_add_custom_fields_to_payload)
          before_keys = raw_payload.keys.clone
          logtasher_add_custom_fields_to_payload(raw_payload)
          after_keys = raw_payload.keys
          # Store all extra keys added to payload hash in payload itself. This is a thread safe way
          LogStasher.custom_fields += after_keys - before_keys
        end

        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

  end
end<commit_msg>Added alias methods to point to old and new methods. Necessary for tests and perhaps somewhere else to.<commit_after>module ActionController
  module Instrumentation
    alias :orig_process_action :process_action
    def process_action(*args)
      raw_payload = {
          :controller => self.class.name,
          :action     => self.action_name,
          :params     => request.filtered_parameters,
          :format     => request.format.try(:ref),
          :method     => request.method,
          :path       => (request.fullpath rescue "unknown")
      }

      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 self.respond_to?(:logstasher_add_custom_fields_to_request_context)
          logstasher_add_custom_fields_to_request_context(LogStasher.request_context)
        end

        result = super

        if self.respond_to?(:logtasher_add_custom_fields_to_payload)
          before_keys = raw_payload.keys.clone
          logtasher_add_custom_fields_to_payload(raw_payload)
          after_keys = raw_payload.keys
          # Store all extra keys added to payload hash in payload itself. This is a thread safe way
          LogStasher.custom_fields += after_keys - before_keys
        end

        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
    alias :logstasher_process_action :process_action

  end
end
{'fraction_non_alphanumeric': 0.07095709570957096, 'fraction_numerical': 0.0, 'mean_word_length': 2.8043933054393304, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2497313', 'n_tokens_mistral': 1041, 'n_tokens_neox': 1017, 'n_words': 196}