From 86a0ffc73e5652e2762b9b91e2c9518aaa319675 Mon Sep 17 00:00:00 2001 From: Natik Gadzhi Date: Sun, 26 Nov 2023 17:49:31 -0800 Subject: [PATCH] Capture Cockroach DB config in sentry-rails ActiveRecordSubscriber --- CHANGELOG.md | 1 + .../lib/sentry/rails/tracing/active_record_subscriber.rb | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24fdb0b8b..bc6992d05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - Respect custom `Delayed::Job.max_attempts` if it's defined [#2176](https://github.com/getsentry/sentry-ruby/pull/2176) - Fixed a bug where `Net::HTTP` instrumentation won't work for some IPv6 addresses [#2180](https://github.com/getsentry/sentry-ruby/pull/2180) - Allow non-string error message to be reported to sentry ([#2137](https://github.com/getsentry/sentry-ruby/pull/2137)) +- `sentry-rails` will now capture Cockroach DB adapter config into spans data [#2182](https://github.com/getsentry/sentry-ruby/pull/2182) ## 5.13.0 diff --git a/sentry-rails/lib/sentry/rails/tracing/active_record_subscriber.rb b/sentry-rails/lib/sentry/rails/tracing/active_record_subscriber.rb index 21eb1ea5c..cd355a51d 100644 --- a/sentry-rails/lib/sentry/rails/tracing/active_record_subscriber.rb +++ b/sentry-rails/lib/sentry/rails/tracing/active_record_subscriber.rb @@ -26,11 +26,15 @@ def self.subscribe! end next unless connection - + db_config = if connection.pool.respond_to?(:db_config) connection.pool.db_config.configuration_hash elsif connection.pool.respond_to?(:spec) connection.pool.spec.config + # CockroachDB pool shows up as NullPool, but we can grab + # it's configuration from the instance variable. + elsif connection.instance_variable_defined?(:@config) + connection.instance_variable_get(:@config) end next unless db_config