Sha256: 23f32aecf54fc185aed2aa6787238e201a1477cec689ee9e2f6e0f584e03988a

Contents?: true

Size: 628 Bytes

Versions: 2

Compression:

Stored size: 628 Bytes

Contents

require 'sequel/database/logging'
require 'active_support/notifications'

module Sequel

  class Database

    def log_yield_with_instrumentation(sql, args = nil, &block)
      ActiveSupport::Notifications.instrument(
        'sql.rom',
        :sql => sql,
        :name => instrumentation_name,
        :binds => args
      ) do
        log_yield_without_instrumentation(sql, args, &block)
      end
    end

    alias_method :log_yield_without_instrumentation, :log_yield
    alias_method :log_yield, :log_yield_with_instrumentation

    private

    def instrumentation_name
      "ROM[#{database_type}]"
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rom-sql-0.3.0 lib/rom/sql/support/active_support_notifications.rb
rom-sql-0.2.0 lib/rom/sql/support/active_support_notifications.rb