Open fukata opened 3 years ago
I've a same question.
Add below to your initializer to skip printing primary/replica
for queries returned from cache
module MakaraLoggingSubscriber
# See https://github.com/instacart/makara/blob/e45ba090fce998dad9e9a2759426f4695009cfae/lib/makara/logging/subscriber.rb#L23
def current_wrapper_name(event)
return nil if event.payload[:cached]
super(event)
end
end
ActiveRecord::LogSubscriber.log_subscribers.each do |subscriber|
subscriber.extend ::MakaraLoggingSubscriber
end
Hello,
I have problem related to query log. They're not showing value from adapter._makara_name
.
versions:
database.yml
default: &default
adapter: postgresql_makara
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: super_awesome_api_development
makara:
id: postgresql
# list your connections with the override values (they're merged into the top-level config)
# be sure to provide the role if primary, role is assumed to be a replica if not provided
connections:
- role: master
name: primary
blacklist_duration: 0
host: localhost
- role: replica
name: replica
host: localhost
development.log
Started GET "/attendance_office_hours" for ::1 at 2022-05-20 14:02:37 +0700
Processing by AttendanceOfficeHoursController#index as */*
AttendanceOfficeHour Load (0.8ms) SELECT "attendance_office_hours".* FROM "attendance_office_hours" WHERE "attendance_office_hours"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
↳ app/controllers/attendance_office_hours_controller.rb:5:in `index'
Completed 200 OK in 30ms (Views: 0.8ms | ActiveRecord: 11.4ms | Allocations: 7800)
I don't know if this query hit primary or replica. Is there any config I should add?
Hello.
Thanks for the easy to use and awesome gem!
I'm currently verifying it for use in a production environment and found a phenomenon that I'm not sure if it's a bug or a specification, so I'd like to ask a question.
Versions
database.yml
Log
log/development.log
Question
The cached results are always output as
CACHE [primary]
in the log.I've been monitoring both primary and replica mysql with general-log output, but there is no log output on the primary, only on the replica.
I thought it would be better to show
CACHE [replica]
since it is a cache of the query results to replica.