Skip to content

Commit

Permalink
in_monitor_agent: rescue NoMethodError
Browse files Browse the repository at this point in the history
  • Loading branch information
shuji-koike committed Jan 4, 2017
1 parent b99df50 commit 919ebb2
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/fluent/plugin/in_monitor_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ def process(req, res)
end
end

def initialize
super

@first_warn = false
end

def start
super

Expand Down Expand Up @@ -259,8 +265,8 @@ def shutdown

MONITOR_INFO = {
'output_plugin' => ->(){ is_a?(::Fluent::Plugin::Output) },
'buffer_queue_length' => ->(){ throw(:skip) unless instance_variable_defined?(:@buffer); @buffer.queue.size },
'buffer_total_queued_size' => ->(){ throw(:skip) unless instance_variable_defined?(:@buffer); @buffer.stage_size },
'buffer_queue_length' => ->(){ throw(:skip) unless instance_variable_defined?(:@buffer) && !@buffer.nil?; @buffer.queue.size },
'buffer_total_queued_size' => ->(){ throw(:skip) unless instance_variable_defined?(:@buffer) && !@buffer.nil?; @buffer.stage_size },
'retry_count' => ->(){ instance_variable_defined?(:@num_errors) ? @num_errors : nil },
}

Expand Down Expand Up @@ -346,6 +352,12 @@ def get_monitor_info(pe, opts={})
catch(:skip) do
obj[key] = pe.instance_exec(&code)
end
rescue NoMethodError => e
unless @first_warn
log.error "NoMethodError in monitoring plugins", key: key, plugin: pe.class, error: e
log.error_backtrace
@first_warn = true
end
rescue => e
log.warn "unexpected error in monitoring plugins", key: key, plugin: pe.class, error: e
end
Expand Down

0 comments on commit 919ebb2

Please sign in to comment.