Sha256: efe719952fca550c61fa39588d466446238bd684e4e6a0dafa2ebad5f5c38613

Contents?: true

Size: 638 Bytes

Versions: 57

Compression:

Stored size: 638 Bytes

Contents

require 'monitor'

# This is an example instrumentation listener that stores the last
# 20 instrumented probe run time.
Puppet::Util::Instrumentation.new_listener(:log) do

  SIZE = 20

  attr_accessor :last_logs

  def initialize
    @last_logs = {}.extend(MonitorMixin)
  end

  def notify(label, event, data)
    return if event == :start
    log_line = "#{label} took #{data[:finished] - data[:started]}"
    @last_logs.synchronize {
      (@last_logs[label] ||= []) << log_line
      @last_logs[label].shift if @last_logs[label].length > SIZE
    }
  end

  def data
    @last_logs.synchronize {
      @last_logs.dup
    }
  end
end

Version data entries

57 entries across 57 versions & 3 rubygems

Version Path
puppet-parse-0.1.4 lib/vendor/puppet/util/instrumentation/listeners/log.rb
puppet-parse-0.1.3 lib/vendor/puppet/util/instrumentation/listeners/log.rb
puppet-parse-0.1.2 lib/vendor/puppet/util/instrumentation/listeners/log.rb
puppet-parse-0.1.1 lib/vendor/puppet/util/instrumentation/listeners/log.rb
puppet-2.7.26 lib/puppet/util/instrumentation/listeners/log.rb
puppet-2.7.25 lib/puppet/util/instrumentation/listeners/log.rb
puppet-2.7.24 lib/puppet/util/instrumentation/listeners/log.rb
puppet-3.3.2 lib/puppet/util/instrumentation/listeners/log.rb
puppet-3.3.1 lib/puppet/util/instrumentation/listeners/log.rb
puppet-3.3.1.rc3 lib/puppet/util/instrumentation/listeners/log.rb
puppet-3.3.1.rc2 lib/puppet/util/instrumentation/listeners/log.rb
puppet-3.3.1.rc1 lib/puppet/util/instrumentation/listeners/log.rb
puppet-3.3.0 lib/puppet/util/instrumentation/listeners/log.rb
puppet-3.3.0.rc3 lib/puppet/util/instrumentation/listeners/log.rb
puppet-3.3.0.rc2 lib/puppet/util/instrumentation/listeners/log.rb
puppet-3.2.4 lib/puppet/util/instrumentation/listeners/log.rb
puppet-2.7.23 lib/puppet/util/instrumentation/listeners/log.rb
puppet-3.2.3 lib/puppet/util/instrumentation/listeners/log.rb
puppet-3.2.3.rc1 lib/puppet/util/instrumentation/listeners/log.rb
puppet-3.2.2 lib/puppet/util/instrumentation/listeners/log.rb