Sha256: 2a583487dc792cc3665473f53b89b1d97be0b41aeb6aa5ea2048dfdf7c77b0ae
Contents?: true
Size: 664 Bytes
Versions: 2
Compression:
Stored size: 664 Bytes
Contents
require 'shiba/query' require 'shiba/backtrace' module Shiba # Logs ActiveRecord SELECT queries that originate from application code. class QueryWatcher attr_reader :queries def initialize(file) @file = file # fixme mem growth on this is kinda nasty @queries = {} end def call(name, start, finish, id, payload) sql = payload[:sql] return if !sql.start_with?("SELECT") fingerprint = Query.get_fingerprint(sql) return if @queries[fingerprint] lines = Backtrace.from_app return if !lines @file.puts("#{sql} /*shiba#{lines}*/") @queries[fingerprint] = true end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shiba-0.2.3 | lib/shiba/query_watcher.rb |
shiba-0.2.2 | lib/shiba/query_watcher.rb |