Class: Rookout::Augs::AugFactory

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

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ AugFactory

Returns a new instance of AugFactory.



18
19
20
21
# File 'lib/rookout/augs/aug_factory.rb', line 18

def initialize output
  @output = output
  @factory = Processor::ProcessorFactory.new
end

Instance Method Details

#create_aug(configuration) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rookout/augs/aug_factory.rb', line 23

def create_aug configuration
  aug_id = configuration["id"]
  raise Exceptions::RookAugInvalidKey.new("id", configuration) unless aug_id.is_a? String

  action_configuration = configuration["action"]
  raise Exceptions::RookAugInvalidKey.new("action", configuration) unless action_configuration.is_a? Hash
  action = Actions::ActionRunProcessor.new action_configuration, @factory

  max_aug_time = configuration["maxAugTime"] || Config.instrumentation_max_aug_time

  condition_configuration = configuration["conditional"]
  unless condition_configuration.nil? || condition_configuration.is_a?(String)
    raise Exceptions::RookAugInvalidKey.new("conditional", configuration)
  end
  condition = condition_configuration.nil? ? nil : Conditions::Condition.new(condition_configuration)

  limits_manager = create_limits_manager configuration

  max_aug_time_ns = Utils.milliseconds_to_nanoseconds max_aug_time
  aug = Aug.new aug_id, action, condition, limits_manager, max_aug_time_ns

  location_configuration = configuration["location"]
  raise Exceptions::RookAugInvalidKey.new("location", configuration) unless location_configuration.is_a? Hash
  create_location location_configuration, aug
end