DEV Community

Masumi Kawasaki 💭
Masumi Kawasaki 💭

Posted on

Recommended Series for Small Rails Development Teams: Error Tracking - Honeybadger

Hello, Rails engineers! Today, I’d like to recommend Honeybadger as an error-tracking tool for small development teams working on Rails projects. Honeybadger offers ease of use and a powerful feature set that can significantly improve your development efficiency.

Why Choose Honeybadger?

  1. Simple Setup: Easy integration into Rails projects.
  2. Real-Time Alerts: Instantly notify you of critical errors.
  3. Detailed Error Information: Provides rich data like stack traces, environment variables, and parameters.
  4. Performance Monitoring: Track application performance alongside error tracking.
  5. Uptime Monitoring: Keep an eye on your app’s availability.
  6. Cron Job Monitoring: Ensure cron jobs are running smoothly.

Setup Instructions

  1. Add this to your Gemfile:
gem 'honeybadger', '~> 5.0'
Enter fullscreen mode Exit fullscreen mode
  1. Run the bundle install command:
bundle install
Enter fullscreen mode Exit fullscreen mode
  1. Execute the Honeybadger setup script:
bundle exec honeybadger install HONEYBADGER_API_KEY
Enter fullscreen mode Exit fullscreen mode

That’s all you need for basic setup!

Effective Usage

Custom Error Notifications

You can set up custom notifications for specific conditions:

begin
  # Some processing
rescue => e
  Honeybadger.notify(
    error_class: "CustomError",
    error_message: "A critical error occurred",
    context: {
      user_id: current_user.id,
      action: "important_action"
    }
  )
end
Enter fullscreen mode Exit fullscreen mode

Adding Context

Adding user or request data makes it easier to identify error causes:

class ApplicationController < ActionController::Base
  before_action :set_honeybadger_context

  private

  def set_honeybadger_context
    Honeybadger.context(
      user_id: current_user.id,
      user_email: current_user.email,
      plan: current_user.plan
    )
  end
end
Enter fullscreen mode Exit fullscreen mode

Real-Time Alerts

Error Tracker

You can configure notifications to send alerts via email, Slack, or other tools. Honeybadger integrates well with platforms like GitHub, automatically creating issues for errors. Once you fix the error and deploy the change, Honeybadger will automatically mark the issue as resolved.

Performance Monitoring

A notable feature is Insights.

insights:
  enabled: true
Enter fullscreen mode Exit fullscreen mode

By enabling this, you can monitor performance data and query it using BadgerQL, similar to a log management tool like Papertrail. However, log data fees can be high, so be mindful of this.

events:
  ignore:
    - event_type: 'sql.active_record'
Enter fullscreen mode Exit fullscreen mode

Since SQL logs can quickly consume space, disabling them can effectively save on log data costs.

Performance Dashboard

Using this information, you can create an APM-like dashboard to monitor performance trends.

APM like

Uptime Monitoring

Though a small feature, Honeybadger includes uptime monitoring. Our team migrated from Pingdom to Honeybadger's Uptime feature, simplifying our monitoring stack and reducing costs.

Cron Job Monitoring

We previously used Dead Man’s Snitch for cron job monitoring, but Honeybadger’s Check-Ins feature looks promising, and we’re considering migrating to it.

Deployment Tracking

By running this command during deployment, you can track deployments:

honeybadger deploy --environment=production --revision=$(git rev-parse HEAD) --repository=git@github.com:your/repo.git
Enter fullscreen mode Exit fullscreen mode

Summary

Honeybadger is an excellent tool for small Rails teams. Its simple setup, rich monitoring features, and ease of use significantly improve development workflows. It helps detect and resolve errors early, contributing to application stability.

Our team previously used the open-source error tracker Errbit, which worked well for catching errors and sending notifications. However, we switched to Honeybadger when Errbit's Ruby version became outdated. While we still contribute to Errbit, Honeybadger provides more stable application operations, leading to our decision to adopt it.

Top comments (0)