diff --git a/app/models/metric/capture.rb b/app/models/metric/capture.rb index ec7998ebcc3..a6483be10b4 100644 --- a/app/models/metric/capture.rb +++ b/app/models/metric/capture.rb @@ -8,6 +8,12 @@ module Metric::Capture REALTIME_PRIORITY = HOURLY_PRIORITY = DAILY_PRIORITY = MiqQueue::NORMAL_PRIORITY HISTORICAL_PRIORITY = MiqQueue::LOW_PRIORITY + # @param [String[ capture interval + # @return [Integer] MiqQueue priority level for this message + def self.interval_priority(interval) + interval == "historical" ? MiqQueue::LOW_PRIORITY : MiqQueue::NORMAL_PRIORITY + end + def self.capture_cols @capture_cols ||= Metric.columns_hash.collect { |c, h| c.to_sym if h.type == :float && c[0, 7] != "derived" }.compact end @@ -193,6 +199,8 @@ def self.calc_target_options(zone, targets_by_rollup_parent) end private_class_method :calc_target_options + # @param targets [Array] list of the targets for capture (from `capture_ems_targets`) + # @param target_options [ Hash{Object => Hash{Symbol => Object}}] list of options indexed by target def self.queue_captures(targets, target_options) # Queue the captures for each target use_historical = historical_days != 0 diff --git a/app/models/metric/ci_mixin/capture.rb b/app/models/metric/ci_mixin/capture.rb index cc33573138e..b14494c13e4 100644 --- a/app/models/metric/ci_mixin/capture.rb +++ b/app/models/metric/ci_mixin/capture.rb @@ -30,7 +30,7 @@ def split_capture_intervals(interval_name, start_time, end_time, threshold = 1.d def perf_capture_queue(interval_name, options = {}) start_time = options[:start_time]&.utc end_time = options[:end_time]&.utc - priority = options[:priority] || Metric::Capture.const_get("#{interval_name.upcase}_PRIORITY") + priority = options[:priority] || Metric::Capture.interval_priority(interval_name) task_id = options[:task_id] zone = options[:zone] || my_zone zone = zone.name if zone.respond_to?(:name) diff --git a/app/models/metric/ci_mixin/rollup.rb b/app/models/metric/ci_mixin/rollup.rb index 6b829e3ddb4..b5e2fa846aa 100644 --- a/app/models/metric/ci_mixin/rollup.rb +++ b/app/models/metric/ci_mixin/rollup.rb @@ -63,7 +63,7 @@ def perf_rollup_queue(time, interval_name, time_profile = nil) :role => 'ems_metrics_processor', :queue_name => 'ems_metrics_processor', :deliver_on => deliver_on, - :priority => Metric::Capture.const_get("#{interval_name.upcase}_PRIORITY") + :priority => Metric::Capture.interval_priority(interval_name) ) do |msg| _log.debug("Skipping queueing [#{interval_name}] rollup of #{self.class.name} name: [#{name}], id: [#{id}] for time: [#{time}], since it is already queued") unless msg.nil? end