sentry-rails, the Rails integration for Sentry's Ruby client


Gem Version Build Status Coverage Status Gem SemVer

Documentation | Bug Tracker | Forum | IRC: irc.freenode.net, #sentry

The official Ruby-language client and integration layer for the Sentry error reporting API.

Requirements

This integration requires Rails version >= 5.0 and Ruby version >= 2.4

Getting Started

Install

gem "sentry-rails"

Integration Specific Configuration

This gem has a few Rails-specific configuration options

Sentry.init do |config|
  # report exceptions rescued by ActionDispatch::ShowExceptions or ActionDispatch::DebugExceptions middlewares
  # the default value is true
  config.rails.report_rescued_exceptions = true

  # this gem also provides a new breadcrumb logger that accepts instrumentations from ActiveSupport
  # it's not activated by default, but you can enable it with
  config.breadcrumbs_logger = [:active_support_logger]
end

Performance Monitoring

You can activate performance monitoring by enabling traces sampling:

Sentry.init do |config|
  # set a uniform sample rate between 0.0 and 1.0
  config.traces_sample_rate = 0.2

  # or control sampling dynamically
  config.traces_sampler = lambda do |sampling_context|
    # sampling_context[:transaction_context] contains the information about the transaction
    # sampling_context[:parent_sampled] contains the transaction's parent's sample decision
    true # return value can be a boolean or a float between 0.0 and 1.0
  end
end

Currently, it tracks the following Rails instrumentation events:

  • ActiveRecord
    • sql.active_record
  • ActionController
    • process_action.action_controller
  • ActionView
    • render_template.action_view
    • render_partial.action_view
    • render_collection.action_view

To lean more about performance monitoring, please visit the official documentation.