class Rookout::Augs::Aug

Attributes

id[R]

Public Class Methods

new(aug_id, action, condition, rate_limiter, _max_aug_time) click to toggle source
# File lib/rookout/augs/aug.rb, line 13
def initialize aug_id, action, condition, rate_limiter, _max_aug_time
  # NOTE: max_aux_time is not implemented

  @id = aug_id
  @action = action
  @condition = condition
  @rate_limiter = rate_limiter

  @enabled = true
  @status = nil
  @log_cache = []
end

Public Instance Methods

execute(frame, extracted, output) click to toggle source
# File lib/rookout/augs/aug.rb, line 28
def execute frame, extracted, output
  return unless @enabled

  if output.user_messages_queue_full?
    Logger.instance.warning "Skipping aug-\t#{id} execution because the queue is full"
    return
  end

  namespace = create_namespaces frame, extracted
  return if @condition && !@condition.evaluate(namespace)

  @rate_limiter.with_limit do
    report_id = Utils.uuid
    Logger.instance.info "Executing aug-\t#{id} (msg ID #{report_id})"
    @action.execute @id, report_id, namespace, output
  end
end

Private Instance Methods

create_namespaces(frame, extracted) click to toggle source
# File lib/rookout/augs/aug.rb, line 48
def create_namespaces frame, extracted
  Processor::Namespaces::ContainerNamespace.new(
    "frame" => Processor::Namespaces::FrameNamespace.new(frame[1]),
    "stack" => Processor::Namespaces::StackNamespace.new(frame, 1),
    "extracted" => Processor::Namespaces::ContainerNamespace.new(extracted),
    "store" => Processor::Namespaces::ContainerNamespace.new,
    "temp" => Processor::Namespaces::ContainerNamespace.new,
    "utils" => Processor::Namespaces::RubyUtilsNamespace.new,
    "trace" => Processor::Namespaces::NoopNamespace.new,
    "state" => Processor::Namespaces::NoopNamespace.new
  )
end