Skip to content

Commit

Permalink
metrics: move capture date logic to gap call
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrock committed Nov 18, 2019
1 parent 053d9da commit 26368fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 4 additions & 1 deletion app/models/metric/capture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def self.perf_capture_timer(ems_id)
end

def self.perf_capture_gap(start_time, end_time, zone_id = nil, ems_id = nil)
raise ArgumentError, "end_time and start_time must be specified" if start_time.nil? || end_time.nil?
raise _("Start time must be earlier than End time") if start_time > end_time

_log.info("Queueing performance capture for range: [#{start_time} - #{end_time}]...")

emses = if ems_id
Expand All @@ -74,7 +77,7 @@ def self.perf_capture_gap(start_time, end_time, zone_id = nil, ems_id = nil)
end
emses.each do |ems|
targets = Metric::Targets.capture_ems_targets(ems, :exclude_storages => true)
target_options = Hash.new { |_n, _v| {:start_time => start_time, :end_time => end_time, :zone => ems.zone, :interval => 'historical'} }
target_options = Hash.new { |_n, _v| {:start_time => start_time.utc, :end_time => end_time.utc, :zone => ems.zone, :interval => 'historical'} }
queue_captures(targets, target_options)
end

Expand Down
6 changes: 2 additions & 4 deletions app/models/metric/ci_mixin/capture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def ems_for_capture_target
end

def split_capture_intervals(interval_name, start_time, end_time, threshold = 1.day)
raise _("Start time must be earlier than End time") if start_time > end_time
# Create an array of ordered pairs from start_time and end_time so that each ordered pair is contained
# within the threshold. Then, reverse it so the newest ordered pair is first:
# start_time = 2017/01/01 12:00:00, end_time = 2017/01/04 12:00:00
Expand All @@ -32,16 +31,15 @@ def split_capture_intervals(interval_name, start_time, end_time, threshold = 1.d
private :split_capture_intervals

def perf_capture_queue(interval_name, options = {})
start_time = options[:start_time]&.utc
end_time = options[:end_time]&.utc
start_time = options[:start_time]
end_time = options[:end_time]
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)
ems = ems_for_capture_target

raise ArgumentError, "invalid interval_name '#{interval_name}'" unless Metric::Capture::VALID_CAPTURE_INTERVALS.include?(interval_name)
raise ArgumentError, "end_time cannot be specified if start_time is nil" if start_time.nil? && !end_time.nil?
raise ArgumentError, "target does not have an ExtManagementSystem" if ems.nil?

# cb is the task used to group cluster realtime metrics
Expand Down

0 comments on commit 26368fb

Please sign in to comment.