Method: #patch_mongo

Defined in:
lib/helios/opentelemetry/sdk/instrumentations.rb

#patch_mongoObject



86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/helios/opentelemetry/sdk/instrumentations.rb', line 86

def patch_mongo
  return unless defined?(::Mongo::Monitoring::Global)

  require 'opentelemetry/instrumentation/mongo/subscriber'
  min_version = ::OpenTelemetry::Instrumentation::Mongo::Instrumentation::MINIMUM_VERSION
  mongo_version = Gem::Version.new(::Mongo::VERSION)
  return unless mongo_version >= min_version

  require_relative 'patches/mongo_patch'
  ::OpenTelemetry::Instrumentation::Mongo::Subscriber.prepend(MongoPatch::Subscriber)
  ::OpenTelemetry::Instrumentation::Mongo::CommandSerializer.prepend(MongoPatch::CommandSerializer)
rescue StandardError => e
  ::OpenTelemetry.logger.debug("Error patching mongo: #{e}")
end