Class: PikaQue::Metrics::LogMetric

Inherits:
Object
  • Object
show all
Defined in:
lib/pika_que/metrics/log_metric.rb

Constant Summary collapse

COUNTERS =
Concurrent::Map.new

Instance Method Summary collapse

Instance Method Details

#increment(metric, delta = 1) ⇒ Object



9
10
11
12
13
# File 'lib/pika_que/metrics/log_metric.rb', line 9

def increment(metric, delta = 1)
  COUNTERS[metric] = 0 unless COUNTERS[metric]
  COUNTERS[metric] = COUNTERS[metric] + delta
  PikaQue.logger.info("COUNT: #{metric} #{COUNTERS[metric]}")
end

#measure(metric, &block) ⇒ Object



15
16
17
18
19
# File 'lib/pika_que/metrics/log_metric.rb', line 15

def measure(metric, &block)
  start = Time.now
  block.call
  PikaQue.logger.info("TIME: #{metric} #{Time.now - start}")
end