lib/logstasher/log_subscriber.rb in md-logstasher-1.3.0 vs lib/logstasher/log_subscriber.rb in md-logstasher-1.4.0

- old
+ new

@@ -19,11 +19,10 @@ def process_action(event) payload = event.payload tags = extract_tags(payload) fields = extract_request(payload) - fields.merge! extract_status(payload) fields.merge! runtimes(event) fields.merge! location fields.merge! extract_exception(payload) fields.merge! extract_parameters(payload) @@ -50,20 +49,23 @@ def controller Thread.current[:logstasher_context][:controller] end def extract_request(payload) - { + result = { :action => payload[:action], :controller => payload[:controller], :format => extract_format(payload), :ip => request.remote_ip, :request_id => request.env["action_dispatch.request_id"], :method => payload[:method], :path => extract_path(payload), :route => "#{payload[:controller]}##{payload[:action]}" } + metadata = ::LogStasher.metadata + result.merge!(:metadata => metadata) unless metadata&.empty? + result end # Monkey patching to enable exception logging def extract_exception(payload) if payload[:exception] @@ -85,10 +87,9 @@ end def extract_parameters(payload) if LogStasher.include_parameters? external_params = payload[:params].except(*INTERNAL_PARAMS) - if LogStasher.serialize_parameters? { :params => JSON.generate(external_params) } else { :params => external_params } end