Class: D13n::Metric::AppStateMetric

Inherits:
Base
  • Object
show all
Defined in:
lib/d13n/metric/metrics/app_state_metric.rb

Defined Under Namespace

Modules: ExceptionProcessor, GemProcessor, Namespace

Constant Summary collapse

PROCESSOR =
{
  'gem' => GemProcessor,
  'exception' => ExceptionProcessor
}

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#process

Constructor Details

#initialize(collector, opts) ⇒ AppStateMetric

Returns a new instance of AppStateMetric.



89
90
91
92
93
# File 'lib/d13n/metric/metrics/app_state_metric.rb', line 89

def initialize(collector, opts)
  @collector = collector
  @opts = opts
  @type = @opts[:type]
end

Class Method Details

.check_type(type) ⇒ Object



78
79
80
# File 'lib/d13n/metric/metrics/app_state_metric.rb', line 78

def self.check_type(type)
  raise InstrumentNameError.new "Wrong request process type #{type}!" unless PROCESSOR.has_key?(type)
end

.instance(collector, opts) ⇒ Object



82
83
84
85
86
87
# File 'lib/d13n/metric/metrics/app_state_metric.rb', line 82

def self.instance(collector, opts)
  type = opts[:type]
  check_type(type)
  @instance = new(collector, opts)
  @instance.extend PROCESSOR[type]
end

Instance Method Details

#metric_name(type) ⇒ Object



95
96
97
# File 'lib/d13n/metric/metrics/app_state_metric.rb', line 95

def metric_name(type)
  "#{prefix}.#{type}"
end

#prefixObject



99
100
101
# File 'lib/d13n/metric/metrics/app_state_metric.rb', line 99

def prefix
  "app.state.#{@type}"
end