Sha256: 5751b4e953c3a71499932cba9dd3e7da4f454b9caf45a425b367b77f430bd415

Contents?: true

Size: 1.36 KB

Versions: 15

Compression:

Stored size: 1.36 KB

Contents

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

    module SequelLogConnectionExtension
      # Add query instrumentation
      def log_connection_yield(sql, conn, args = nil)
        ActiveSupport::Notifications.instrument(
          'sql.sequel',
          :sql => sql
        ) 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

15 entries across 15 versions & 1 rubygems

Version Path
appsignal-1.2.5 lib/appsignal/hooks/sequel.rb
appsignal-1.2.4 lib/appsignal/hooks/sequel.rb
appsignal-1.2.4.beta.4 lib/appsignal/hooks/sequel.rb
appsignal-1.2.4.beta.3 lib/appsignal/hooks/sequel.rb
appsignal-1.2.4.beta.2 lib/appsignal/hooks/sequel.rb
appsignal-1.2.4.beta.1 lib/appsignal/hooks/sequel.rb
appsignal-1.2.3 lib/appsignal/hooks/sequel.rb
appsignal-1.2.3.beta.3 lib/appsignal/hooks/sequel.rb
appsignal-1.2.3.beta.2 lib/appsignal/hooks/sequel.rb
appsignal-1.2.3.beta.1 lib/appsignal/hooks/sequel.rb
appsignal-1.2.2 lib/appsignal/hooks/sequel.rb
appsignal-1.2.1 lib/appsignal/hooks/sequel.rb
appsignal-1.2.1.beta.3 lib/appsignal/hooks/sequel.rb
appsignal-1.2.1.beta.2 lib/appsignal/hooks/sequel.rb
appsignal-1.2.1.beta.1 lib/appsignal/hooks/sequel.rb