Sha256: 9b2586b6003242e943314d9bb2ae5acff550efcf42125cb06d67f41a5efbf1ae

Contents?: true

Size: 882 Bytes

Versions: 4

Compression:

Stored size: 882 Bytes

Contents

MetricFu.metrics_require   { 'hotspots/hotspot_analyzer' }
module MetricFu

  class HotspotsGenerator < Generator

    def self.metric
      :hotspots
    end

    def initialize(options={})
      MetricFu::Metric.enabled_metrics.each do |metric|
        require_hotspot(metric.name)
      end
      super
    end

    def emit
      # no-op
    end

    def analyze
      analyzer = MetricFu::HotspotAnalyzer.new(MetricFu.result.result_hash)
      @hotspots = analyzer.hotspots
    end

    def to_h
      result = {:hotspots => {}}
      @hotspots.each do |granularity, hotspots|
        result[:hotspots][granularity.to_s] = hotspots.map(&:to_hash)
      end
      result
    end

    private

    def require_hotspot(metric_name)
      require "metric_fu/metrics/#{metric_name}/hotspot"
    rescue LoadError
      mf_debug "*** No hotspot for #{metric_name}"
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
metric_fu-4.11.3 lib/metric_fu/metrics/hotspots/generator.rb
metric_fu-4.11.2 lib/metric_fu/metrics/hotspots/generator.rb
metric_fu-4.11.1 lib/metric_fu/metrics/hotspots/generator.rb
metric_fu-4.11.0 lib/metric_fu/metrics/hotspots/generator.rb