Sha256: 3ed5a789e5d91e63632087cad9a73479545449b0d7702656ce426451bc9051dd

Contents?: true

Size: 897 Bytes

Versions: 8

Compression:

Stored size: 897 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}/#{metric_name}_hotspot"
    rescue LoadError
      mf_debug "*** No hotspot for #{metric_name}"
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
metric_fu-4.10.0 lib/metric_fu/metrics/hotspots/hotspots.rb
metric_fu-4.9.0 lib/metric_fu/metrics/hotspots/hotspots.rb
metric_fu-4.8.0 lib/metric_fu/metrics/hotspots/hotspots.rb
metric_fu-4.7.4 lib/metric_fu/metrics/hotspots/hotspots.rb
metric_fu-4.7.3 lib/metric_fu/metrics/hotspots/hotspots.rb
metric_fu-4.7.2 lib/metric_fu/metrics/hotspots/hotspots.rb
metric_fu-4.7.1 lib/metric_fu/metrics/hotspots/hotspots.rb
metric_fu-4.7.0 lib/metric_fu/metrics/hotspots/hotspots.rb