Module: Librato::Metrics
- Extended by:
- SingleForwardable
- Defined in:
- lib/librato/metrics.rb,
lib/librato/metrics/queue.rb,
lib/librato/metrics/errors.rb,
lib/librato/metrics/simple.rb,
lib/librato/metrics/version.rb,
lib/librato/metrics/persistence/test.rb,
lib/librato/metrics/persistence/direct.rb
Overview
Metrics provides a simple wrapper for the Metrics web API. Some of the methods Metrics provides will be documented below. Others are delegated to Simple and will be documented there.
Defined Under Namespace
Modules: Persistence Classes: CredentialsMissing, MetricsError, NoMetricsQueued, Queue, Simple
Constant Summary collapse
- TYPES =
[:counter, :gauge]
- VERSION =
"0.1.0"
Class Method Summary collapse
-
.fetch(metric, options = {}) ⇒ Object
Query metric data.
-
.list(options = {}) ⇒ Object
List currently existing metrics.
Class Method Details
.fetch(metric, options = {}) ⇒ Object
Query metric data
A full list of query parameters can be found in the API documentation: http://dev.librato.com/v1/get/gauges/:name
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/librato/metrics.rb', line 53 def self.fetch(metric, ={}) resolution = .delete(:resolution) || 1 count = .delete(:count) query = {} if count query.merge!({:count => count, :resolution => resolution}) end query.merge!() # TODO: look up type when not specified. type = .delete(:type) || 'gauge' response = connection.get(:path => "v1/#{type}s/#{metric}.json", :query => query, :expects => 200) parsed = JSON.parse(response.body) # TODO: pagination support query.empty? ? parsed : parsed["measurements"] end |
.list(options = {}) ⇒ Object
List currently existing metrics
79 80 81 82 83 84 85 86 |
# File 'lib/librato/metrics.rb', line 79 def self.list(={}) query = {} query[:name] = [:name] if [:name] response = connection.get(:path => 'v1/metrics.json', :query => query, :expects => 200) # TODO: pagination support JSON.parse(response.body)["metrics"] end |