Class: Appsignal::Minutely
Defined Under Namespace
Classes: ProbeCollection
Class Method Summary collapse
-
.probes ⇒ ProbeCollection
Returns list of probes.
- .start ⇒ Object private
- .stop ⇒ Object private
- .wait_time ⇒ Object private
Class Method Details
.probes ⇒ ProbeCollection
Returns list of probes.
118 119 120 |
# File 'lib/appsignal/minutely.rb', line 118 def probes @probes ||= ProbeCollection.new end |
.start ⇒ Object
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.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/appsignal/minutely.rb', line 123 def start stop @thread = Thread.new do # Advise multi-threaded app servers to ignore this thread # for the purposes of fork safety warnings if Thread.current.respond_to?(:thread_variable_set) Thread.current.thread_variable_set(:fork_safe, true) end sleep initial_wait_time initialize_probes loop do logger = Appsignal.internal_logger logger.debug("Gathering minutely metrics with #{probe_instances.count} probes") probe_instances.each do |name, probe| logger.debug("Gathering minutely metrics with '#{name}' probe") probe.call rescue => ex logger.error "Error in minutely probe '#{name}': #{ex}" logger.debug ex.backtrace.join("\n") end sleep wait_time end end end |
.stop ⇒ Object
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.
150 151 152 153 |
# File 'lib/appsignal/minutely.rb', line 150 def stop defined?(@thread) && @thread.kill probe_instances.clear end |
.wait_time ⇒ Object
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.
156 157 158 |
# File 'lib/appsignal/minutely.rb', line 156 def wait_time 60 - Time.now.sec end |