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.
-
#entity_and_tags(metric, entity = nil) ⇒ Array<Entity>
Returns a list of unique series tags for the metric.
-
#get(metric) ⇒ Array<Metric>
Displays metric properties and its tags.
-
#list(parameters = {}) ⇒ Array<Metric>
Metrics list.
-
#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 |
#entity_and_tags(metric, entity = nil) ⇒ Array<Entity>
Returns a list of unique series tags for the metric. The list is based on data stored on disk for the last 24 hours.
86 87 88 89 90 91 92 |
# File 'lib/atsd/services/metrics_service.rb', line 86 def (metric, entity = nil) metric = name_for_metric(metric) params = {} params[:entity] = name_for_entity(entity) if entity result = @client.(metric, params) result.map { |json| Entity.new json } 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 |
#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 |