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

Defined in:
lib/datadog/tracing/contrib/mongodb/instrumentation.rb

Overview

Instance methods for Mongo::Client

Instance Method Summary collapse

Instance Method Details

#datadog_pinObject



21
22
23
24
25
26
27
28
# File 'lib/datadog/tracing/contrib/mongodb/instrumentation.rb', line 21

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

#datadog_pin=(pin) ⇒ Object



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

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