class LogStasher::ActionView::LogSubscriber
Public Instance Methods
logger()
click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 16 def logger LogStasher.logger end
render_template(event)
click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 10 def render_template(event) logstash_event(event) end
Also aliased as: render_partial, render_collection
Private Instance Methods
event_data(event)
click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 49 def event_data(event) { name: event.name, transaction_id: event.transaction_id, } end
extract_data(data)
click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 37 def extract_data(data) { identifier: from_rails_root(data[:identifier]) } end
logstash_event(event)
click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 22 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
request_context()
click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 41 def request_context LogStasher.request_context end
runtimes(event)
click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 56 def runtimes(event) { duration: event.duration, }.inject({}) do |runtimes, (name, runtime)| runtimes[name] = runtime.to_f.round(2) if runtime runtimes end end
store()
click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 45 def store LogStasher.store end