Sha256: 80a2b105e589578e0424e058f52fd20fc55d276388871990f850c4dd8bb8b1b7

Contents?: true

Size: 898 Bytes

Versions: 15

Compression:

Stored size: 898 Bytes

Contents

module Appsignal
  # @api private
  class Minutely
    class << self
      # List of probes. Probes can be lamdba's or objects that
      # respond to call.
      def probes
        @@probes ||= []
      end

      def start
        Thread.new do
          begin
            loop do
              Appsignal.logger.debug("Gathering minutely metrics with #{probes.count} probe(s)")
              probes.each(&:call)
              sleep(wait_time)
            end
          rescue Exception => ex
            Appsignal.logger.error("Error in minutely thread: #{ex}")
          end
        end
      end

      def wait_time
        60 - Time.now.sec
      end

      def add_gc_probe
        probes << GCProbe.new
      end
    end

    class GCProbe
      def call
        GC.stat.each do |key, value|
          Appsignal.set_process_gauge("gc.#{key}", value)
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
appsignal-2.3.7 lib/appsignal/minutely.rb
appsignal-2.3.6 lib/appsignal/minutely.rb
appsignal-2.3.6.beta.1 lib/appsignal/minutely.rb
appsignal-2.3.4 lib/appsignal/minutely.rb
appsignal-2.3.3 lib/appsignal/minutely.rb
appsignal-2.3.3.beta.1 lib/appsignal/minutely.rb
appsignal-2.3.2 lib/appsignal/minutely.rb
appsignal-2.3.1 lib/appsignal/minutely.rb
appsignal-2.3.0 lib/appsignal/minutely.rb
appsignal-2.3.0.beta.3 lib/appsignal/minutely.rb
appsignal-2.3.0.beta.2 lib/appsignal/minutely.rb
appsignal-2.3.0.beta.1 lib/appsignal/minutely.rb
appsignal-2.2.1 lib/appsignal/minutely.rb
appsignal-2.2.0 lib/appsignal/minutely.rb
appsignal-2.2.0.beta.1 lib/appsignal/minutely.rb