Class: Opower::TimeSeries::Query::MetricQuery
- Inherits:
-
Object
- Object
- Opower::TimeSeries::Query::MetricQuery
- Defined in:
- lib/time_series/query.rb
Overview
Wrapper class for each query made against a separate metric.
Instance Method Summary collapse
-
#initialize(metric) ⇒ MetricQuery
constructor
Initializes a wrapper object that represent a single metric that will be queried against in OpenTSDB.
-
#to_s ⇒ String
Builds the query string representation of this MetricQuery object.
Constructor Details
#initialize(metric) ⇒ MetricQuery
Initializes a wrapper object that represent a single metric that will be queried against in OpenTSDB.
91 92 93 94 95 96 97 98 |
# File 'lib/time_series/query.rb', line 91 def initialize(metric) @metric = metric.fetch(:metric) @tags = metric.fetch(:tags, {}) @aggregator = metric.fetch(:aggregator, 'sum') @rate = metric.fetch(:rate, false) initialize_downsample(metric) end |
Instance Method Details
#to_s ⇒ String
Builds the query string representation of this MetricQuery object.
103 104 105 106 107 108 109 |
# File 'lib/time_series/query.rb', line 103 def to_s str = "#{@aggregator}:" str << "#{@period}-#{@function}:" if @downsample str << 'rate:' if @rate str << "#{@metric}{#{}}" str end |