Sha256: 521ab74b9a9dff85c934621c93f588dbaef019e6b5dbd31d7a2bfc9c36ab4a24

Contents?: true

Size: 984 Bytes

Versions: 16

Compression:

Stored size: 984 Bytes

Contents

# encoding: utf-8
module Moped
  module Instrumentable

    # Provides logging instrumentation for compatibility with active support
    # notifications.
    #
    # @since 2.0.0
    module Log
      extend self

      # Instrument the log payload.
      #
      # @example Instrument the log payload.
      #   Log.instrument("moped.ops", {})
      #
      # @param [ String ] name The name of the logging type.
      # @param [ Hash ] payload The log payload.
      #
      # @return [ Object ] The result of the yield.
      #
      # @since 2.0.0
      def instrument(name, payload = {})
        started = Time.new
        begin
          yield if block_given?
        rescue Exception => e
          payload[:exception] = [ e.class.name, e.message ]
          raise e
        ensure
          runtime = ("%.4fms" % (1000 * (Time.now.to_f - started.to_f)))
          Moped::Loggable.log_operations(payload[:prefix], payload[:ops], runtime)
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/bundler/gems/moped-cf817ca58a85/lib/moped/instrumentable/log.rb
moped-2.0.7 lib/moped/instrumentable/log.rb
moped-2.0.6 lib/moped/instrumentable/log.rb
moped-2.0.5 lib/moped/instrumentable/log.rb
moped-2.0.4 lib/moped/instrumentable/log.rb
moped-2.0.3 lib/moped/instrumentable/log.rb
moped-2.0.2 lib/moped/instrumentable/log.rb
moped-2.0.1 lib/moped/instrumentable/log.rb
moped-2.0.0 lib/moped/instrumentable/log.rb
moped-2.0.0.rc2 lib/moped/instrumentable/log.rb
moped-2.0.0.rc1 lib/moped/instrumentable/log.rb
moped-2.0.0.beta6 lib/moped/instrumentable/log.rb
moped-2.0.0.beta5 lib/moped/instrumentable/log.rb
moped-2.0.0.beta4 lib/moped/instrumentable/log.rb
moped-2.0.0.beta3 lib/moped/instrumentable/log.rb
moped-2.0.0.beta2 lib/moped/instrumentable/log.rb