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(output_class, metric, execution_context, 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
27
# File 'lib/logstash/output_delegator.rb', line 10

def initialize(output_class, metric, execution_context, strategy_registry, plugin_args)
  @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

  @namespaced_metric = metric.namespace(id.to_sym)
  @namespaced_metric.gauge(:name, config_name)
  @metric_events = @namespaced_metric.namespace(:events)
  @in_counter = @metric_events.counter(:in)
  @out_counter = @metric_events.counter(:out)
  @time_metric = @metric_events.counter(:duration_in_millis)
  @strategy = strategy_registry.
                class_for(self.concurrency).
                new(@output_class, @namespaced_metric, execution_context, plugin_args)
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



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

def concurrency
  @output_class.concurrency
end

#config_nameObject



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

def config_name
  @output_class.config_name
end

#do_closeObject



54
55
56
# File 'lib/logstash/output_delegator.rb', line 54

def do_close
  @strategy.do_close
end

#multi_receive(events) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/logstash/output_delegator.rb', line 45

def multi_receive(events)
  count = events.size
  @in_counter.increment(count)
  start_time = java.lang.System.nano_time
  @strategy.multi_receive(events)
  @time_metric.increment((java.lang.System.nano_time - start_time) / 1_000_000)
  @out_counter.increment(count)
end

#registerObject



41
42
43
# File 'lib/logstash/output_delegator.rb', line 41

def register
  @strategy.register
end

#reloadable?Boolean

Returns:

  • (Boolean)


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

def reloadable?
  @output_class.reloadable?
end