Class: Stackify::Metrics::MetricsSender
- Inherits:
-
HttpClient
- Object
- HttpClient
- Stackify::Metrics::MetricsSender
- Defined in:
- lib/stackify/metrics/metrics_sender.rb
Constant Summary collapse
- SUBMIT_METRIS_URI =
URI("#{Stackify.configuration.base_api_url}/Metrics/SubmitMetricsByID")
- GET_METRIC_INFO_URI =
URI("#{Stackify.configuration.base_api_url}/Metrics/GetMetricInfo")
Constants inherited from HttpClient
Instance Attribute Summary
Attributes inherited from HttpClient
Instance Method Summary collapse
Instance Method Details
#monitor_info(aggr_metric) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/stackify/metrics/metrics_sender.rb', line 6 def monitor_info aggr_metric if Stackify. send_request GET_METRIC_INFO_URI, GetMetricRequest.new(aggr_metric).to_h.to_json else Stackify.log_internal_error "Getting of monitor_info is failed because of authorisation failure" end end |
#upload_metrics(aggr_metrics) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/stackify/metrics/metrics_sender.rb', line 14 def upload_metrics aggr_metrics return true if aggr_metrics.nil? || aggr_metrics.length == 0 if Stackify. records = [] aggr_metrics.each_pair do |_key, metric| records << Stackify::Metrics::MetricForSubmit.new(metric).to_h prms = [metric.category, metric.name, metric.count, metric.value, metric.monitor_id ] Stackify.internal_log :debug, 'Uploading metric: %s: %s count %s, value %s, ID %s' % prms end send_request SUBMIT_METRIS_URI, records.to_json else Stackify.log_internal_error "Uploading of metrics is failed because of authorisation failure" end end |