librato / librato-metrics

Ruby wrapper to make it easy to interact with Librato's API.
https://librato.com
Other
108 stars 51 forks source link

Multidimensional check is not always correct #141

Open mheffner opened 6 years ago

mheffner commented 6 years ago

Take the following code:

measure_time = (Time.now.tv_sec / 300) * 300

Librato::Metrics.authenticate 'token', opts[:appoptics_token]
queue = Librato::Metrics::Queue.new(:prefix => "foo",
                                    :time => measure_time)
  queue.add "mymetric": {
    value: 1.34,
    tags: {"foo" => "bar"}
  }

This leads to a payload that includes a top-level :measure_time => <> key which is not valid for multidimensional (and fails to submit). This appears to be because we use a has_tags? check on the Queue, however the queue could legitimately not have any tags because they are added on the individual measurements. Therefore, it seems like the check must be performed on the individual measurements and not on the queue itself.