Giter VIP home page Giter VIP logo

Comments (3)

mintuhouse avatar mintuhouse commented on June 29, 2024 2

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

from makara.

nguyenngoc2505 avatar nguyenngoc2505 commented on June 29, 2024

I've a same question.

from makara.

BambangSinaga avatar BambangSinaga commented on June 29, 2024

Hello,

I have problem related to query log. They're not showing value from adapter._makara_name.
versions:

  • rails api 6.1.6
  • ruby 2.7.4
  • makara 0.5.1

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?

from makara.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.