Repository navigation
Add barnes for Heroku Ruby Language Metrics - #7298
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the
barnesgem (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 callsBarnes.startat boot, which covers Puma's current single mode (noworkersinconfig/puma.rb).config/puma.rb: abefore_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_URLis unset (local dev, CI) and on one-offrun.*dynos.After merge (manual, in Heroku)
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 bashand thenBARNES_DEBUG=1 DYNO=web.1 bundle exec pumaand check that the output includespool.capacity.Verified locally
standardrbpasses onGemfileandconfig/puma.rbconfig/puma.rbloads throughPuma::ConfigurationBarnes::Railtieis loaded🤖 Generated with Claude Code