Skip to content

Add barnes for Heroku Ruby Language Metrics - #7298

Merged
compwron merged 1 commit into
mainfrom
heroku-ruby-metrics
Nov 1, 2026
Merged

compwron merged 1 commit into
mainfrom
heroku-ruby-metrics

Conversation

@compwron

@compwron compwron commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

What

Adds the barnes gem (1.0.1) so Heroku's Application Metrics page shows Ruby runtime charts: Puma pool usage, free memory slots, and heap object counts. See Ruby Language Metrics.

  • Gemfile / Gemfile.lock: gem "barnes", "~> 1.0". Barnes 1.0 includes a Railtie that calls Barnes.start at boot, which covers Puma's current single mode (no workers in config/puma.rb).
  • config/puma.rb: a before_worker_boot { Barnes.start } hook. It only fires in cluster mode (WEB_CONCURRENCY > 1). It's there because the reporter thread doesn't survive a fork. I used this instead of the docs' before_fork, which runs once in the Puma master, not in each worker.

Barnes does nothing when HEROKU_METRICS_URL is unset (local dev, CI) and on one-off run.* dynos.

After merge (manual, in Heroku)

heroku labs:enable "runtime-heroku-metrics" -a <app>
heroku labs:enable "ruby-language-metrics" -a <app>

Or turn on Enhanced Language Metrics and Ruby Language Metrics under Metrics → Preferences. These don't work on eco dynos. If the charts are empty after a few minutes, run heroku run bash and then BARNES_DEBUG=1 DYNO=web.1 bundle exec puma and check that the output includes pool.capacity.

Verified locally

  • standardrb passes on Gemfile and config/puma.rb
  • config/puma.rb loads through Puma::Configuration
  • The app boots and Barnes::Railtie is loaded

🤖 Generated with Claude Code

Reports GC/heap/Puma pool stats to HEROKU_METRICS_URL. The Railtie starts
it at boot (single mode); a before_worker_boot hook restarts it per worker
if Puma runs in cluster mode. Silent no-op outside Heroku.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added dependencies Touches dependency files ruby Touches Ruby code labels Nov 1, 2026
@compwron
compwron merged commit 7e6dd49 into main Nov 1, 2026
12 checks passed
@compwron
compwron deleted the heroku-ruby-metrics branch November 1, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Touches dependency files ruby Touches Ruby code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant