Class: Fluent::Plugin::ObjectSpaceInput
- Defined in:
- lib/fluent/plugin/in_object_space.rb
Defined Under Namespace
Classes: Counter
Constant Summary
Constants included from Configurable
Configurable::CONFIG_TYPE_REGISTRY
Instance Attribute Summary
Attributes included from Fluent::PluginLoggerMixin
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize ⇒ ObjectSpaceInput
constructor
A new instance of ObjectSpaceInput.
- #multi_workers_ready? ⇒ Boolean
- #on_timer ⇒ Object
- #start ⇒ Object
Methods inherited from Input
#configure, #emit_records, #emit_size, #metric_callback, #statistics
Methods included from Fluent::PluginHelper::Mixin
Methods included from Fluent::PluginLoggerMixin
#configure, included, #terminate
Methods included from Fluent::PluginId
#configure, #plugin_id, #plugin_id_configured?, #plugin_id_for_test?, #plugin_root_dir, #stop
Methods inherited from Base
#acquire_worker_lock, #after_shutdown, #after_shutdown?, #after_start, #after_started?, #before_shutdown, #before_shutdown?, #called_in_test?, #close, #closed?, #configure, #configured?, #context_router, #context_router=, #fluentd_worker_id, #get_lock_path, #has_router?, #inspect, #plugin_root_dir, #reloadable_plugin?, #shutdown, #shutdown?, #started?, #stop, #stopped?, #string_safe_encoding, #terminate, #terminated?
Methods included from SystemConfig::Mixin
#system_config, #system_config_override
Methods included from Configurable
#config, #configure, #configure_proxy_generate, #configured_section_create, included, lookup_type, register_type
Constructor Details
#initialize ⇒ ObjectSpaceInput
Returns a new instance of ObjectSpaceInput.
27 28 29 |
# File 'lib/fluent/plugin/in_object_space.rb', line 27 def initialize super end |
Instance Method Details
#multi_workers_ready? ⇒ Boolean
35 36 37 |
# File 'lib/fluent/plugin/in_object_space.rb', line 35 def multi_workers_ready? true end |
#on_timer ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/fluent/plugin/in_object_space.rb', line 62 def on_timer now = Fluent::EventTime.now array = [] map = {} ObjectSpace.each_object {|obj| klass = obj.class rescue Object if c = map[klass] c.incr! else c = Counter.new(klass, 1) array << c map[klass] = c end } array.sort_by! {|c| -c.count } record = {} array.each_with_index {|c,i| break if i >= @top record[c.name] = c.count } router.emit(@tag, now, record) rescue => e log.error "object space failed to emit", error: e, tag: @tag, record: Yajl.dump(record) log.error_backtrace end |
#start ⇒ Object
39 40 41 42 43 |
# File 'lib/fluent/plugin/in_object_space.rb', line 39 def start super timer_execute(:object_space_input, @emit_interval, &method(:on_timer)) end |