Module: ActiveRecord::ConnectionAdapters::CockroachDBConnectionPool

Defined in:
lib/active_record/connection_adapters/cockroachdb_adapter.rb

Instance Method Summary collapse

Instance Method Details

#initialize(spec) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/active_record/connection_adapters/cockroachdb_adapter.rb', line 55

def initialize(spec)
  super(spec)
  disable_telemetry = spec.config[:disable_cockroachdb_telemetry]
  adapter = spec.config[:adapter]
  return if disable_telemetry || adapter != "cockroachdb"

  with_connection do |conn|
    if conn.active?
      begin
        query = "SELECT crdb_internal.increment_feature_counter('ActiveRecord %d.%d')"
        conn.execute(query % [ActiveRecord::VERSION::MAJOR, ActiveRecord::VERSION::MINOR])
      rescue ActiveRecord::StatementInvalid
        # The increment_feature_counter built-in is not supported on this
        # CockroachDB version. Ignore.
      rescue StandardError => e
        conn.logger.warn "Unexpected error when incrementing feature counter: #{e}"
      end
    end
  end
end