Class: ExceptionNotifier::TdNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/exception_notifier/td_notifier.rb

Constant Summary collapse

BACKTRACE_LIMIT_DEFAULT =
10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ TdNotifier

Returns a new instance of TdNotifier.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/exception_notifier/td_notifier.rb', line 9

def initialize(options)
  @table_name = options.delete(:table_name)
  raise "Please set table_name. options: #{options.inspect}" unless @table_name

  @backtrace_limit = options.delete(:backtrace_limit) || BACKTRACE_LIMIT_DEFAULT
  @custom_param_proc = options.delete(:custom_param_proc)

  unless defined? TreasureData::Logger::Agent::Rails
    @database = options.delete(:database)
    raise "Please set database. options: #{options.inspect}" unless @database
    TreasureData::Logger.open(@database, options)
  end
end

Instance Attribute Details

#backtrace_limitObject (readonly)

Returns the value of attribute backtrace_limit.



22
23
24
# File 'lib/exception_notifier/td_notifier.rb', line 22

def backtrace_limit
  @backtrace_limit
end

#custom_param_procObject (readonly)

Returns the value of attribute custom_param_proc.



22
23
24
# File 'lib/exception_notifier/td_notifier.rb', line 22

def custom_param_proc
  @custom_param_proc
end

#databaseObject (readonly)

Returns the value of attribute database.



22
23
24
# File 'lib/exception_notifier/td_notifier.rb', line 22

def database
  @database
end

#table_nameObject (readonly)

Returns the value of attribute table_name.



22
23
24
# File 'lib/exception_notifier/td_notifier.rb', line 22

def table_name
  @table_name
end

Instance Method Details

#call(exception, options = {}) ⇒ Object



24
25
26
# File 'lib/exception_notifier/td_notifier.rb', line 24

def call(exception, options = {})
  TD.event.post(@table_name, exception_to_td_data(exception, options))
end