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 Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #config_name ⇒ Object
-
#initialize(filter, id) ⇒ FilterDelegator
constructor
A new instance of FilterDelegator.
- #multi_filter(events) ⇒ Object
Constructor Details
#initialize(filter, id) ⇒ FilterDelegator
Returns a new instance of FilterDelegator.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/logstash/filter_delegator.rb', line 19 def initialize(filter, id) @klass = filter.class @id = id @filter = filter # Scope the metrics to the plugin namespaced_metric = filter.metric @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
#id ⇒ Object (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_name ⇒ Object
36 37 38 |
# File 'lib/logstash/filter_delegator.rb', line 36 def config_name @klass.config_name end |
#multi_filter(events) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/logstash/filter_delegator.rb', line 40 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 |