{"id":15048355,"url":"https://github.com/github/marginalia","last_synced_at":"2026-01-10T07:21:41.510Z","repository":{"id":37539092,"uuid":"13387595","full_name":"github/marginalia","owner":"github","description":"Attach comments to ActiveRecord's SQL queries","archived":true,"fork":true,"pushed_at":"2013-10-07T18:18:10.000Z","size":124,"stargazers_count":8,"open_issues_count":0,"forks_count":5,"subscribers_count":20,"default_branch":"master","last_synced_at":"2024-09-25T21:10:55.802Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"basecamp/marginalia","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/github.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-07T15:30:30.000Z","updated_at":"2024-07-31T03:23:12.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/github/marginalia","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fmarginalia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fmarginalia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fmarginalia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fmarginalia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/github","download_url":"https://codeload.github.com/github/marginalia/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219876581,"owners_count":16554769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-09-24T21:11:05.456Z","updated_at":"2025-10-04T08:31:24.226Z","avatar_url":"https://github.com/github.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# marginalia [![Build Status](https://secure.travis-ci.org/37signals/marginalia.png?branch=master)](http://travis-ci.org/37signals/marginalia)\n\nAttach comments to your ActiveRecord queries. By default, it adds the application, controller, and action names as a\ncomment at the end of each query.\n\nThis helps when searching log files for queries, and seeing where slow queries came from.\n\nFor example, once enabled, your logs will look like:\n\n    Account Load (0.3ms)  SELECT `accounts`.* FROM `accounts` \n    WHERE `accounts`.`queenbee_id` = 1234567890 \n    LIMIT 1 \n    /*application:BCX,controller:project_imports,action:show*/\n\nYou can also use these query comments along with a tool like [pt-query-digest](http://www.percona.com/doc/percona-toolkit/2.1/pt-query-digest.html#query-reviews) \nto automate identification of controllers and actions that are hotspots forslow queries.\n\nThis gem was created at 37signals. You can read more about how we use it [on\nour blog](http://37signals.com/svn/posts/3130-tech-note-mysql-query-comments-in-rails).\n\nThis has been tested and used in production with both the mysql and mysql2 gems, \ntested on Rails 2.3.5 through 3.2-stable. It has also been tested for sqlite3 and postgres.\n\nPatches are welcome for other database adapters. \n\n**The preferred way to get support is to send an email to\nmarginalia@librelist.com. Github issues\nand pull requests will be checked occassionally, but email is the\nfastest way to get help.**\n\n## Installation\n\n### For Rails 3.x:\n\n    # Gemfile\n    gem 'marginalia'\n    \n    #config/application.rb\n    require 'marginalia/railtie'\n\n\n### For Rails 2.x:\n\nIf using cached externals, add to your `config/externals.yml` file.\n\nOr, if your prefer using `config.gem`, you can use:\n\n    config.gem 'marginalia'\n\nFinally, if bundled, you'll need to manually run the initialization step in an\ninitializer, e.g.:\n    \n    # Gemfile\n    gem 'marginalia', :require =\u003e false\n\n    #config/initializers/marginalia.rb\n    require 'marginalia'\n    Marginalia::Railtie.insert\n\n### Customization\nOptionally, you can set the application name shown in the log like so in an initializer (e.g. `config/initializers/marginalia.rb`):\n\n    Marginalia.application_name = \"BCX\"\n\nFor Rails 3 applications, the name will default to your Rails application name.\nFor Rails 2 applications, \"rails\" is used as the default application name.\n\nYou can also configure the components of the comment that will be appended,\nby setting `Marginalia::Comment.components`. By default, this is set to:\n\n    Marginalia::Comment.components = [:application, :controller, :action]\n\nWhich results in a comment of\n`application:#{application_name},controller:#{controller.name},action:#{action_name}`.\n\nYou can re-order or remove these components. You can also add additional\ncomment components of your desire by defining new module methods for\n`Marginalia::Comment` which return a string. For example:\n\n    module Marginalia\n      module Comment\n        def self.mycommentcomponent\n          \"TEST\"\n        end\n      end\n    end\n\n    Marginalia::Comment.components = [:application, :mycommentcomponent]\n\nWhich will result in a comment like\n`application:#{application_name},mycommentcomponent:TEST`\nThe calling controller is available to these methods via `@controller`.\n\nMarginalia ships with `:application`, `:controller`, and `:action` enabled by\ndefault. In addition, implementation is provided for:\n  * `:line` (for file and line number calling query). :line supports\n    a configuration by setting a regexp in `Marginalia::Comment.lines_to_ignore`\n    to exclude parts of the stacktrace from inclusion in the line comment.\n\nPull requests for other included comment components are welcome.\n\n## Contributing\n\nStart by bundling and creating the test database:\n\n    bundle\n    rake db:create\n\nThen, running `rake` will run the tests on both the `mysql` and `mysql2` adapters:\n\n    rake\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub%2Fmarginalia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgithub%2Fmarginalia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub%2Fmarginalia/lists"}