Module: FFWD::Plugin::Riemann::Output

Included in:
OutputTCP, OutputUDP
Defined in:
lib/ffwd/plugin/riemann/output.rb

Instance Method Summary collapse

Instance Method Details

#output_encode(message) ⇒ Object



75
76
77
# File 'lib/ffwd/plugin/riemann/output.rb', line 75

def output_encode message
  raise "#output_encode: not implemented"
end

#output_failed_event(event, error) ⇒ Object



79
# File 'lib/ffwd/plugin/riemann/output.rb', line 79

def output_failed_event event, error; end

#output_failed_metric(metric, error) ⇒ Object



80
# File 'lib/ffwd/plugin/riemann/output.rb', line 80

def output_failed_metric metric, error; end

#receive_data(data) ⇒ Object



69
70
71
72
73
# File 'lib/ffwd/plugin/riemann/output.rb', line 69

def receive_data data
  message = read_message data
  return if message.ok
  @bad_acks = (@bad_acks || 0) + 1
end

#send_all(events, metrics) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ffwd/plugin/riemann/output.rb', line 20

def send_all events, metrics
  all_events = []

  events.each do |event|
    begin
      all_events << make_event(event)
    rescue => error
      output_failed_event event, error
    end
  end

  metrics.each do |metric|
    begin
      all_events << make_metric(metric)
    rescue => error
      output_failed_metric metric, error
    end
  end

  return if all_events.empty?

  m = make_message :events => all_events
  send_data output_encode(m)
end

#send_event(event) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/ffwd/plugin/riemann/output.rb', line 45

def send_event event
  begin
    e = make_event event
  rescue => error
    output_failed_event event, error
    return
  end

  m = make_message :events => [e]
  send_data output_encode(m)
end

#send_metric(metric) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/ffwd/plugin/riemann/output.rb', line 57

def send_metric metric
  begin
    e = make_metric metric
  rescue => error
    output_failed_metric event, error
    return
  end

  m = make_message :events => [e]
  send_data output_encode(m)
end