{"id":13416439,"url":"https://github.com/ankane/ownership","last_synced_at":"2025-11-17T14:06:14.875Z","repository":{"id":37493067,"uuid":"109635035","full_name":"ankane/ownership","owner":"ankane","description":"Code ownership for Rails","archived":false,"fork":false,"pushed_at":"2025-10-26T23:20:25.000Z","size":64,"stargazers_count":129,"open_issues_count":1,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-11-12T16:10:20.719Z","etag":null,"topics":[],"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/ankane.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2017-11-06T01:56:53.000Z","updated_at":"2025-11-04T09:48:38.000Z","dependencies_parsed_at":"2024-06-10T04:28:23.053Z","dependency_job_id":"762dde08-bfe7-42f1-b401-8f5e4aeff5b7","html_url":"https://github.com/ankane/ownership","commit_stats":{"total_commits":65,"total_committers":6,"mean_commits":"10.833333333333334","dds":"0.32307692307692304","last_synced_commit":"105460e7dd8d99e0a7640fe1faeb38767ef286a5"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/ankane/ownership","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fownership","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fownership/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fownership/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fownership/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ankane","download_url":"https://codeload.github.com/ankane/ownership/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fownership/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284558742,"owners_count":27025820,"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","status":"online","status_checked_at":"2025-11-15T02:00:06.050Z","response_time":57,"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":[],"created_at":"2024-07-30T21:00:58.866Z","updated_at":"2025-11-17T14:06:14.864Z","avatar_url":"https://github.com/ankane.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Ownership\n\nCode ownership for Rails\n\nCheck out [Scaling the Monolith](https://ankane.org/scaling-the-monolith) for other tips\n\n:tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)\n\n[![Build Status](https://github.com/ankane/ownership/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/ownership/actions)\n\n## Installation\n\nAdd this line to your application’s Gemfile:\n\n```ruby\ngem \"ownership\"\n```\n\n## Getting Started\n\nOwnership provides the ability to specify owners for different parts of the codebase. **We highly recommend owners are teams rather than individuals.** You can then use this information however you’d like, like routing errors to the correct team.\n\n## Specifying Ownership\n\n### Controllers\n\n```ruby\nclass OrdersController \u003c ApplicationController\n  owner :logistics\nend\n```\n\nYou can use any options that `before_action` supports.\n\n```ruby\nclass OrdersController \u003c ApplicationController\n  owner :logistics, only: [:index]\n  owner :customers, except: [:index]\nend\n```\n\n### Jobs\n\n```ruby\nclass SomeJob \u003c ApplicationJob\n  owner :logistics\nend\n```\n\n### Anywhere\n\n```ruby\nowner :logistics do\n  # code\nend\n```\n\n### Default\n\nYou can set a default owner with:\n\n```ruby\nOwnership.default_owner = :logistics\n```\n\n## Integrations\n\nThere are a few built-in integrations with other gems.\n\n- [Active Record](#active-record)\n- [AppSignal](#appsignal)\n- [Honeybadger](#honeybadger)\n- [Rollbar](#rollbar)\n\nYou can also add [custom integrations](#custom-integrations).\n\n### Active Record\n\nActive Record has the option to add comments to queries.\n\n```sql\nSELECT ...\n/*application:MyApp,controller:posts,action:index,owner:logistics*/\n```\n\nAdd to `config/application.rb`:\n\n```ruby\nconfig.active_record.query_log_tags_enabled = true\nconfig.active_record.query_log_tags \u003c\u003c :owner\n```\n\n### AppSignal\n\nThe [AppSignal gem integrates with Ownership](https://docs.appsignal.com/ruby/integrations/ownership.html) automatically. Error and performance samples in AppSignal will be tagged with the specified owner.\n\nYou can set AppSignal's [`ownership_set_namespace` configuration option](https://docs.appsignal.com/ruby/configuration/options.html#option-ownership_set_namespace) to `true` in order to use the specified owner as an AppSignal namespace, which allows you to easily list performance actions and error incidents for each namespace.\n\n### Honeybadger\n\n[Honeybadger](https://github.com/honeybadger-io/honeybadger-ruby) tracks exceptions. This integration makes it easy to send exceptions to different projects based on the owner. We recommend having a project for each team.\n\n```ruby\nOwnership::Honeybadger.api_keys = {\n  logistics: \"token1\",\n  customers: \"token2\"\n}\n```\n\nAlso works with a proc\n\n```ruby\nOwnership::Honeybadger.api_keys = -\u003e(owner) { ENV[\"#{owner.to_s.upcase}_HONEYBADGER_API_KEY\"] }\n```\n\n### Rollbar\n\n[Rollbar](https://github.com/rollbar/rollbar-gem) tracks exceptions. This integration makes it easy to send exceptions to different projects based on the owner. We recommend having a project for each team.\n\n```ruby\nOwnership::Rollbar.access_token = {\n  logistics: \"token1\",\n  customers: \"token2\"\n}\n```\n\nAlso works with a proc\n\n```ruby\nOwnership::Rollbar.access_token = -\u003e(owner) { ENV[\"#{owner.to_s.upcase}_ROLLBAR_ACCESS_TOKEN\"] }\n```\n\nFor version 3.1+ of the `rollbar` gem, add to `config/initializers/rollbar.rb`:\n\n```ruby\nconfig.use_payload_access_token = true\n```\n\n## Custom Integrations\n\nYou can define a custom block of code to run with:\n\n```ruby\nOwnership.around_change = proc do |owner, block|\n  puts \"New owner: #{owner}\"\n  block.call\n  puts \"Done\"\nend\n```\n\nExceptions that bubble up from an `owner` block have the owner, which your exception reporting library can use.\n\n```ruby\nbegin\n  owner :logistics do\n    raise \"error\"\n  end\nrescue =\u003e e\n  puts e.owner # :logistics\nend\n```\n\n## Other Useful Tools\n\n- [GitHub Code Owners](https://github.com/blog/2392-introducing-code-owners) for code reviews\n\n## Thanks\n\nThanks to [Nick Elser](https://github.com/nickelser) for creating this pattern.\n\n## History\n\nView the [changelog](https://github.com/ankane/ownership/blob/master/CHANGELOG.md)\n\n## Contributing\n\nEveryone is encouraged to help improve this project. Here are a few ways you can help:\n\n- [Report bugs](https://github.com/ankane/ownership/issues)\n- Fix bugs and [submit pull requests](https://github.com/ankane/ownership/pulls)\n- Write, clarify, or fix documentation\n- Suggest or add new features\n\nTo get started with development and testing:\n\n```sh\ngit clone https://github.com/ankane/ownership.git\ncd ownership\nbundle install\nbundle exec rake test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Fownership","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fankane%2Fownership","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Fownership/lists"}