0.0
The project is in a healthy, maintained state
A lightweight Ruby gem for reporting errors to Dristi error tracking service
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 13.0
~> 3.0
~> 3.0
 Project Readme

Dristi Client

Gem Version

Ruby client for Dristi error tracking service.

Requirements

  • Ruby >= 3.0.0
  • Rails (optional, for automatic middleware integration)

Installation

Add this line to your application's Gemfile:

gem "dristi-client"

Then execute:

bundle install

Configuration

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

DristiClient.configure do |config|
  config.api_token = ENV["DRISTI_API_TOKEN"]

  # Optional: disable in specific environments
  config.enabled = !Rails.env.test?

  # Optional: ignore specific exception classes
  config.ignored_exceptions = [ActiveRecord::RecordNotFound]
end

Configuration Options

Option Type Default Description
api_token String nil Required. API token for authentication
enabled Boolean true Enable/disable error reporting
ignored_exceptions Array [] Exception classes to skip

Usage

Automatic Error Capture

The gem automatically captures unhandled exceptions via Rack middleware. No additional code is needed for Rails applications.

The middleware captures the following context automatically:

  • request_method - HTTP method (GET, POST, etc.)
  • request_path - Request path
  • request_params - Request parameters (sensitive params filtered)
  • query_string - Query string
  • user_agent - Browser/client user agent
  • remote_ip - Client IP address
  • request_id - Rails request ID
  • referer - HTTP referer URL (if present)
  • referer_path - Path portion of the referer URL

Manual Error Reporting

You can manually report errors with additional context:

begin
  # risky code
rescue => e
  DristiClient.capture(e, {
    user_id: current_user.id,
    action: "checkout",
    custom_data: { cart_items: cart.items.count }
  })
  raise
end

Custom Context

Add any relevant context to help with debugging:

DristiClient.capture(exception, {
  user_id: current_user&.id,
  user_email: current_user&.email,
  feature_flags: FeatureFlags.active,
  request_id: request.request_id
})

Error Payload

Errors are reported with the following structure:

{
  "exception_class": "NoMethodError",
  "message": "undefined method 'foo' for nil:NilClass",
  "backtrace": ["app/models/user.rb:42:in `process'", "..."],
  "context": { "user_id": 123 },
  "environment": {
    "ruby_version": "3.3.0",
    "rails_version": "8.1.2",
    "rails_env": "production",
    "hostname": "web-1"
  },
  "occurred_at": "2025-01-21T12:00:00Z"
}

Retry & Fallback Behavior

  • Errors are sent in a background thread to avoid blocking requests
  • Failed requests retry up to 3 times with exponential backoff (1s, 2s, 4s)
  • If all retries fail, errors are written to tmp/dristi_fallback.jsonl

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/logicalgroove/dristi-client.

License

MIT License. See LICENSE.txt.