
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
(DEPRECATED use active-record-query-count instead)
QueryTracker
is a Ruby gem designed to help you track and analyze SQL queries executed by your ActiveRecord models. By subscribing to ActiveSupport notifications, it provides detailed insights into the queries being run, including the tables involved and the locations in your code where the queries are generated.
There are three things this gem allows you to do
Add this line to your application's Gemfile:
gem 'query_tracker'
And then execute:
bundle install
Or install it yourself as:
gem install query_tracker
There are four ways of using this gem:
require 'query_tracker'
QueryTracker.start_with_block(printer: :html) do
# your code goes here
end
this will open up a html table with the SQL stats of your code
require 'query_tracker'
QueryTracker.start_recording
# your code goes here
QueryTracker.end_recording(printer: :html)
require 'query_tracker'
QueryTracker.compare do |bench|
bench.code('script1') do
end
bench.code('script2') do
end
bench.compare!
end
this will open up a graph comparing the quantity of SQL of the two codes
config/development.rb
or the initializer of the application. config.after_initialize do
QueryTracker.configure do |configuration|
configuration.enable_middleware = true
end
end
There are two ways of displaying the collected queries data, :console
and :html
, to select one pass the printer argument to start_with_block
o end_recording
methods.
If you use html
with WSL enviroment, you need to set on your enviroments variables the WSL_DISTRIBUTION
that you are using, so the dependency Launchy work as expected.
When visualizing the html table or the console output, tables with less than ignore_table_count
will not be shown. Also, the ammount of locations to show is given by max_locations_per_table
config.after_initialize do
QueryTracker.configure do |configuration|
configuration.ignore_table_count = 1
configuration.max_locations_per_table = 4
end
end
end
After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
to run the tests.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/query_tracker. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the QueryTracker project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that query_tracker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.