Sha256: c0662bf657d48150ed097350fc2120baaf2dddc91760bddfce885219acc4a383

Contents?: true

Size: 808 Bytes

Versions: 3

Compression:

Stored size: 808 Bytes

Contents

require 'ddtrace/contrib/patcher'
require 'ddtrace/contrib/mongodb/ext'
require 'ddtrace/contrib/mongodb/instrumentation'

module Datadog
  module Contrib
    module MongoDB
      # Patcher enables patching of 'mongo' module.
      module Patcher
        include Contrib::Patcher

        module_function

        def target_version
          Integration.version
        end

        def patch
          ::Mongo::Address.include(Instrumentation::Address)
          ::Mongo::Client.include(Instrumentation::Client)
          add_mongo_monitoring
        end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ddtrace-0.51.1 lib/ddtrace/contrib/mongodb/patcher.rb
ddtrace-0.51.0 lib/ddtrace/contrib/mongodb/patcher.rb
ddtrace-0.50.0 lib/ddtrace/contrib/mongodb/patcher.rb