Class: ATSD::MetricsService
- Inherits:
-
BaseService
- Object
- BaseService
- ATSD::MetricsService
- Defined in:
- lib/atsd/services/metrics_service.rb
Instance Method Summary collapse
-
#create_or_replace(metric) ⇒ self
Create a metric with specified properties and tags or replace an existing metric.
-
#delete(metric) ⇒ self
Delete the metric.
-
#get(metric) ⇒ Array<Metric>
Displays metric properties and its tags.
-
#list(parameters = {}) ⇒ Array<Metric>
Metrics list.
-
#series(metric, params = {}) ⇒ Array<Series>
Returns a list of series for the metric.
-
#update(metric) ⇒ self
Update specified properties and tags for the given metric.
Methods inherited from BaseService
Constructor Details
This class inherits a constructor from ATSD::BaseService
Instance Method Details
#create_or_replace(metric) ⇒ self
If only a subset of fields is provided for an existing metric, the remaining properties and tags will be deleted.
Create a metric with specified properties and tags or replace an existing metric. This method creates a new metric or replaces an existing metric.
47 48 49 50 51 52 |
# File 'lib/atsd/services/metrics_service.rb', line 47 def create_or_replace(metric) metric = Metric.new(name: metric) if metric.is_a? String metric = Metric.new(metric) if metric.is_a? Hash @client.metrics_create_or_replace(metric.name, metric.to_request_hash) self end |
#delete(metric) ⇒ self
Delete the metric. Data collected for the metric will be removed asynchronously in the background.
74 75 76 77 |
# File 'lib/atsd/services/metrics_service.rb', line 74 def delete(metric) @client.metrics_delete(name_for_metric(metric)) self end |
#get(metric) ⇒ Array<Metric>
Displays metric properties and its tags.
33 34 35 |
# File 'lib/atsd/services/metrics_service.rb', line 33 def get(metric) Metric.new(@client.metrics_get(name_for_metric metric)) end |
#list(parameters = {}) ⇒ Array<Metric>
Metrics list.
21 22 23 24 25 26 |
# File 'lib/atsd/services/metrics_service.rb', line 21 def list(parameters = {}) parameters = parameters.camelize_keys @client.metrics_list(parameters).map do |json| Metric.new json end end |
#series(metric, params = {}) ⇒ Array<Series>
Returns a list of series for the metric. Each series is identified with metric name, entity name and optional series tags
86 87 88 89 |
# File 'lib/atsd/services/metrics_service.rb', line 86 def series(metric, params = {}) result = @client.metrics_series(name_for_metric(metric), params) result.map { |json| Series.new json } end |
#update(metric) ⇒ self
Properties and tags that are not specified are left unchanged.
Update specified properties and tags for the given metric. This method updates specified properties and tags for an existing metric.
62 63 64 65 66 |
# File 'lib/atsd/services/metrics_service.rb', line 62 def update(metric) metric = Metric.new(metric) if metric.is_a? Hash @client.metrics_update(metric.name, metric.to_request_hash) self end |