Sha256: 283aa9b82c0263b795eef94bb5aa59d2735d93c2e44c021633bcfd54a670812d

Contents?: true

Size: 1.47 KB

Versions: 33

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

require_relative 'ext'
require_relative 'parsers'
require_relative '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

33 entries across 33 versions & 2 rubygems

Version Path
datadog-2.7.1 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
datadog-2.7.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
datadog-2.6.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
datadog-2.5.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
datadog-2.4.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
datadog-2.3.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
datadog-2.2.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.23.3 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.23.2 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
datadog-2.1.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
datadog-2.0.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.23.1 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
datadog-2.0.0.beta2 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.22.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
datadog-2.0.0.beta1 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.21.1 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.21.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.20.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.19.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.18.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb