Sha256: 89d4625b7c860dac66154beb4c4d357f11f6033e7b09ad32d89352d4acbff97a
Contents?: true
Size: 1.52 KB
Versions: 3
Compression:
Stored size: 1.52 KB
Contents
# frozen_string_literal: true require 'active_support/notifications' require 'action_view/log_subscriber' require 'logstasher/custom_fields' module LogStasher module ActionView class LogSubscriber < ::ActionView::LogSubscriber include CustomFields::LogSubscriber def render_template(event) logstash_event(event) end alias render_partial render_template alias render_collection render_template def logger LogStasher.logger end private def logstash_event(event) data = event.payload data.merge! event_data(event) data.merge! runtimes(event) data.merge! extract_data(data) data.merge! request_context data.merge! LogStasher.store data.merge! extract_custom_fields(data) tags = [] tags.push('exception') if data[:exception] logger << "#{LogStasher.build_logstash_event(data, tags).to_json}\n" end def extract_data(data) { identifier: from_rails_root(data[:identifier]) } end def request_context LogStasher.request_context end def store LogStasher.store end def event_data(event) { name: event.name, transaction_id: event.transaction_id } end def runtimes(event) { duration: event.duration }.each_with_object({}) do |(name, runtime), runtimes| runtimes[name] = runtime.to_f.round(2) if runtime end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
logstasher-2.1.5 | lib/logstasher/action_view/log_subscriber.rb |
logstasher-2.1.3 | lib/logstasher/action_view/log_subscriber.rb |
logstasher-2.1.2 | lib/logstasher/action_view/log_subscriber.rb |