Class: Rookout::Augs::Aug

Inherits:
Object
  • Object
show all
Defined in:
lib/rookout/augs/aug.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aug_id, action, condition, limits_manager, _max_aug_time) ⇒ Aug

Returns a new instance of Aug.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rookout/augs/aug.rb', line 13

def initialize aug_id, action, condition, limits_manager, _max_aug_time
  @id = aug_id
  @action = action
  @condition = condition
  @limits_manager = limits_manager

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

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



25
26
27
# File 'lib/rookout/augs/aug.rb', line 25

def id
  @id
end

Instance Method Details

#execute(frame_binding, stack_trace, extracted, output) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rookout/augs/aug.rb', line 27

def execute frame_binding, stack_trace, extracted, output
  return unless @enabled

  if output.user_messages_queue_full?
    output.send_output_queue_full_warning @id
    return
  end

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

  should_skip_limiters = @condition.nil? && !@executed
  @limits_manager.with_limit should_skip_limiters do
    @executed = true
    report_id = Utils.uuid
    Logger.instance.info "Executing aug-\t#{id} (msg ID #{report_id})"
    @action.execute @id, report_id, namespace, output
  end
end