Class: LogStash::OutputDelegator

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/output_delegator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger, output_class, metric, strategy_registry, plugin_args) ⇒ OutputDelegator

Returns a new instance of OutputDelegator.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/logstash/output_delegator.rb', line 10

def initialize(logger, output_class, metric, strategy_registry, plugin_args)
  @logger = logger
  @output_class = output_class
  @metric = metric
  @id = plugin_args["id"]

  raise ArgumentError, "No strategy registry specified" unless strategy_registry
  raise ArgumentError, "No ID specified! Got args #{plugin_args}" unless id
  
  @strategy = strategy_registry.
                class_for(self.concurrency).
                new(@logger, @output_class, @metric, plugin_args)
  
  @namespaced_metric = metric.namespace(id.to_sym)
  @namespaced_metric.gauge(:name, config_name)
  @metric_events = @namespaced_metric.namespace(:events)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/logstash/output_delegator.rb', line 8

def id
  @id
end

#metricObject (readonly)

Returns the value of attribute metric.



8
9
10
# File 'lib/logstash/output_delegator.rb', line 8

def metric
  @metric
end

#metric_eventsObject (readonly)

Returns the value of attribute metric_events.



8
9
10
# File 'lib/logstash/output_delegator.rb', line 8

def metric_events
  @metric_events
end

#namespaced_metricObject (readonly)

Returns the value of attribute namespaced_metric.



8
9
10
# File 'lib/logstash/output_delegator.rb', line 8

def namespaced_metric
  @namespaced_metric
end

#strategyObject (readonly)

Returns the value of attribute strategy.



8
9
10
# File 'lib/logstash/output_delegator.rb', line 8

def strategy
  @strategy
end

Instance Method Details

#concurrencyObject



32
33
34
# File 'lib/logstash/output_delegator.rb', line 32

def concurrency
  @output_class.concurrency
end

#config_nameObject



28
29
30
# File 'lib/logstash/output_delegator.rb', line 28

def config_name
  @output_class.config_name
end

#do_closeObject



48
49
50
# File 'lib/logstash/output_delegator.rb', line 48

def do_close
  @strategy.do_close
end

#multi_receive(events) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/logstash/output_delegator.rb', line 40

def multi_receive(events)
  @metric_events.increment(:in, events.length)
  clock = @metric_events.time(:duration_in_millis)
  @strategy.multi_receive(events)
  clock.stop
  @metric_events.increment(:out, events.length)
end

#registerObject



36
37
38
# File 'lib/logstash/output_delegator.rb', line 36

def register
  @strategy.register
end