Sha256: 417d9d55a0d7c0bb71bca6cbf405bf0dc979e50bdb56736248321ded55ccbb30

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

# encoding: utf-8

LibraryDetection.defer do
  @name = :sequel

  depends_on do
    defined?(::Sequel)
  end

  depends_on do
    !OneApm::Agent.config[:disable_sequel_instrumentation]
  end

  def supported_sequel_version?
    Sequel.const_defined?( :MAJOR ) &&
      ( Sequel::MAJOR > 3 ||
        Sequel::MAJOR == 3 && Sequel::MINOR >= 37 )
  end

  executes do
    if supported_sequel_version?

      ::OneApm::Agent.logger.info 'Installing Sequel instrumentation'

      if Sequel::Database.respond_to?(:extension)
        Sequel::Database.extension :oneapm_instrumentation
      else
        OneApm::Agent.logger.info "Detected Sequel version %s." % [ Sequel::VERSION ]
        OneApm::Agent.logger.info "Please see additional documentation: " +
          "https://oneapm.com/docs/ruby/sequel-instrumentation"
      end

      Sequel.synchronize{Sequel::DATABASES.dup}.each do |db|
        db.extension :oneapm_instrumentation
      end

      Sequel::Model.plugin :oneapm_instrumentation

    else

      OneApm::Agent.logger.info "Sequel instrumentation requires at least version 3.37.0."

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
oneapm_rpm-1.1.1 lib/one_apm/inst/orm/sequel.rb
oneapm_rpm-1.1.0 lib/one_apm/inst/orm/sequel.rb