appsignal

Introducing AppSignal for Hanami

Connor James

Connor James on

Introducing AppSignal for Hanami

Struggling to keep track of key metrics and potential issues in your Hanami application? AppSignal integrates seamlessly with Hanami 2.0 actions to provide action-level insights, making it easier for you to ensure a smooth-running application.

In this blog post, you'll learn about the integration between AppSignal and Hanami and how it solves your performance monitoring challenges.

How AppSignal Elevates Your Hanami Application

AppSignal was created by developers for developers and has supported Ruby applications for close to a decade now.

Once you've integrated your Hanami application with our Ruby integration, our six powerful monitoring tools will provide you with clear and actionable application insights:

  • Error Tracking: Tracks exceptions and sends error alerts so you can debug and fix errors quickly.
  • Performance monitoring: Monitors the performance of an application's slowest actions down to the nanosecond.
  • Host monitoring: Server monitoring with CPU, Disk and Network data.
  • Anomaly detection: Allows you to set triggers for anomalies on any metric you'd like.
  • Metrics dashboards: Collects metrics from an application's code and charts them on dashboards.
  • Uptime monitoring: Sends real-time alerts when an application is down.

These tools give you the data you need to resolve issues quickly. When a user encounters an error while using your application, AppSignal notifies you with details on its cause, location, and if it has happened before.

Let's take a look at Error Tracking, Uptime Monitoring and Dashboards in more detail:

Error Tracking

Screenshot of AppSignal's Error Tracking

AppSignal's Error Tracking tracks exceptions and sends you alerts so you can debug and fix errors quickly. Not only does AppSignal notify you when an error occurs within your Hanami application, but it also gives you the data you need to see the error from within the context of your application's performance and codebase. AppSignal will provide you with an error message, request data, and host information.

We also understand that sometimes it's hard for you to know if an error is new or something you've already fixed. To help prevent any sense of déjà vu, you'll have access to samples of the same error across every deployment of your application that we've tracked.

Performance Monitoring

Screenshot of AppSignal's Performance Dashboard

Performance is always important, and exactly what the Hanami framework is optimized for. With AppSignal, you'll have access to data to maximize your application's performance using metrics instead of guesswork.

You'll get a breakdown of your action's performance, can view request details, and see a timeline of request events to help you quickly see exactly what was going on and for how long while a request was being processed.

Dashboards

Screenshot of AppSignal's Job Queue Dashboard

AppSignal Dashboards give you quick visual insights into how your application is performing, from tracking the size of your application's database to its background job queue performance. AppSignal understands your stack and automatically creates dashboards for integrations like Sidekiq, MongoDB, and Puma. With dashboards, you have access to your application's key metrics at a glance and can better understand your application's performance across its integrations.

Third-Party Integrations

To help you streamline your workflows and communication, AppSignal integrates with many popular third-party applications like GitHub, Slack, and Discord. When integrated with an Issue Tracker like GitHub or Atlassian's Jira, you can create issues directly from an incident screen in AppSignal.

AppSignal hates spam, so you can decide when and how frequently you want to be notified about specific issues via your organization's notification settings.

TLDR: AppSignal can be configured to communicate with you in a way that makes sense to you.

Getting Started with AppSignal and Hanami

To use AppSignal for monitoring your Hanami app, you'll need to install the Hanami 2.0 gem in your Ruby application. Alternatively, you can use the Hanami framework to generate a new application.

Once you've got a Ruby application with the Hanami gem installed, you'll need to modify your application's config.ru file to include AppSignal's Hanami integration, like so:

require "hanami/boot"
require "appsignal/integrations/hanami" # Add this line
 
run Hanami.app

You'll also need to configure your application to connect to AppSignal. This can be done via a configuration file:

# config/appsignal.yml
production:
  active: true
  push_api_key: "1234-1234-1234"
  name: "My app"

Or via environment variables:

# Environment variables
export APPSIGNAL_PUSH_API_KEY="1234-1234-1234"
export APPSIGNAL_APP_NAME="My app"
export APPSIGNAL_APP_ENV="production"

If you are new to AppSignal, our documentation and installer tool will provide you with more information on how to get your application up and running with AppSignal.

Once you've successfully installed Hanami, included the AppSignal integration, and provided your application with the configuration it needs to talk to AppSignal, you'll be able to see Hanami data in the application.

Hanami and AppSignal in Action

Let's imagine we've created a Hanami application for a library and we want to see an index of all books the library has in stock. In a typical Ruby application you'd expect to find this as a method in a controller, but in Hanami it's an action. Here's an example of an index action:

# /app/actions/books/index.rb
 
module HanamiLibrary
  module Actions
    module Books
      class Index < HanamiLibrary::Action
        include Deps["persistence.rom"]
 
        params do
          optional(:page).value(:integer, gt?: 0)
          optional(:per_page).value(:integer, gt?: 0, lteq?: 100)
        end
 
        def handle(request, response)
          halt 422 unless request.params.valid?
 
          books = rom.relations[:books]
            .select(:title, :author)
            .order(:title)
            .page(request.params[:page] || 1)
            .per_page(request.params[:per_page] || 5)
            .to_a
 
          response.format = :json
          response.body = books.to_json
        end
      end
    end
  end
end

The action requests a database to retrieve all books and deliver them to our users.

Screenshot of AppSignal's Sample Breakdown and Event Timeline

AppSignal can recognise that the request is for a Hanami action and represent it in the Sample Breakdown and Event Timeline of an incident, as demonstrated in the screenshot above.

To Summarise

The beauty of Ruby is its consistent ability to deliver frameworks that fit the needs of various applications. We continuously strive to improve the Ruby frameworks that we support so Ruby users can always get the best out of their application monitoring with AppSignal.

In the future, we plan to integrate with dry-monitor to enhance our Hanami monitoring capabilities further, but we'll of course let you know as and when we make any changes to how our Hanami support works!

Sutorōpuwaffuru

That's stroopwafel in Japanese, and we love to send them to our trial users (upon request). If you'd like some sweet sugary snacks to power you through a pair programming session, have an idea for a feature, or need a helping hand with your code, please contact us.

Share this article

RSS
Connor James

Connor James

Official technical writer at AppSignal. Podcast addict who loves cannoli so much that he's considering changing his name to Connoli. He thinks there's a `u` in color. You might find him on the mic, on the stage, or lying on the sofa when he's off Documentation Duty.

All articles by Connor James

Become our next author!

Find out more

AppSignal monitors your apps

AppSignal provides insights for Ruby, Rails, Elixir, Phoenix, Node.js, Express and many other frameworks and libraries. We are located in beautiful Amsterdam. We love stroopwafels. If you do too, let us know. We might send you some!

Discover AppSignal
AppSignal monitors your apps