Class: LogStash::FilterDelegator

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/logstash/filter_delegator.rb

Constant Summary collapse

DELEGATED_METHODS =
[
  :register,
  :close,
  :threadsafe?,
  :do_close,
  :do_stop,
  :periodic_flush,
  :reloadable?
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, metric, execution_context, plugin_args) ⇒ FilterDelegator

Returns a new instance of FilterDelegator.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/logstash/filter_delegator.rb', line 19

def initialize(klass, metric, execution_context, plugin_args)
  @klass = klass
  @id = plugin_args["id"]
  @filter = klass.new(plugin_args)

  # Scope the metrics to the plugin
  namespaced_metric = metric.namespace(@id.to_sym)
  @filter.metric = namespaced_metric
  @filter.execution_context = execution_context

  @metric_events = namespaced_metric.namespace(:events)
  @metric_events_in = @metric_events.counter(:in)
  @metric_events_out = @metric_events.counter(:out)
  @metric_events_time = @metric_events.counter(:duration_in_millis)
  namespaced_metric.gauge(:name, config_name)

  # Not all the filters will do bufferings
  define_flush_method if @filter.respond_to?(:flush)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



17
18
19
# File 'lib/logstash/filter_delegator.rb', line 17

def id
  @id
end

Instance Method Details

#config_nameObject



39
40
41
# File 'lib/logstash/filter_delegator.rb', line 39

def config_name
  @klass.config_name
end

#multi_filter(events) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/logstash/filter_delegator.rb', line 43

def multi_filter(events)
  @metric_events_in.increment(events.size)

  start_time = java.lang.System.nano_time
  new_events = @filter.multi_filter(events)
  @metric_events_time.increment((java.lang.System.nano_time - start_time) / 1_000_000)

  # There is no guarantee in the context of filter
  # that EVENTS_IN == EVENTS_OUT, see the aggregates and
  # the split filter
  c = new_events.count { |event| !event.cancelled? }
  @metric_events_out.increment(c) if c > 0
  new_events
end