Allow selection of which metrics to submit from Librato metrics reporter #9

wants to merge 1 commit into


None yet
3 participants

Can specific :only or :except when initializing the reporter, e.g.
    prefix: 'example',
    only: [

eric commented Apr 18, 2012

This is great. It may be a couple days before I get a chance to merge and release this — I'm traveling in Japan at the moment... but this looks useful.

Thanks for the pull request.

@eric eric commented on the diff Apr 25, 2012

@@ -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] || []

eric Apr 25, 2012


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.

This one is going to really come in handy. Thanks guys!

@eric eric commented on the diff Jul 3, 2012

@@ -121,6 +127,15 @@ def prepare_metric(base_name, metric, keys, snapshot_keys = [])
base_name = "#{@prefix}.#{base_name}"
+ if @only

eric Jul 3, 2012


With the defaulting above, this is going to need to be if @only && !@only.empty? — same with the @except one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment