Project

errsight

0.0
The project is in a healthy, maintained state
A lightweight Ruby gem that hooks into Rails.logger and sends logs/errors to the Errsight API.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

 Project Readme

errsight-ruby

Ruby/Rails client for ErrSight error tracking. Captures exceptions and log entries and ships them to the ErrSight API in a background thread.

Requirements

  • Ruby >= 3.0
  • Rails 6+ (optional — also works in plain Ruby)

Installation

Add to your Gemfile:

gem "errsight"

Then run:

bundle install

Configuration

Rails

Create an initializer at config/initializers/errsight.rb:

Errsight.configure do |config|
  config.api_key     = ENV["ERRSIGHT_API_KEY"]   # required
  config.environment = Rails.env                  # default: ENV["ERRSIGHT_ENV"] || "production"
end

That is all you need. The Railtie handles the rest automatically:

  • Attaches to Rails.logger so every log line is forwarded to ErrSight.
  • Subscribes to process_action.action_controller notifications to capture unhandled exceptions with request context (controller, action, path, params, current user).
  • Calls Errsight.client.shutdown! on process exit to drain the queue.

Plain Ruby

require "errsight"

Errsight.configure do |config|
  config.api_key     = ENV["ERRSIGHT_API_KEY"]
  config.environment = "production"
end

Environment variables

Variable Default Description
ERRSIGHT_API_KEY Your project API key (required)
ERRSIGHT_ENV "production" Environment tag attached to events

All configuration options

Errsight.configure do |config|
  config.api_key                = ENV["ERRSIGHT_API_KEY"]
  config.environment            = "production"
  config.min_level              = :warning   # :debug | :info | :warning | :error | :fatal
  config.host                   = "https://errsight.com"
  config.timeout                = 5          # HTTP timeout in seconds
  config.batch_size             = 10         # events per HTTP request
  config.flush_interval         = 2          # background flush cadence in seconds
  config.max_queue_size         = 1_000      # drop events when queue exceeds this
  config.attach_to_rails_logger = true       # broadcast Rails.logger to ErrSight
end

Usage

Capture an exception

begin
  do_something_risky
rescue => e
  Errsight.capture_exception(e, metadata: { user_id: current_user.id })
end

Log a message directly

Errsight.log(level: :error, message: "Payment gateway timeout", metadata: { order_id: 42 })

Use as a Logger sink

logger = Errsight::Logger.new          # standalone — forwards to API only
logger = Errsight::Logger.new($stdout) # tee — writes to $stdout AND the API

logger.warn  "Cache miss"
logger.error "Unprocessable entity"

Rails — automatic exception capture

In a Rails app the Railtie automatically captures every unhandled exception raised during a controller action. Each event ships with:

  • User context (top-level user block): id, email, username from the signed-in Devise/Warden user (any scope, including ActiveAdmin), plus ip_address from request.remote_ip — populated even for anonymous requests.
  • Tags (filterable in the UI): controller, action, request_method, status, ruby_version, rails_version, hostname.
  • Metadata: path, full_path, format, duration, filtered params (respects Rails' filter_parameters), exception_class.
  • Backtrace: full exception.backtrace.

No additional code is required.

How it works

Events are pushed onto an in-memory queue and flushed to the API in batches by a background thread every flush_interval seconds (default: 2 s). A flush also triggers immediately when the queue reaches batch_size. On process exit the queue is drained synchronously before the process terminates.

The HTTP transport uses Net::HTTP with no extra dependencies beyond concurrent-ruby for thread-safe queue operations.