Module: Datadog::Contrib::MongoDB::Patcher

Includes:
Patcher
Defined in:
lib/ddtrace/contrib/mongodb/patcher.rb

Overview

Patcher enables patching of ‘mongo’ module.

Class Method Summary collapse

Methods included from Patcher

included

Class Method Details

.add_mongo_monitoringObject



30
31
32
33
# File 'lib/ddtrace/contrib/mongodb/patcher.rb', line 30

def add_mongo_monitoring
  # Subscribe to all COMMAND queries with our subscriber class
  ::Mongo::Monitoring::Global.subscribe(::Mongo::Monitoring::COMMAND, MongoCommandSubscriber.new)
end

.patchObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ddtrace/contrib/mongodb/patcher.rb', line 18

def patch
  do_once(:mongo) do
    begin
      ::Mongo::Address.send(:include, Instrumentation::Address)
      ::Mongo::Client.send(:include, Instrumentation::Client)
      add_mongo_monitoring
    rescue StandardError => e
      Datadog::Tracer.log.error("Unable to apply MongoDB integration: #{e}")
    end
  end
end

.patched?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/ddtrace/contrib/mongodb/patcher.rb', line 14

def patched?
  done?(:mongo)
end