class Skylight::Core::Probes::Moped::Probe

Public Instance Methods

install() click to toggle source
# File lib/skylight/core/probes/moped.rb, line 5
def install
  unless defined?(::Moped::Instrumentable)
    # Using $stderr here isn't great, but we don't have a logger accessible
    $stderr.puts "[SKYLIGHT::CORE] [#{Skylight::Core::VERSION}] The installed version of Moped doesn't " \
                  "support instrumentation. The Moped probe will be disabled."

    return
  end

  ::Moped::Instrumentable.module_eval do
    alias_method :instrument_without_sk, :instrument

    def instrument(*args, &block)
      # Mongoid sets the instrumenter to AS::N
      asn_block =
        if instrumenter == ActiveSupport::Notifications
          block
        else
          # If the instrumenter hasn't been changed to AS::N use both
          proc do
            ActiveSupport::Notifications.instrument(*args, &block)
          end
        end

      instrument_without_sk(*args, &asn_block)
    end
  end
end
instrument(*args, &block) click to toggle source
# File lib/skylight/core/probes/moped.rb, line 17
def instrument(*args, &block)
  # Mongoid sets the instrumenter to AS::N
  asn_block =
    if instrumenter == ActiveSupport::Notifications
      block
    else
      # If the instrumenter hasn't been changed to AS::N use both
      proc do
        ActiveSupport::Notifications.instrument(*args, &block)
      end
    end

  instrument_without_sk(*args, &asn_block)
end