Sha256: accc96e1267e1fdea0d76358fe16e07be4122d9713b9cfdf71b5b251e0255826

Contents?: true

Size: 1.44 KB

Versions: 18

Compression:

Stored size: 1.44 KB

Contents

module Appsignal
  class Hooks
    module SequelLogExtension
      # Add query instrumentation
      def log_yield(sql, args = nil)
        Appsignal.instrument(
          'sql.sequel',
          nil,
          sql,
          Appsignal::EventFormatter::SQL_BODY_FORMAT
        ) do
          yield
        end
      end
    end

    module SequelLogConnectionExtension
      # Add query instrumentation
      def log_connection_yield(sql, conn, args = nil)
        Appsignal.instrument(
          'sql.sequel',
          nil,
          sql,
          Appsignal::EventFormatter::SQL_BODY_FORMAT
        ) do
          yield
        end
      end
    end

    class SequelHook < Appsignal::Hooks::Hook
      register :sequel

      def dependencies_present?
        defined?(::Sequel::Database) &&
          Appsignal.config &&
          Appsignal.config[:instrument_sequel]
      end

      def install
        # Register the extension...
        if ::Sequel::MAJOR >= 4 && ::Sequel::MINOR >= 35
          ::Sequel::Database.register_extension(
            :appsignal_integration,
            Appsignal::Hooks::SequelLogConnectionExtension
          )
        else
          ::Sequel::Database.register_extension(
            :appsignal_integration,
            Appsignal::Hooks::SequelLogExtension
          )
        end

        # ... and automatically add it to future instances.
        ::Sequel::Database.extension(:appsignal_integration)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
appsignal-2.0.1 lib/appsignal/hooks/sequel.rb
appsignal-2.0.0 lib/appsignal/hooks/sequel.rb
appsignal-2.0.0.beta.1 lib/appsignal/hooks/sequel.rb
appsignal-1.4.0.beta.1 lib/appsignal/hooks/sequel.rb
appsignal-1.3.6 lib/appsignal/hooks/sequel.rb
appsignal-1.3.6.beta.1 lib/appsignal/hooks/sequel.rb
appsignal-1.3.5 lib/appsignal/hooks/sequel.rb
appsignal-1.3.5.beta.1 lib/appsignal/hooks/sequel.rb
appsignal-1.3.4 lib/appsignal/hooks/sequel.rb
appsignal-1.3.3 lib/appsignal/hooks/sequel.rb
appsignal-1.4.0.alpha.2 lib/appsignal/hooks/sequel.rb
appsignal-1.4.0.alpha.1 lib/appsignal/hooks/sequel.rb
appsignal-1.3.2 lib/appsignal/hooks/sequel.rb
appsignal-1.3.1 lib/appsignal/hooks/sequel.rb
appsignal-1.3.0 lib/appsignal/hooks/sequel.rb
appsignal-1.3.0.beta.3 lib/appsignal/hooks/sequel.rb
appsignal-1.3.0.beta.2 lib/appsignal/hooks/sequel.rb
appsignal-1.3.0.beta.1 lib/appsignal/hooks/sequel.rb