Class: ExceptionDog::AgentNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/exception_dog/agent_notifier.rb

Constant Summary collapse

OPTS_WHITELIST =
[:priority, :tags, :aggregation_key, :source_type_name, :alert_type]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ AgentNotifier



14
15
16
17
# File 'lib/exception_dog/agent_notifier.rb', line 14

def initialize(configuration)
  @configuration = configuration
  @logger = configuration.logger
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



9
10
11
# File 'lib/exception_dog/agent_notifier.rb', line 9

def configuration
  @configuration
end

#loggerObject (readonly)

Returns the value of attribute logger.



10
11
12
# File 'lib/exception_dog/agent_notifier.rb', line 10

def logger
  @logger
end

Instance Method Details

#errorsObject



25
26
27
28
29
# File 'lib/exception_dog/agent_notifier.rb', line 25

def errors
  @errors  = []
  @errors << "Invalid host setup" unless configuration.agent_port && configuration.agent_host
  @errors
end

#notify(title, text, opts) ⇒ Object



19
20
21
22
23
# File 'lib/exception_dog/agent_notifier.rb', line 19

def notify(title, text, opts)
  logger.info "ExceptionDog::send_to_agent"
  @@socket ||= Datadog::Statsd.new(configuration.agent_host, configuration.agent_port, logger: configuration.logger)
  response = @@socket.event(title, text, opts)
end