{"id":13747333,"url":"https://github.com/brunofacca/active-record-query-trace","last_synced_at":"2026-10-19T17:42:25.316Z","repository":{"id":54795979,"uuid":"1901866","full_name":"brunofacca/active-record-query-trace","owner":"brunofacca","description":"Rails plugin that logs/displays a backtrace of all SQL queries executed by Active Record","archived":false,"fork":false,"pushed_at":"2026-01-20T23:44:19.000Z","size":140,"stargazers_count":1009,"open_issues_count":0,"forks_count":74,"subscribers_count":7,"default_branch":"master","last_synced_at":"2026-10-05T10:42:38.164Z","etag":null,"topics":["activerecord","backtrace","ruby","ruby-on-rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brunofacca.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2011-06-15T18:36:10.000Z","updated_at":"2026-09-29T17:55:09.000Z","dependencies_parsed_at":"2024-06-18T14:02:33.714Z","dependency_job_id":"5f4dac06-0481-44f3-8ead-8595faf783e4","html_url":"https://github.com/brunofacca/active-record-query-trace","commit_stats":{"total_commits":92,"total_committers":28,"mean_commits":"3.2857142857142856","dds":0.7934782608695652,"last_synced_commit":"8f0f586cf22ac202b352459f94bce9c08e31bff8"},"previous_names":["ruckus/active-record-query-trace"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/brunofacca/active-record-query-trace","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunofacca%2Factive-record-query-trace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunofacca%2Factive-record-query-trace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunofacca%2Factive-record-query-trace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunofacca%2Factive-record-query-trace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brunofacca","download_url":"https://codeload.github.com/brunofacca/active-record-query-trace/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunofacca%2Factive-record-query-trace/sbom","scorecard":{"id":255320,"data":{"date":"2025-08-11","repo":{"name":"github.com/brunofacca/active-record-query-trace","commit":"adfd8403853c3ed34a3784e750b69d2f5317ba03"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.7,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":5,"reason":"Found 4/8 approved changesets -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: MIT-LICENSE:0","Info: FSF or OSI recognized license: MIT License: MIT-LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 28 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T09:34:00.677Z","repository_id":54795979,"created_at":"2025-08-17T09:34:00.677Z","updated_at":"2025-08-17T09:34:00.677Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":344872684,"owners_count":38363794,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-10-03T21:59:58.778Z","status":"online","status_checked_at":"2026-10-19T02:00:06.414Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activerecord","backtrace","ruby","ruby-on-rails"],"created_at":"2024-08-03T06:01:25.353Z","updated_at":"2026-10-19T17:42:25.311Z","avatar_url":"https://github.com/brunofacca.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"Displays a backtrace for each query in Rails' development console and log.\nAllows you to track down where queries are executed in your application.\nUseful for performance optimizations and for finding where to start when making\nchanges to a large application.\n\nWhen enabled, every query will be logged like:\n\n```\nD, [2019-03-03T19:50:41.061115 #25560] DEBUG -- : User Load (0.1ms)  SELECT \"users\".* FROM \"users\"\nD, [2019-03-03T19:50:41.062492 #25560] DEBUG -- : Query Trace:\n      app/models/concerns/is_active.rb:11:in `active?'\n      app/models/user.rb:67:in `active?'\n      app/decorators/concerns/status_methods.rb:42:in `colored_status'\n      app/views/shared/companies/_user.html.slim:28:in `block in _app_views_users_html_slim___2427456029761612502_70304705622200'\n      app/views/shared/companies/_user.html.slim:27:in `_app_views_users_html_slim___2427456029761612502_70304705622200'\n```\n\n## Requirements\n- Ruby \u003e= 2.7;\n- Rails 6.0, 6.1, or 7.\n\n## Usage\n\n1. Add the following to your Gemfile:\n   ```ruby\n   group :development do\n     gem 'active_record_query_trace'\n   end\n   ```\n\n2. Create an initializer such as `config/initializers/active_record_query_trace.rb`\nto enable the gem. If you want to customize how the gem behaves, you can add any\ncombination of the following [options](#options) to the initializer as well.\n\n    ```ruby\n    if Rails.env.development?\n      ActiveRecordQueryTrace.enabled = true\n      # Optional: other gem config options go here\n    end\n    ```\n\n3. Restart the Rails development server.\n\n## Options\n\n#### Backtrace level\nThere are three levels of debug.\n\n- `:app` - includes only application trace lines (files in the `Rails.root` directory);\n- `:rails` - includes all trace lines except the ones from the application (all files except those in `Rails.root`).\n- `:full` - full backtrace (includes all files), useful for debugging gems.\n\n```ruby\nActiveRecordQueryTrace.level = :app # default\n```\n\nIf you need more control you can provide a custom backtrace cleaner using the `:custom` level. For example:\n\n```ruby\nActiveRecordQueryTrace.level = :custom\nrequire \"rails/backtrace_cleaner\"\nActiveRecordQueryTrace.backtrace_cleaner = Rails::BacktraceCleaner.new.tap do |bc|\n  bc.remove_filters!\n  bc.remove_silencers!\n  bc.add_silencer { |line| line =~ /\\b(active_record_query_trace|active_support|active_record|another_gem)\\b/ }\nend\n```\n\nIt's not necessary to create an instance of `Rails::BacktraceCleaner`, you can use any object responding to `#clean` or even\na lambda/proc:\n\n```ruby\nActiveRecordQueryTrace.backtrace_cleaner = -\u003e(trace) {\n  trace.reject { |line| line =~ /\\b(active_record_query_trace|active_support|active_record|another_gem)\\b/ }\n}\n```\n\n#### Display the trace only for read or write queries\nYou can choose to display the backtrace only for DB reads, writes or both.\n\n- `:all` - display backtrace for all queries;\n- `:read` - display backtrace only for DB read operations (SELECT);\n- `:write` - display the backtrace only for DB write operations (INSERT, UPDATE, DELETE).\n\n```ruby\nActiveRecordQueryTrace.query_type = :all # default\n```\n\n#### Suppress DB read queries\nIf set to `true`, this option will suppress all log lines generated by DB\nread (SELECT) operations, leaving only the lines generated by DB write queries\n(INSERT, UPDATE, DELETE). **Beware, the entire log line is suppressed, not only\nthe backtrace.** Useful to reduce noise in the logs (e.g., N+1 queries) when you\nonly care about queries that write to the DB.\n\n```ruby\nActiveRecordQueryTrace.suppress_logging_of_db_reads = false # default\n```\n\n#### Ignore cached queries\nBy default, a backtrace will be logged for every query, even cached queries that\ndo not actually hit the database. You might find it useful not to print the backtrace\nfor cached queries:\n\n```ruby\nActiveRecordQueryTrace.ignore_cached_queries = true # Default is false.\n```\n\n#### Limit the number of lines in the backtrace\nIf you are working with a large app, you may wish to limit the number of lines\ndisplayed for each query.  If you set `level` to `:full`, you might want to set\n`lines` to `0` so you can see the entire trace.\n\n```ruby\nActiveRecordQueryTrace.lines = 10 # Default is 5. Setting to 0 includes entire trace.\n```\n\n#### Colorize the backtrace\nTo colorize the output:\n\n```ruby\nActiveRecordQueryTrace.colorize = false           # No colorization (default)\nActiveRecordQueryTrace.colorize = :light_purple   # Colorize in specific color\n```\n\nValid colors are: `:black`, `:red`, `:green`, `:brown`, `:blue`, `:purple`, `:cyan`,\n`:gray`, `:dark_gray`, `:light_red`, `:light_green`, `:yellow`, `:light_blue`,\n`:light_purple`, `:light_cyan`, `:white`.\n\n## Authors\n\n- **Cody Caughlan** - Original author.\n- **Bruno Facca** - Current maintainer. [LinkedIn](https://www.linkedin.com/in/brunofacca/)\n\n## Contributing\n\n#### Bug reports\n\nPlease use the issue tracker to report any bugs.\n\n#### Test environment\n\nThis gem uses RSpec for testing. You can run the test suite by executing the\n`rspec` command. It has a decent test coverage and the test suite takes less than\na second to run as it uses an in-memory SQLite DB.\n\n#### Developing\n\n1. Create an issue and describe your idea\n2. Fork it\n3. Create your feature branch (`git checkout -b my-new-feature`)\n4. Implement your changes;\n5. Run the test suite (`rspec`)\n6. Commit your changes (`git commit -m 'Add some feature'`)\n7. Publish the branch (`git push origin my-new-feature`)\n8. Create a Pull Request\n\n## License\n\nReleased under the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunofacca%2Factive-record-query-trace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrunofacca%2Factive-record-query-trace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunofacca%2Factive-record-query-trace/lists"}