Class: LogStash::JavaFilterDelegator
- Inherits:
-
Object
- Object
- LogStash::JavaFilterDelegator
- Extended by:
- Forwardable
- Includes:
- orgorg.logstashorg.logstash.configorg.logstash.config.irorg.logstash.config.ir.compilerorg.logstash.config.ir.compiler.RubyIntegrationorg.logstash.config.ir.compiler.RubyIntegration::Filter
- Defined in:
- lib/logstash/java_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
- #flush(options = {}) ⇒ Object
- #has_flush ⇒ Object
-
#initialize(klass, metric, execution_context, plugin_args) ⇒ JavaFilterDelegator
constructor
A new instance of JavaFilterDelegator.
- #multi_filter(events) ⇒ Object
- #toRuby ⇒ Object
Constructor Details
#initialize(klass, metric, execution_context, plugin_args) ⇒ JavaFilterDelegator
Returns a new instance of JavaFilterDelegator.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/logstash/java_filter_delegator.rb', line 20 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 @flushes = @filter.respond_to?(:flush) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
18 19 20 |
# File 'lib/logstash/java_filter_delegator.rb', line 18 def id @id end |
Instance Method Details
#config_name ⇒ Object
44 45 46 |
# File 'lib/logstash/java_filter_delegator.rb', line 44 def config_name @klass.config_name end |
#flush(options = {}) ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/logstash/java_filter_delegator.rb', line 67 def flush( = {}) # we also need to trace the number of events # coming from a specific filters. new_events = @filter.flush() # Filter plugins that does buffering or spooling of events like the # `Logstash-filter-aggregates` can return `NIL` and will flush on the next flush ticks. @metric_events_out.increment(new_events.size) if new_events && new_events.size > 0 new_events end |
#has_flush ⇒ Object
63 64 65 |
# File 'lib/logstash/java_filter_delegator.rb', line 63 def has_flush @flushes end |
#multi_filter(events) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/logstash/java_filter_delegator.rb', line 48 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 |
#toRuby ⇒ Object
40 41 42 |
# File 'lib/logstash/java_filter_delegator.rb', line 40 def toRuby self end |