Sha256: 0758685ada048d6e2775cee03817ab16ec452fad30bbf547acf600b2af6aa1b0

Contents?: true

Size: 1.52 KB

Versions: 4

Compression:

Stored size: 1.52 KB

Contents

# typed: false

require 'datadog/tracing/contrib/mongodb/ext'
require 'datadog/tracing/contrib/mongodb/parsers'
require 'datadog/tracing/contrib/mongodb/subscribers'

module Datadog
  module Tracing
    module Contrib
      module MongoDB
        # Instrumentation for Mongo integration
        module Instrumentation
          # Instrumentation for Mongo::Client
          module Client
            def self.included(base)
              base.include(InstanceMethods)
            end

            # Instance methods for Mongo::Client
            module InstanceMethods
              def datadog_pin
                # safe-navigation to avoid crashes during each query
                return unless respond_to? :cluster
                return unless cluster.respond_to? :addresses
                return unless cluster.addresses.respond_to? :first

                Datadog.configuration_for(cluster.addresses.first)
              end

              def datadog_pin=(pin)
                # safe-navigation to avoid crashes during each query
                return unless respond_to? :cluster
                return unless cluster.respond_to? :addresses
                return unless cluster.addresses.respond_to? :each

                # attach the PIN to all cluster addresses. One of them is used
                # when executing a Command and it is attached to the Monitoring
                # Event instance.
                cluster.addresses.each { |x| pin.onto(x) }
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ddtrace-1.2.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.1.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.0.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.0.0.beta2 lib/datadog/tracing/contrib/mongodb/instrumentation.rb