Introducing Honeybadger for Crystal

Good news, Crystal developers! We just shipped an official Crystal shard for Honeybadger. Track errors and keep your users happy.

We are excited that you can now easily plug your Crystal applications into Honeybadger. Installation and configuration are easy, and the shard provides everything you need to set up your application.

In this article, we'll cover installing Honeybadger, capturing errors in HTTP servers, manually capturing errors, and collecting context data from the Crystal Log::Context.


Update your shard.yml with the following snippet and shards install

+  honeybadger:
+    github: honeybadger-io/honeybadger-crystal

Provide your Honeybadger API key at runtime

Visit your Project Settings page on Honeybadger and find your API key. Add the following code to your application startup, and configure your API key in the environment:

Honeybadger.configure do |config|
  config.api_key = ENV["HONEYBADGER_API_KEY"]? || "API Key"
  config.environment = ENV["HONEYBADGER_ENVIRONMENT"]? || "production"

Capturing exceptions — HTTP::Server

For HTTP frameworks based on Crystal’s excellent HTTP::Server library, add the Honeybadger::Handler middleware to the server stack:

require "http/server"
require "honeybadger"

server =[, # added at the top of the stack,,"."),

server.bind_tcp "", 8080

Adding Honeybadger::Handler to the top of the server stack allows it to capture and report as many errors as possible. Any exception raised within the server stack will be captured and reported to the Honeybadger API.

Capturing exceptions — General utility

For applications which don't leverage HTTP::Server, an application-wide capture is still helpful and might look something like this:

require "honeybadger"

def run_application
rescue exception : Exception
    Honeybadger.notify exception


Log context

Crystal’s unique and powerful Log::Context system allows easily decorating log entries with helpful information like this:

user = Users.first
Log.context.set user_id:
user.send_email! { "Sent email to User##{}" }

Out of the box, Honeybadger includes the current Log::Context with exceptions reported via Honeybadger.notify — it's dead simple!

What to do next:
  1. Try Honeybadger for FREE
    Honeybadger helps you find and fix errors before your users can even report them. Get set up in minutes and check monitoring off your to-do list.
    Start free trial
    Easy 5-minute setup — No credit card required
  2. Get the Honeybadger newsletter
    Each month we share news, best practices, and stories from the DevOps & monitoring community—exclusively for developers like you.
    author photo

    Robert Carpenter

    My name is Robert Carpenter. I build web applications, automate clouds, compile and analyze data, and spend way too much time thinking about software.

    Stop wasting time manually checking logs for errors!

    Try the only application health monitoring tool that allows you to track application errors, uptime, and cron jobs in one simple platform.

    • Know when critical errors occur, and which customers are affected.
    • Respond instantly when your systems go down.
    • Improve the health of your systems over time.
    • Fix problems before your customers can report them!

    As developers ourselves, we hated wasting time tracking down errors—so we built the system we always wanted.

    Honeybadger tracks everything you need and nothing you don't, creating one simple solution to keep your application running and error free so you can do what you do best—release new code. Try it free and see for yourself.

    Start free trial
    Simple 5-minute setup — No credit card required

    Learn more

    "We've looked at a lot of error management systems. Honeybadger is head and shoulders above the rest and somehow gets better with every new release."
    — Michael Smith, Cofounder & CTO of YvesBlue

    Honeybadger is trusted by top companies like: