Sha256: c9446c14e02d9ccf5c9a2d77064a7827ac11e095f0216b7942c900ad052555f2

Contents?: true

Size: 1.14 KB

Versions: 28

Compression:

Stored size: 1.14 KB

Contents

module Skylight
  module Probes
    module Moped
      class Probe

        def install
          unless defined?(::Moped::Instrumentable)
            # Using $stderr here isn't great, but we don't have a logger accessible
            $stderr.puts "[SKYLIGHT] [#{Skylight::VERSION}] The installed version of Moped doesn't " \
                          "support instrumentation. The Moped probe will be disabled."

            return
          end

          ::Moped::Instrumentable.module_eval do
            alias instrument_without_sk instrument

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

              instrument_without_sk(*args, &asn_block)
            end
          end
        end

      end
    end

    register("Moped", "moped", Moped::Probe.new)
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
skylight-1.6.1 lib/skylight/probes/moped.rb
skylight-1.6.0 lib/skylight/probes/moped.rb
skylight-1.5.1 lib/skylight/probes/moped.rb
skylight-1.5.0 lib/skylight/probes/moped.rb
skylight-1.4.4 lib/skylight/probes/moped.rb
skylight-1.4.3 lib/skylight/probes/moped.rb
skylight-1.4.2 lib/skylight/probes/moped.rb
skylight-1.4.1 lib/skylight/probes/moped.rb
skylight-1.4.0 lib/skylight/probes/moped.rb
skylight-1.4.0.beta.2 lib/skylight/probes/moped.rb
skylight-1.4.0.beta lib/skylight/probes/moped.rb
skylight-1.3.1 lib/skylight/probes/moped.rb
skylight-1.3.0 lib/skylight/probes/moped.rb
skylight-1.2.2 lib/skylight/probes/moped.rb
skylight-1.2.1 lib/skylight/probes/moped.rb
skylight-1.2.0 lib/skylight/probes/moped.rb
skylight-1.1.0 lib/skylight/probes/moped.rb
skylight-1.0.1 lib/skylight/probes/moped.rb
skylight-1.0.0 lib/skylight/probes/moped.rb
skylight-0.10.6 lib/skylight/probes/moped.rb