Sha256: 287bef1fccbe97be2a9f07d85c707aa72ba819d1867693a7b0eab935abcb46ae

Contents?: true

Size: 1.25 KB

Versions: 32

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

module Appsignal
  module Helpers
    module Heartbeats
      # Track heartbeats
      #
      # Track the execution of certain processes by sending a hearbeat.
      #
      # To track the duration of a piece of code, pass a block to {.heartbeat}
      # 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 heartbeat. The
      # exception will bubble outside of the heartbeat block.
      #
      # @example Send a heartbeat
      #   Appsignal.heartbeat("send_invoices")
      #
      # @example Send a heartbeat with duration
      #   Appsignal.heartbeat("send_invoices") do
      #     # your code
      #   end
      #
      # @param name [String] name of the heartbeat to report.
      # @yield the block to monitor.
      # @return [void]
      # @since 3.7.0
      # @see https://docs.appsignal.com/heartbeats
      def heartbeat(name)
        heartbeat = Appsignal::Heartbeat.new(:name => name)
        output = nil

        if block_given?
          heartbeat.start
          output = yield
        end

        heartbeat.finish
        output
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
appsignal-3.12.6-java lib/appsignal/helpers/heartbeats.rb
appsignal-3.12.6 lib/appsignal/helpers/heartbeats.rb
appsignal-3.12.5-java lib/appsignal/helpers/heartbeats.rb
appsignal-3.12.5 lib/appsignal/helpers/heartbeats.rb
appsignal-3.12.4-java lib/appsignal/helpers/heartbeats.rb
appsignal-3.12.4 lib/appsignal/helpers/heartbeats.rb
appsignal-3.12.3-java lib/appsignal/helpers/heartbeats.rb
appsignal-3.12.3 lib/appsignal/helpers/heartbeats.rb
appsignal-3.12.2-java lib/appsignal/helpers/heartbeats.rb
appsignal-3.12.2 lib/appsignal/helpers/heartbeats.rb
appsignal-3.12.1-java lib/appsignal/helpers/heartbeats.rb
appsignal-3.12.1 lib/appsignal/helpers/heartbeats.rb
appsignal-3.12.0-java lib/appsignal/helpers/heartbeats.rb
appsignal-3.12.0 lib/appsignal/helpers/heartbeats.rb
appsignal-3.11.0-java lib/appsignal/helpers/heartbeats.rb
appsignal-3.11.0 lib/appsignal/helpers/heartbeats.rb
appsignal-3.10.0-java lib/appsignal/helpers/heartbeats.rb
appsignal-3.10.0 lib/appsignal/helpers/heartbeats.rb
appsignal-3.9.3-java lib/appsignal/helpers/heartbeats.rb
appsignal-3.9.3 lib/appsignal/helpers/heartbeats.rb