<commit_before>module Metric::CiMixin::Capture
  def perf_capture_object
    self.class.parent::MetricsCapture.new(self)
  end

  delegate :perf_collect_metrics, :to => :perf_capture_object

  def queue_name_for_metrics_collection
    ems = if self.kind_of?(ExtManagementSystem)
            self
          elsif self.kind_of?(Storage)
            ext_management_systems.first
          elsif self.respond_to?(:ext_management_system)
            ext_management_system
          else
            raise _("Unsupported type %{name} (id: %{number})") % {:name => self.class.name, :number => id}
          end

    ems.metrics_collector_queue_name
  end

  def perf_capture_queue(interval_name, options = {})
    start_time = options[:start_time]
    end_time   = options[:end_time]
    force      = options[:force] # Force capture to run regardless of last capture time
    priority   = options[:priority] || Metric::Capture.const_get("#{interval_name.upcase}_PRIORITY")
    task_id    = options[:task_id]
    zone       = options[:zone] || my_zone
    zone = zone.name if zone.respond_to?(:name)
    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?

    start_time = start_time.utc unless start_time.nil?
    end_time = end_time.utc unless end_time.nil?

    log_target = "#{self.class.name} name: [#{name}], id: [#{id}]"

    if interval_name != 'historical' && start_time.nil? && !force && !self.perf_capture_now?
      _log.debug "Skipping capture of #{log_target} - Performance last captured on [#{last_perf_capture_on}] is within threshold"
      return
    end

    # Determine what items we should be queuing up<commit_msg>perf_capture_timer missing ems, give better error<commit_after>module Metric::CiMixin::Capture
  def perf_capture_object
    self.class.parent::MetricsCapture.new(self)
  end

  delegate :perf_collect_metrics, :to => :perf_capture_object

  def queue_name_for_metrics_collection
    ems = if self.kind_of?(ExtManagementSystem)
            self
          elsif self.kind_of?(Storage)
            ext_management_systems.first
          elsif self.respond_to?(:ext_management_system)
            ext_management_system
          end
    raise _("Unsupported type %{name} (id: %{number})") % {:name => self.class.name, :number => id} if ems.nil?
    ems.metrics_collector_queue_name
  end

  def perf_capture_queue(interval_name, options = {})
    start_time = options[:start_time]
    end_time   = options[:end_time]
    force      = options[:force] # Force capture to run regardless of last capture time
    priority   = options[:priority] || Metric::Capture.const_get("#{interval_name.upcase}_PRIORITY")
    task_id    = options[:task_id]
    zone       = options[:zone] || my_zone
    zone = zone.name if zone.respond_to?(:name)
    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?

    start_time = start_time.utc unless start_time.nil?
    end_time = end_time.utc unless end_time.nil?

    log_target = "#{self.class.name} name: [#{name}], id: [#{id}]"

    if interval_name != 'historical' && start_time.nil? && !force && !self.perf_capture_now?
      _log.debug "Skipping capture of #{log_target} - Performance last captured on [#{last_perf_capture_on}] is within threshold"
      return
    end

    # Determine what items we should be queuing up
{'fraction_non_alphanumeric': 0.10848287112561175, 'fraction_numerical': 0.0, 'mean_word_length': 3.759379042690815, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5814968', 'n_tokens_mistral': 1148, 'n_tokens_neox': 1126, 'n_words': 265}