module Fluent::ElapsedTimable

Public Class Methods

included(klass) click to toggle source
# File lib/fluent/mixin/elapsed_time.rb, line 5
def self.included(klass)
  klass.__send__(:alias_method, :configure_without_elapsed, :configure)
  klass.__send__(:alias_method, :configure, :configure_with_elapsed)
end

Public Instance Methods

configure_with_elapsed(conf) click to toggle source
# File lib/fluent/mixin/elapsed_time.rb, line 10
def configure_with_elapsed(conf)
  configure_without_elapsed(conf)
  if element = conf.elements.select { |element| element.name == 'elapsed' }.first
    @elapsed = ElapsedTime.new(self, log)
    @elapsed.configure(element)
    # #start and #stop methods must be extended in concrete input plugins
    # because most of built-in input plugins do not call `super`
    klass = self.class
    unless klass.method_defined?(:start_without_elapsed)
      klass.__send__(:alias_method, :start_without_elapsed, :start)
      klass.__send__(:alias_method, :start, :start_with_elapsed)
      klass.__send__(:alias_method, :shutdown_without_elapsed, :shutdown)
      klass.__send__(:alias_method, :shutdown, :shutdown_with_elapsed)
    end
  end
end
elapsed() click to toggle source
# File lib/fluent/mixin/elapsed_time.rb, line 27
def elapsed
  @elapsed
end
shutdown_with_elapsed() click to toggle source
# File lib/fluent/mixin/elapsed_time.rb, line 36
def shutdown_with_elapsed
  shutdown_without_elapsed
  @elapsed.stop if @elapsed
end
start_with_elapsed() click to toggle source
# File lib/fluent/mixin/elapsed_time.rb, line 31
def start_with_elapsed
  start_without_elapsed
  @elapsed.start if @elapsed
end