basecamp/marginalia
60.7
Adequate · 19 September 2026
340
lines of production code
Ruby
primary language
1
measurement over time
What this system is
Marginalia is a Ruby gem that automatically annotates SQL queries executed by ActiveRecord with contextual metadata, such as the application name, controller, and action. It extends this instrumentation to background jobs processed via ActiveJob and Sidekiq, enabling easier debugging and profiling of database activity across web requests and asynchronous tasks. The library supports multiple database adapters and provides configurable components for customizing the query comments.
Features
Initial release of Marginalia SQL query annotation library
This change introduces the Marginalia gem, which automatically appends comments to SQL queries executed by ActiveRecord and Sidekiq. The library instruments database methods (such as execute, exec\_query, exec\_delete, and exec\_update) to inject contextual information like the application name, controller, and action into the query comments. It also supports inline annotations via a new API (Marginalia.with\_annotation) and handles compatibility across different database adapters (MySQL2, PostgreSQL) and Rails versions, including fixes for Ruby 2.7 deprecation warnings.
lib · high confidence
Marginalia query comment instrumentation now supports ActiveJob and Sidekiq
The library now automatically appends query comments for background jobs processed via ActiveJob and Sidekiq, in addition to standard web requests. This is achieved by injecting instrumentation into ActiveJob's \around\_perform\ callback and adding a Sidekiq server middleware, ensuring that database queries executed during job processing are annotated with job class information for easier debugging and profiling.
lib/marginalia · high confidence
Behavioural changes
Migration to Marginalia gem and removal of legacy query commenter
The repository has been restructured to adopt the 'marginalia' gem for attaching query comments to ActiveRecord logs, replacing the previous custom \QueryComments\ module. The legacy \query\_commenter.rb\ file has been removed, and the project now includes a new README, Rakefile, and configuration files (\.gitignore\, \.ruby-version\, \LICENSE\) that document the gem's features, such as customizable comment components, inline annotations, and support for multiple database adapters (MySQL, PostgreSQL, SQLite).
(repo-wide) · high confidence
Test coverage
Added comprehensive test suite for query comment functionality
Added a new test file \test/query\_comments\_test.rb\ that validates the Marginalia library's ability to annotate SQL queries with application, controller, and action metadata. The tests cover various scenarios including MySQL and PostgreSQL drivers, Rails API controllers, ActiveJob and Sidekiq integration, and configurable query components such as application name and line numbers.
test · high confidence
Dependencies
Initial release of Marginalia gem v1.11.1
This change introduces the Marginalia gem, which attaches comments to ActiveRecord queries. The package specifies runtime dependencies on Action Pack and ActiveRecord version 5.2 or higher, and includes development dependencies for testing against MySQL, PostgreSQL, and SQLite3 databases, as well as Sidekiq instrumentation support.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Baseline
- First survey — no prior run to compare against. CAI 61.
Lenses
- Code Health 100
- Architecture 69
- Maturity 49
- Readiness 59
- Security 100
Changes since last survey
- 267 commits — 246 feature/other, 21 fixes
By area
- (root) — 135 commits
- (repo) — 60 commits
- lib/marginalia — 32 commits
- lib/marginalia.rb — 17 commits
- test/query_comments_test.rb — 11 commits
- lib/query_comments.rb — 7 commits
- .github/workflows — 3 commits
- lib/query_comments — 2 commits
Notable commits
- fix: Actually fix tests in 1.8.7
- fix: Fix CI
- fix: Fix Ruby 2.7 kwargs deprecation warning
- fix: Fix error when sidekiq used as ActiveJob adapter
- fix: Fix failing master build
- fix: Fix false lines_to_ignore match on gems
- fix: Fix minitest compatibility
- fix: Fix misattributed queries on multithreaded servers
- fix: Fix missing travis services
- fix: Fix tests on 3.2.19
- fix: Fix travis buils
- fix: Fully support Rails 3.1 adaptors, fix :line info
- fix: Ignore mon_synchronize by default, which comes up as caller in Rails 5+. Fixes #70.
- fix: Merge pull request #110 from stanhu/sh-fix-ruby-2.7-warnings
- fix: Merge pull request #21 from github/fix-execute-check
- fix: Merge pull request #83 from eileencodes/fix-travis-for-marginalia-rebuild
- fix: Revert "Either instrument execute or exec_query, not both"
- fix: Revert "Test against mysql gem"
- fix: Test fixes
- fix: fix mocha import
- …and 247 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
basecamp/marginalia was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 6f9215ba654504c6520d82fbe06db5c536cbfc33 — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-13a154b7f5d1.