Class: Promenade::Pitchfork::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/promenade/pitchfork/stats.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStats

Returns a new instance of Stats.



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/promenade/pitchfork/stats.rb', line 22

def initialize
  return unless defined?(::Pitchfork) && defined?(::Pitchfork::Info)

  @workers_count = ::Pitchfork::Info.workers_count
  @live_workers_count = ::Pitchfork::Info.live_workers_count

  raindrops_stats = Raindrops::Stats.new

  @active_workers = raindrops_stats.active_workers || 0
  @queued_requests = raindrops_stats.queued_requests || 0
end

Class Method Details

.instrumentObject



41
42
43
# File 'lib/promenade/pitchfork/stats.rb', line 41

def self.instrument
  new.instrument
end

Instance Method Details

#instrumentObject



34
35
36
37
38
39
# File 'lib/promenade/pitchfork/stats.rb', line 34

def instrument
  Promenade.metric(:pitchfork_workers_count).set({}, workers_count)
  Promenade.metric(:pitchfork_live_workers_count).set({}, live_workers_count)
  Promenade.metric(:pitchfork_capacity).set({}, capacity)
  Promenade.metric(:pitchfork_busy_percent).set({}, busy_percent)
end