Module: Datadog::Contrib::MongoDB::Instrumentation::Client::InstanceMethods

Defined in:
lib/ddtrace/contrib/mongodb/instrumentation.rb

Overview

Instance methods for Mongo::Client

Instance Method Summary collapse

Instance Method Details

#datadog_pinObject



22
23
24
25
26
27
28
29
# File 'lib/ddtrace/contrib/mongodb/instrumentation.rb', line 22

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::Pin.get_from(cluster.addresses.first)
end

#datadog_pin=(pin) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ddtrace/contrib/mongodb/instrumentation.rb', line 31

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