Sha256: 42ebf7d353ecc5b25251c62dfe35bb1f7d7ca7dc69c284f7456fdbfcff635825
Contents?: true
Size: 1.48 KB
Versions: 2
Compression:
Stored size: 1.48 KB
Contents
require 'delegate' module Appsignal class TransactionFormatter < SimpleDelegator def initialize(transaction) super(transaction) end def hash @hash ||= default_hash end def to_hash merge_process_action_event_with_log_entry! if process_action_event if exception? add_exception_to_hash! add_tags_to_hash! end add_events_to_hash! if slow_request? hash end protected def default_hash { :request_id => request_id, :log_entry => { :path => fullpath, :kind => 'http_request', :time => time, :environment => sanitized_environment, :session_data => sanitized_session_data }, :failed => exception? } end def merge_process_action_event_with_log_entry! hash[:log_entry].merge!(process_action_event.to_appsignal_hash) hash[:log_entry].tap do |o| o.merge!(o.delete(:payload)) o.delete(:action) o.delete(:controller) o.delete(:name) o[:action] = action end end def add_tags_to_hash! hash[:log_entry][:tags] = tags end def add_exception_to_hash! hash[:exception] = { :exception => exception.class.name, :message => exception.message, :backtrace => Rails.backtrace_cleaner.clean(exception.backtrace, nil) } end def add_events_to_hash! hash[:events] = events.map(&:to_appsignal_hash) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
appsignal-0.6.7 | lib/appsignal/transaction/transaction_formatter.rb |
appsignal-0.6.6 | lib/appsignal/transaction/transaction_formatter.rb |