module Technologic::ClassMethods

Public Instance Methods

instrument(*args, **opts, &block) click to toggle source

DEP-2021-01-14 Remove this method

# File lib/technologic.rb, line 65
def instrument(*args, **opts, &block)
  ActiveSupport::Deprecation.warn("Technologic.instrument is deprecated. Instead, use the corresponding severity-level convenience method (#info, #error etc)")

  _tl_instrument(*args, **opts, &block)
end
surveil(event, severity: :info, **data, &block) click to toggle source
# File lib/technologic.rb, line 71
def surveil(event, severity: :info, **data, &block)
  raise LocalJumpError unless block_given?

  raise ArgumentError, "Invalid severity: #{severity}" unless severity.to_sym.in?(SEVERITIES)

  _tl_instrument(severity, "#{event}_started", **data)
  _tl_instrument(severity, "#{event}_finished", &block)
end

Protected Instance Methods

_tl_instrument(severity, event, **data, &block) click to toggle source
# File lib/technologic.rb, line 108
def _tl_instrument(severity, event, **data, &block)
  ActiveSupport::Notifications.instrument("#{event}.#{name}.#{severity}", data, &block).tap do
    # If a block was defined, :instrument will return the value of the block.
    # Otherwise, :instrument will return nil, since it didn't do anything.
    # Returning true here allows us to do fun things like `info :subscription_created and return subscription`
    return true unless block_given?
  end
end