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
ddtrace-1.17.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.16.2 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.16.1 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.16.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.15.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.14.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.13.1 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.13.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.12.1 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.12.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.11.1 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.11.0 lib/datadog/tracing/contrib/mongodb/instrumentation.rb
ddtrace-1.11.0.beta1 lib/datadog/tracing/contrib/mongodb/instrumentation.rb