{"id":13879488,"url":"https://github.com/basecamp/trashed","last_synced_at":"2025-07-20T03:31:11.973Z","repository":{"id":645043,"uuid":"287176","full_name":"basecamp/trashed","owner":"basecamp","description":"Tell StatsD about request time, GC, objects and more. Latest Rails 4 and Ruby 2.1 support, and ancient Rails 2 and Ruby 1.8 support.","archived":false,"fork":false,"pushed_at":"2022-01-31T21:53:52.000Z","size":70,"stargazers_count":194,"open_issues_count":2,"forks_count":25,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-07-10T16:09:42.936Z","etag":null,"topics":["instrument","rack","ruby","statsd"],"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/basecamp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-08-25T01:39:34.000Z","updated_at":"2025-06-01T03:25:54.000Z","dependencies_parsed_at":"2022-07-05T05:31:26.468Z","dependency_job_id":null,"html_url":"https://github.com/basecamp/trashed","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/basecamp/trashed","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basecamp%2Ftrashed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basecamp%2Ftrashed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basecamp%2Ftrashed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basecamp%2Ftrashed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/basecamp","download_url":"https://codeload.github.com/basecamp/trashed/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basecamp%2Ftrashed/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265521489,"owners_count":23781521,"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":["instrument","rack","ruby","statsd"],"created_at":"2024-08-06T08:02:22.621Z","updated_at":"2025-07-20T03:31:11.947Z","avatar_url":"https://github.com/basecamp.png","language":"Ruby","readme":"## Trashed\n# Keep an eye on resource usage.\n\n\n - Sends per-request object counts, heap growth, GC time, and more to StatsD.\n - Sends snapshots of resource usage, e.g. live String objects, to StatsD.\n - Supports new stuff: Rails 5.1 and latest Ruby 2.x features.\n - Supports old stuff: Rails 2/3/4, Ruby 1.9+, REE, Ruby 1.8 with RubyBench patches.\n\n## Setup\n\n### Rails 5\n\nOn Rails 5 (and Rails 3 and 4), add this to the top of `config/application.rb`:\n\n    require 'trashed/railtie'\n\nAnd in the body of your app config:\n\n    module YourApp\n      class Application \u003c Rails::Application\n        config.trashed.statsd = YourApp.statsd\n\n\n### Rails 2\n\nOn Rails 2, add the middleware to `config/environment.rb`:\n\n    Rails::Initializer.run do |config|\n      reporter = Trashed::Reporter.new\n      reporter.logger = Rails.logger\n      reporter.statsd = YourApp.statsd\n\n      config.middleware.use Trashed::Rack, reporter\n    end\n\n\n### Custom dimensions\n\nYou probably want stats per controller, action, right?\n\nSet a `#timing_dimensions` lambda to return a list of dimensions to\nqualify per-request measurements like time elapsed, GC time, objects\nallocated, etc.\n\nFor example:\n```ruby\nconfig.trashed.timing_dimensions = -\u003e(env) do\n  # Rails 3, 4, and 5, set this. Other Rack endpoints won't have it.\n  if controller = env['action_controller.instance']\n    name    = controller.controller_name\n    action  = controller.action_name\n    format  = controller.rendered_format || :none\n    variant = controller.request.variant || :none  # Rails 4.1+ only!\n\n    [ :All,\n      :\"Controllers.#{name}\",\n      :\"Actions.#{name}.#{action}.#{format}+#{variant}\" ]\n  end\nend\n```\n\nResults in metrics like:\n```\nYourNamespace.All.Time.wall\nYourNamespace.Controllers.SessionsController.Time.wall\nYourNamespace.Actions.SessionsController.index.json+phone.Time.wall\n```\n\n\nSimilarly, set a `#gauge_dimensions` lambda to return a list of dimensions to\nqualify measurements which gauge current state, like heap slots used or total\nnumber of live String objects.\n\nFor example:\n\n```ruby\nconfig.trashed.gauge_dimensions = -\u003e(env) {\n  [ :All,\n    :\"Stage.#{Rails.env}\",\n    :\"Hosts.#{`hostname -s`.chomp}\" ]\n}\n```\n\nResults in metrics like:\n```\nYourNamespace.All.Objects.T_STRING\nYourNamespace.Stage.production.Objects.T_STRING\nYourNamespace.Hosts.host-001.Objects.T_STRING\n```\n\n\n### Version history\n\n*3.2.8* (January 31, 2022)\n\n* REE: Fix that GC.time is reported in microseconds instead of milliseconds\n\n*3.2.7* (November 8, 2017)\n\n* Ruby 1.8.7 compatibility\n\n*3.2.6* (June 21, 2017)\n\n* Mention Rails 5 support\n\n*3.2.5* (Feb 26, 2015)\n\n* Support Ruby 2.2 GC.stat naming, avoiding 2.1 warnings\n\n*3.2.4* (July 25, 2014)\n\n* Fix compatibility with Rails 3.x tagged logging - @calavera\n\n*3.2.3* (June 23, 2014)\n\n* Report CPU/Idle time in tenths of a percent\n\n*3.2.2* (March 31, 2014)\n\n* Reduce default sampling rates.\n* Stop gauging all GC::Profiler data. Too noisy.\n* Report gauge readings as StatsD timings.\n* Support providing a Statsd::Batch since using Statsd#batch\n  results in underfilled packets at low sample rates.\n* Fix bug with sending arrays of timings to StatsD.\n* Record GC timings in milliseconds.\n\n*3.1.0* (March 30, 2014)\n\n* Report percent CPU/idle time: Time.pct.cpu and Time.pct.idle.\n* Measure out-of-band GC count, time, and stats. Only meaningful for\n  single-threaded servers like Unicorn. But then again so is per-request\n  GC monitoring.\n* Support @tmm1's GC::OOB (https://github.com/tmm1/gctools).\n* Measure time between GCs.\n* Spiff up logger reports with more timings.\n* Support Rails log tags on logged reports.\n* Allow instruments' #start to set timings/gauges.\n\n*3.0.1* (March 30, 2014)\n\n* Sample requests to instrument based on StatsD sample rate.\n\n*3.0.0* (March 29, 2014)\n\n* Support new Ruby 2.0 and 2.1 GC stats.\n* Gauge GC details with GC::Profiler.\n* Performance rework. Faster, fewer allocations.\n* Rework counters and gauges as instruments.\n* Batch StatsD messages to decrease overhead on the server.\n* Drop NewRelic samplers.\n\n*2.0.5* (December 15, 2012)\n\n* Relax outdated statsd-ruby dependency.\n\n*2.0.0* (December 1, 2011)\n\n* Rails 3 support.\n* NewRelic samplers.\n\n*1.0.0* (August 24, 2009)\n\n* Initial release.\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasecamp%2Ftrashed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasecamp%2Ftrashed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasecamp%2Ftrashed/lists"}