Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/metriks/reporter/librato_metrics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ def initialize(email, token, options = {})
@registry = options[:registry] || Metriks::Registry.default
@interval = options[:interval] || 60
@on_error = options[:on_error] || proc { |ex| }

if options[:only] and options[:except]
raise 'Can only specify one of :only or :except'
end
@only = options[:only] || []
@except = options[:except] || []
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defaulting these to an empty array is going to cause the if's later on to always evaluate to true.

I think this may be worth a test case to not break things.

end

def start
Expand Down Expand Up @@ -121,6 +127,15 @@ def prepare_metric(base_name, metric, keys, snapshot_keys = [])
base_name = "#{@prefix}.#{base_name}"
end

if @only
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the defaulting above, this is going to need to be if @only && [email protected]? — same with the @except one.

keys = keys & @only
snapshot_keys = snapshot_keys & @only
end
if @except
keys = keys - @except
snapshot_keys = snapshot_keys - @except
end

keys.flatten.each do |key|
name = key.to_s.gsub(/^get_/, '')
value = metric.send(key)
Expand Down