Back-end Engineering Articles

I write and talk about backend stuff like Ruby, Ruby On Rails, Databases, Testing, Architecture / Infrastructure / System Design, Cloud, DevOps, Backgroud Jobs, and more...

Twitter:
@daniel_moralesp

2020-02-14

Errbit - Rails Error Tracking

Error Tracking

The best tool to do this is Erribt, which is an open source gem in Rails, that is basically an app that tracks the app errors in any environment. But the vast majority of time helps to track errors in productions, staging and other important branches of the project (not so in dev or test environments).

This app is self-hosted, that means that we need a simple server to deploy it to production. It uses MongoDB, so we need to have an account with Mongo Atlas. More on the official documentation here: https://github.com/errbit/errbit. A good advantage of this gem is that we just need to create the app once and we can add any amount of apps and environments to track inside it

There are two ways to configure this gem, but none of them is easy. So we use a combined approach. The list of steps is here:

1- MongoDB Atlas


We need to have this setup. Please follow these steps, but don’t deploy to Heroku via the button “Deploy to Heroku”, because this is generating an error. The error is because of incompatibility between Heroku-20 (current release) and Ruby 2.5.1 (Ruby version used by Errbit). Link to ste steps: https://github.com/errbit/errbit/blob/master/docs/deployment/heroku.md#mongodb-atlas-setup-for-quick-deployment

2- Deploy in the Hard Way


Once you have MongoDB Atlas setup ready, follow this steps: https://github.com/errbit/errbit/blob/master/docs/deployment/heroku.md#the-hard-way

3- Gotchas


  • * You may be required to add a credit card. But that doesn't mean that the service is not free. We’ll be using free dyons
  • * Some ENV variables won’t work, and you’ll need to add it manually via Heroku app (settings/reveal config vars)
  • * Name of Env var (MONGO_URL not MONGO_URI): MONGO_URL is the correct name for this env variable
  • Inside Mongo Atlas to “Connect” the account, you need to choose for Ruby 2.4 or later and the MONGO_URL looks like this:
  • * mongodb://errbit-parso:<password>@cluster0-shard-00-00.gmsvz.mongodb.net:27017,cluster0-shard-00-01.gmsvz.mongodb.net:27017,cluster0-shard-00-02.gmsvz.mongodb.net:27017/myFirstDatabase?ssl=true&replicaSet=atlas-gy6qcz-shard-0&authSource=admin&retryWrites=true&w=majority
  • * To create the admin, you need to add a Figaro gem to the project and create these two env vars: ERRBIT_ADMIN_EMAIL and ERRBIT_ADMIN_PASSWORD. However you can also create these two variables directly in the Heroku app and add it manually. After this, you’ll need to run the seed command: “heroku run rake db:seed”