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

Open
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants

Can specific :only or :except when initializing the reporter, e.g.

Metriks::Reporter::LibratoMetrics.new(
  'email',
  'key',
  {
    prefix: 'example',
    only: [
      :count,
      :mean,
      :one_minute_rate
    ]
  }
).start
Owner

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

lib/metriks/reporter/librato_metrics.rb
@@ -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

eric Apr 25, 2012

Owner

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

lib/metriks/reporter/librato_metrics.rb
@@ -121,6 +127,15 @@ def prepare_metric(base_name, metric, keys, snapshot_keys = [])
base_name = "#{@prefix}.#{base_name}"
end
+ if @only
@eric

eric Jul 3, 2012

Owner

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