---
title: Tracking Ruby errors on AWS Lambda
description: Honeybadger monitors your Ruby AWS Lambda functions for errors and exceptions so that you can fix them wicked fast.
url: https://docs.honeybadger.io/lib/ruby/integration-guides/aws-lambda-exception-tracking/
---

**Typical installation time:** 1 minute

Hi there! You’ve found Honeybadger’s guide to **Ruby Exception and error tracking on AWS Lambda and Serverless**. Once installed, Honeybadger will report exceptions wherever they may happen.

If you’re new to Honeybadger, read our [Getting Started guide](https://docs.honeybadger.io/lib/ruby/) to become familiar with our Ruby gem. For a refresher on working with exceptions in Ruby, check out the [Honeybadger guide to Ruby exceptions](https://www.exceptionalcreatures.com/guides/what-are-ruby-exceptions/).

## Installation

The first step is to add the honeybadger gem to your Gemfile:

```ruby
gem 'honeybadger'
```

Tell bundler to install:

```bash
bundle install --deployment --without development,test
```

Depending on your deployment method, vendoring might be required to ensure your dependencies are included. We think the [serverless framework](https://serverless.com/framework/docs/providers/aws/examples/hello-world/ruby/) is a cool way to manage your lambda functions.

It may help to use a Ruby version manager (something like [asdf](https://github.com/asdf-vm/asdf-ruby) or [rvm](https://rvm.io/)) to ensure you are building against your selected lambda Ruby runtime. You can view a list of lambda runtime versions [here](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html).

You can configure Honeybadger in your Lambda by adding your API key via the `HONEYBADGER_API_KEY` environment variable.

## Capturing exceptions

To automatically capture exceptions from your Lambda handler, register your handlers with the `hb_wrap_handler` method. Any unhandled exceptions raised within the specified methods will be automatically reported to Honeybadger.

```ruby
require 'honeybadger'


hb_wrap_handler :my_handler1, :my_handler2


def my_handler1(event:, context:)
  # ...
end


def my_handler2(event:, context:)
  # ...
end
```

For class methods, you’ll need to first extend our `LambdaExtensions` module:

```ruby
class MyLambdaApp
  extend ::Honeybadger::Plugins::LambdaExtension


  hb_wrap_handler :my_handler


  def self.my_handler(event:, context:)
    # ...
  end
end
```

---

## Try Honeybadger for FREE

Intelligent logging, error tracking, and Just Enough APM™ in one dev-friendly platform. Find and fix problems before users notice.

[Start free trial](https://app.honeybadger.io/users/sign_up)

[See plans and pricing](https://www.honeybadger.io/plans/)
