Class: MetricFu::HotspotsGenerator

Inherits:
Generator
  • Object
show all
Defined in:
lib/metric_fu/metrics/hotspots/generator.rb

Instance Attribute Summary

Attributes inherited from Generator

#options, #result, #template

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Generator

#generate_result, generators, get_generator, #metric, #metric_config, metric_directory, #metric_directory, not_implemented, #remove_excluded_files, #round_to_tenths, #run!, #silence_streams

Constructor Details

#initialize(options = {}) ⇒ HotspotsGenerator

Returns a new instance of HotspotsGenerator.



8
9
10
11
12
13
# File 'lib/metric_fu/metrics/hotspots/generator.rb', line 8

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

Class Method Details

.metricObject



4
5
6
# File 'lib/metric_fu/metrics/hotspots/generator.rb', line 4

def self.metric
  :hotspots
end

Instance Method Details

#analyzeObject



19
20
21
22
# File 'lib/metric_fu/metrics/hotspots/generator.rb', line 19

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

#emitObject



15
16
17
# File 'lib/metric_fu/metrics/hotspots/generator.rb', line 15

def emit
  # no-op
end

#to_hObject



24
25
26
27
28
29
30
# File 'lib/metric_fu/metrics/hotspots/generator.rb', line 24

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