Does anyone have a way to check which database is being queried from ActiveRecord using Octopus Gem?
I want to check whether the read requests are actually hitting slave database and not master database.
Does anyone have a way to check which database is being queried from ActiveRecord using Octopus Gem?
I want to check whether the read requests are actually hitting slave database and not master database.
Looking into the gem source code, I believe that Octopus already logs the current shard it sends the ActiveRecord query against, by default. You need to set your Rails logger to the :debug
level and then you should see a green prefix [Shard: the_db] ...
on each debug line, including the SQL printings.
See also this gem's spec for using the logging feature.