Class: LogStash::FilterDelegator
- Inherits:
-
Object
- Object
- LogStash::FilterDelegator
- 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 Method Summary collapse
- #config_name ⇒ Object
-
#initialize(logger, klass, metric, plugin_args) ⇒ FilterDelegator
constructor
A new instance of FilterDelegator.
- #multi_filter(events) ⇒ Object
Constructor Details
#initialize(logger, klass, metric, plugin_args) ⇒ FilterDelegator
Returns a new instance of FilterDelegator.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/logstash/filter_delegator.rb', line 17 def initialize(logger, klass, metric, plugin_args) @logger = logger @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 @metric_events = namespaced_metric.namespace(:events) namespaced_metric.gauge(:name, config_name) # Not all the filters will do bufferings define_flush_method if @filter.respond_to?(:flush) end |
Instance Method Details
#config_name ⇒ Object
34 35 36 |
# File 'lib/logstash/filter_delegator.rb', line 34 def config_name @klass.config_name end |
#multi_filter(events) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/logstash/filter_delegator.rb', line 38 def multi_filter(events) @metric_events.increment(:in, events.size) clock = @metric_events.time(:duration_in_millis) new_events = @filter.multi_filter(events) clock.stop # There is no garantee in the context of filter # that EVENTS_INT == EVENTS_OUT, see the aggregates and # the split filter c = new_events.count { |event| !event.cancelled? } @metric_events.increment(:out, c) if c > 0 return new_events end |