Class: Stackify::Metrics::MetricsClient
- Defined in:
- lib/stackify/metrics/metrics_client.rb
Instance Attribute Summary collapse
-
#metrics_queue ⇒ Object
readonly
Returns the value of attribute metrics_queue.
Instance Method Summary collapse
- #get_latest(category, metric_name) ⇒ Object
- #get_latest_all_metrics ⇒ Object
-
#initialize ⇒ MetricsClient
constructor
A new instance of MetricsClient.
- #queue_metric(metric) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ MetricsClient
Returns a new instance of MetricsClient.
6 7 8 9 10 11 12 13 |
# File 'lib/stackify/metrics/metrics_client.rb', line 6 def initialize @metrics_queue = MetricsQueue.new @last_aggregates = {} @metric_settings = {} @aggregate_metrics = {} @monitor_ids = {} @metrics_sender = MetricsSender.new end |
Instance Attribute Details
#metrics_queue ⇒ Object (readonly)
Returns the value of attribute metrics_queue.
4 5 6 |
# File 'lib/stackify/metrics/metrics_client.rb', line 4 def metrics_queue @metrics_queue end |
Instance Method Details
#get_latest(category, metric_name) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/stackify/metrics/metrics_client.rb', line 26 def get_latest category, metric_name Stackify::Utils. Stackify::MODES[:metrics] do l = @last_aggregates.select { |_key, aggr| aggr.category.eql?(category) && aggr.name.eql?(metric_name) } LatestAggregate.new l.values.first end end |
#get_latest_all_metrics ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/stackify/metrics/metrics_client.rb', line 33 def get_latest_all_metrics Stackify::Utils. Stackify::MODES[:metrics] do all_latest = [] @last_aggregates.each_pair do |_key, aggr| all_latest << Stackify::Metrics::LatestAggregate.new(aggr) end all_latest end end |
#queue_metric(metric) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/stackify/metrics/metrics_client.rb', line 43 def queue_metric metric if Stackify.working? if Stackify::Utils.is_mode_on? Stackify::MODES[:metrics] @metrics_queue.add_metric metric else Stackify.internal_log :warn, '[MetricClient]: Adding of metrics is impossible because they are disabled by configuration' end else Stackify.internal_log :warn, '[MetricClient]: Adding of metrics is impossible - Stackify is terminating or terminated work.' end end |
#start ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/stackify/metrics/metrics_client.rb', line 15 def start if Stackify::Utils.is_mode_on? Stackify::MODES[:metrics] worker = Stackify::Worker.new 'Metrics client - processing of metrics' Stackify.internal_log :debug, 'Metrics client: processing of metrics is started' task = submit_metrics_task worker.async_perform Stackify::ScheduleDelay.new, task else Stackify.internal_log :warn, '[MetricClient]: Processing of metrics is disabled at configuration!' end end |