Class: Appsignal::Minutely

Inherits:
Object show all
Defined in:
lib/appsignal/minutely.rb

Defined Under Namespace

Classes: ProbeCollection

Class Method Summary collapse

Class Method Details

.probesProbeCollection

Returns list of probes.

Returns:

See Also:



131
132
133
# File 'lib/appsignal/minutely.rb', line 131

def probes
  @@probes ||= ProbeCollection.new
end

.startObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/appsignal/minutely.rb', line 136

def start
  stop
  initialize_probes
  @@thread = Thread.new do
    sleep initial_wait_time
    loop do
      logger = Appsignal.logger
      logger.debug("Gathering minutely metrics with #{probes.count} probes")
      probe_instances.each do |name, probe|
        begin
          logger.debug("Gathering minutely metrics with '#{name}' probe")
          probe.call
        rescue => ex
          logger.error "Error in minutely probe '#{name}': #{ex}\n"
          logger.debug ex.backtrace.join("\n")
        end
      end
      sleep wait_time
    end
  end
end

.stopObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



159
160
161
162
# File 'lib/appsignal/minutely.rb', line 159

def stop
  defined?(@@thread) && @@thread.kill
  probe_instances.clear
end

.wait_timeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



165
166
167
# File 'lib/appsignal/minutely.rb', line 165

def wait_time
  60 - Time.now.sec
end