Active Record Query Trace

screenshot of Active Record Query Trace

Rails plugin that logs/displays a backtrace of all SQL queries executed by Active Record

Overview

If you're a Rails developer looking to optimize your application's performance, you might want to check out a gem that provides detailed backtraces for each query in the development console and log. This powerful tool enables you to identify where queries are executed throughout your application, allowing you to make informed decisions about performance enhancements and changes in larger codebases. By logging every query, it becomes much easier to pinpoint issues and manage the complexities within your Rails projects.

This gem is particularly attractive to developers who want a straightforward way to enhance the debugging process. Whether you're using Rails versions 6.0, 6.1, or 7, with Ruby version 2.7 or above, integrating this gem into your workflow can lead to significant improvements in tracking database interactions.

Features

  • Backtrace Logging: Automatically logs a backtrace for all queries, giving you insight into where each query is executed within your application’s code.

  • Customizable Backtrace Levels: Choose between different levels of backtrace detail: :app, :rails, or :full, allowing for tailored debugging experiences.

  • Query Type Filtering: Set options to log backtraces only for specific query types, such as reads, writes, or both, helping reduce log noise.

  • Suppress DB Reads: Optionally suppress all log lines generated by database read operations, focusing your attention on write queries that really matter.

  • Cached Query Handling: Configure the gem to ignore backtraces for cached queries, helping to declutter logs when database hits aren't occurring.

  • Line Limit Control: Limit how many lines of backtrace are displayed to make it manageable when dealing with extensive applications.

  • Colorized Output: Improve readability by colorizing the backtrace output, making it easier to distinguish different parts of your logs.

  • Tested with RSpec: Benefit from a robust testing framework with good coverage, ensuring reliability as you implement this tool in your projects.