Sha256: 0f3fa446eeafee0d7cbb6abd3bab980fdc7dd64f7d28f770fd118263a49d7bdf

Contents?: true

Size: 1.32 KB

Versions: 18

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module Appsignal
  module CheckIn
    class << self
      # Track cron check-ins.
      #
      # Track the execution of certain processes by sending a cron check-in.
      #
      # To track the duration of a piece of code, pass a block to {.cron}
      # to report both when the process starts, and when it finishes.
      #
      # If an exception is raised within the block, the finish event will not
      # be reported, triggering a notification about the missing cron check-in.
      # The exception will bubble outside of the cron check-in block.
      #
      # @example Send a cron check-in
      #   Appsignal::CheckIn.cron("send_invoices")
      #
      # @example Send a cron check-in with duration
      #   Appsignal::CheckIn.cron("send_invoices") do
      #     # your code
      #   end
      #
      # @param name [String] name of the cron check-in to report.
      # @yield the block to monitor.
      # @return [void]
      # @since 3.13.0
      # @see https://docs.appsignal.com/check-ins/cron
      def cron(identifier)
        cron = Appsignal::CheckIn::Cron.new(:identifier => identifier)
        output = nil

        if block_given?
          cron.start
          output = yield
        end

        cron.finish
        output
      end
    end
  end
end

require "appsignal/check_in/cron"

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
appsignal-4.0.3-java lib/appsignal/check_in.rb
appsignal-4.0.3 lib/appsignal/check_in.rb
appsignal-4.0.2-java lib/appsignal/check_in.rb
appsignal-4.0.2 lib/appsignal/check_in.rb
appsignal-4.0.1-java lib/appsignal/check_in.rb
appsignal-4.0.1 lib/appsignal/check_in.rb
appsignal-4.0.0-java lib/appsignal/check_in.rb
appsignal-4.0.0 lib/appsignal/check_in.rb
appsignal-3.13.1-java lib/appsignal/check_in.rb
appsignal-3.13.1 lib/appsignal/check_in.rb
appsignal-3.13.1.alpha.1-java lib/appsignal/check_in.rb
appsignal-3.13.1.alpha.1 lib/appsignal/check_in.rb
appsignal-4.0.0.beta.2-java lib/appsignal/check_in.rb
appsignal-4.0.0.beta.2 lib/appsignal/check_in.rb
appsignal-4.0.0.beta.1-java lib/appsignal/check_in.rb
appsignal-4.0.0.beta.1 lib/appsignal/check_in.rb
appsignal-3.13.0-java lib/appsignal/check_in.rb
appsignal-3.13.0 lib/appsignal/check_in.rb