2

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.

Sushma Satish
  • 2,363
  • 2
  • 20
  • 23

1 Answers1

1

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.

Matouš Borák
  • 15,606
  • 1
  • 42
  • 53