コンテンツにスキップ

Honeybadger Cheat Sheet

Overview

Honeybadger is an application health monitoring platform built for developers, providing exception tracking, uptime monitoring, and scheduled job check-ins in a single service. It focuses on delivering noise-free error reporting with smart grouping, detailed context, and fast notifications so teams can quickly identify and fix problems.

Honeybadger supports Ruby, JavaScript, Python, Go, PHP, Java, Elixir, and .NET with lightweight SDKs. It features unlimited team members, deploy tracking, GitHub and GitLab integration, breadcrumbs, and a clean interface designed to minimize alert fatigue. The platform offers both cloud-hosted and on-premise deployment options.

Installation

# Ruby
gem install honeybadger

# Node.js
npm install @honeybadger-io/js

# React
npm install @honeybadger-io/react

# Python
pip install honeybadger

# Go
go get github.com/honeybadger-io/honeybadger-go

# PHP
composer require honeybadger-io/honeybadger-php

# Elixir - add to mix.exs
# {:honeybadger, "~> 0.21"}

Core Configuration

Ruby / Rails

# config/initializers/honeybadger.rb
Honeybadger.configure do |config|
  config.api_key = ENV["HONEYBADGER_API_KEY"]
  config.revision = `git rev-parse HEAD`.strip
  config.env = Rails.env
end

# Or via honeybadger.yml
# api_key: '<%= ENV["HONEYBADGER_API_KEY"] %>'
# env: '<%= Rails.env %>'

Node.js

const Honeybadger = require("@honeybadger-io/js");

Honeybadger.configure({
  apiKey: process.env.HONEYBADGER_API_KEY,
  environment: process.env.NODE_ENV,
  revision: process.env.GIT_SHA,
});

// Express middleware
app.use(Honeybadger.requestHandler);
// ... routes
app.use(Honeybadger.errorHandler);

Python / Django

import honeybadger

honeybadger.configure(
    api_key=os.environ.get("HONEYBADGER_API_KEY"),
    environment="production",
)

# Django settings.py
INSTALLED_APPS = [
    "honeybadger.contrib.DjangoHoneybadgerMiddleware",
    # ... other apps
]

HONEYBADGER = {
    "API_KEY": os.environ.get("HONEYBADGER_API_KEY"),
}

Manual Error Reporting

# Ruby
begin
  risky_operation
rescue => e
  Honeybadger.notify(e, context: {
    user_id: current_user.id,
    action: "payment_processing"
  })
end

# Notify with a string
Honeybadger.notify("Something unexpected happened",
  context: { order_id: 123 },
  tags: "payments, critical"
)
// JavaScript
try {
  processPayment(order);
} catch (error) {
  Honeybadger.notify(error, {
    context: { orderId: order.id, amount: order.total },
    tags: ["payments", "critical"],
  });
}

// Notify with just a message
Honeybadger.notify("API rate limit exceeded", {
  name: "RateLimitError",
  context: { endpoint: "/api/users", limit: 1000 },
});
# Python
try:
    risky_operation()
except Exception as e:
    honeybadger.notify(e, context={
        "user_id": "123",
        "action": "data_export",
    })

Context and Metadata

# Ruby - Set global context
Honeybadger.context({
  user_id: current_user.id,
  account: current_user.account.name,
  plan: current_user.account.plan,
})

# Clear context
Honeybadger.context.clear!
// JavaScript - Set context
Honeybadger.setContext({
  userId: user.id,
  email: user.email,
  plan: "premium",
});

// Reset context
Honeybadger.resetContext();

// Context for a single notification
Honeybadger.notify(error, {
  context: { transactionId: "txn_123" },
});
// Add custom breadcrumbs
Honeybadger.addBreadcrumb("User action", {
  metadata: { button: "checkout", cartItems: 3 },
  category: "custom",
});

// Automatic breadcrumbs include:
// - Console messages
// - XHR/Fetch requests
// - Click events
// - Navigation events
# Ruby breadcrumbs
Honeybadger.add_breadcrumb("Cache miss", metadata: {
  key: "user:123:profile",
  store: "redis"
})

Deploy Tracking

# Notify Honeybadger of a deploy
bundle exec honeybadger deploy \
  --environment production \
  --revision $(git rev-parse HEAD) \
  --repository https://github.com/org/repo \
  --user $(whoami)

# Via API
curl -X POST https://api.honeybadger.io/v1/deploys \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "deploy": {
      "environment": "production",
      "revision": "abc123",
      "repository": "https://github.com/org/repo",
      "local_username": "deployer"
    }
  }'

Check-Ins (Cron Monitoring)

# Simple check-in after a cron job
curl https://api.honeybadger.io/v1/check_in/YOUR_CHECK_IN_ID

# Ruby - wrap a task
Honeybadger.check_in("YOUR_CHECK_IN_ID")

# In a Rake task
task :daily_cleanup do
  perform_cleanup
  Honeybadger.check_in("cleanup-check-in-id")
end
// Node.js check-in
Honeybadger.checkIn("YOUR_CHECK_IN_ID");

Advanced Usage

Custom Fingerprinting

# Ruby
Honeybadger.notify(error, fingerprint: "custom-group-key")
// JavaScript
Honeybadger.notify(error, {
  fingerprint: "payment-gateway-timeout",
});

Before Notify Hooks

Honeybadger.beforeNotify(function (notice) {
  // Filter out specific errors
  if (notice.name === "NetworkError") {
    return false; // Don't send
  }
  // Add or modify data
  notice.context.appVersion = "1.2.0";
});
# Ruby
Honeybadger.configure do |config|
  config.before_notify do |notice|
    notice.halt! if notice.error_class == "ActionController::RoutingError"
    notice.context[:build] = ENV["BUILD_NUMBER"]
  end
end

Tags

# Ruby - tag errors for filtering
Honeybadger.notify(error, tags: "billing, critical, retry")
// JavaScript
Honeybadger.notify(error, {
  tags: ["api", "timeout", "external"],
});

Ignored Exceptions

# Ruby
Honeybadger.configure do |config|
  config.ignored_exceptions = [
    "ActionController::RoutingError",
    "ActiveRecord::RecordNotFound",
    "ActionController::InvalidAuthenticityToken",
  ]
end

Configuration

# honeybadger.yml (Ruby)
api_key: '<%= ENV["HONEYBADGER_API_KEY"] %>'
env: '<%= Rails.env %>'
report_data: true
revision: '<%= `git rev-parse HEAD`.strip %>'

development:
  report_data: false

production:
  report_data: true

# Ignore specific classes
exceptions:
  ignore:
    - "ActiveRecord::RecordNotFound"
    - "ActionController::RoutingError"
# Environment variables (all SDKs)
export HONEYBADGER_API_KEY="your-api-key"
export HONEYBADGER_ENV="production"
export HONEYBADGER_REVISION="abc123def"
export HONEYBADGER_REPORT_DATA=true

Troubleshooting

IssueSolution
Errors not appearingVerify API key; check report_data is true for current env
Duplicate errorsReview custom fingerprinting; check for multiple SDK inits
Missing contextEnsure setContext is called before the error occurs
Check-ins not workingVerify check-in ID; ensure the HTTP request succeeds
Too many notificationsConfigure ignored exceptions; use before_notify to filter
Source maps not resolvingUpload source maps and ensure revision matches
Deploy not trackedVerify API key has deploy notification permissions
Breadcrumbs emptyEnsure breadcrumb collection is enabled in configuration