Skip to content

Commit

Permalink
Allow selection of which metrics to send to Librato metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlower committed Apr 18, 2012
1 parent 2b23601 commit 47350ac
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/metriks/reporter/librato_metrics.rb
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] || []
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
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

0 comments on commit 47350ac

Please sign in to comment.