Skip to content

Commit

Permalink
Adds barnes gem to collect Ruby Language Metrics
Browse files Browse the repository at this point in the history
Why are these changes being introduced:

* This adds a few additional useful metrics in our heroku dashboard
  for stage/prod level apps (it doesn't work in eco dynos so pr
  builds will not collect this data)
* see also:
  https://devcenter.heroku.com/articles/language-runtime-metrics-ruby

Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/TCO-78

How does this address that need:

* adds barnes gem
* configures puma per heroku docs to enable barnes
* updates app.json to add the metrics collection to PR builds even
  though they probably won't do anything in our eco dynos

Document any side effects to this change:

None really, but the only other rails app we do this with is Bento.
Other apps should likely get updated to collect this data if we don't
see any side effects.
  • Loading branch information
JPrevost committed Oct 17, 2024
1 parent 78dd771 commit ae19c67
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ git_source(:github) do |repo_name|
"https://github.com/#{repo_name}.git"
end

# GC Statsd Reporter [https://github.com/heroku/barnes]
gem 'barnes'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', require: false

Expand Down
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ GEM
rake (>= 10.4, < 14.0)
ast (2.4.2)
attr_required (1.0.2)
barnes (0.0.9)
multi_json (~> 1)
statsd-ruby (~> 1.1)
base64 (0.2.0)
bcrypt (3.1.20)
bigdecimal (3.1.8)
Expand Down Expand Up @@ -230,6 +233,7 @@ GEM
mini_mime (1.1.5)
minitest (5.25.1)
msgpack (1.7.2)
multi_json (1.15.0)
mutex_m (0.2.0)
net-http (0.4.1)
uri
Expand Down Expand Up @@ -409,6 +413,7 @@ GEM
sqlite3 (1.7.3-arm64-darwin)
sqlite3 (1.7.3-x86_64-darwin)
sqlite3 (1.7.3-x86_64-linux)
statsd-ruby (1.5.0)
stimulus-rails (1.3.4)
railties (>= 6.0.0)
stringex (2.8.6)
Expand Down Expand Up @@ -469,6 +474,7 @@ PLATFORMS
DEPENDENCIES
administrate (~> 0.20.1)
annotate
barnes
bootsnap
cancancan
capybara
Expand Down
3 changes: 3 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"buildpacks": [
{
"url": "heroku/ruby"
},
{
"url": "heroku/metrics"
}
]
}
8 changes: 8 additions & 0 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@

# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart

require 'barnes'

before_fork do
# worker specific setup

Barnes.start # Must have enabled worker mode for this to block to be called
end

0 comments on commit ae19c67

Please sign in to comment.