Class: Skylight::Core::Probes::Moped::Probe Private

Inherits:
Object
  • Object
show all
Defined in:
lib/skylight/core/probes/moped.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#installObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 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