Skip to content

Commit 790fb92

Browse files
committed
Call telemetry built-in at initialization time
I enhanced the initialize function to call the increment_feature_counter built-in (if supported). This triggers telemetry on usage of the adapter.
1 parent ac7edda commit 790fb92

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/active_record/connection_adapters/cockroachdb_adapter.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,20 @@ def initialize(connection, logger, conn_params, config)
205205
version_num = 202
206206
end
207207
@crdb_version = version_num
208+
209+
Thread.new do
210+
begin
211+
query = "SELECT crdb_internal.increment_feature_counter('ActiveRecord %d.%d')"
212+
query_value(query % [ActiveRecord::VERSION::MAJOR, ActiveRecord::VERSION::MINOR])
213+
rescue ActiveRecord::StatementInvalid => error
214+
if error.cause.class == PG::UndefinedFunction
215+
# The increment_feature_counter built-in is not supported on this
216+
# CockroachDB version. Ignore.
217+
else
218+
raise error
219+
end
220+
end
221+
end
208222
end
209223

210224
def self.database_exists?(config)

0 commit comments

Comments
 (0)