Ruby client for Dristi error tracking service.
- Ruby >= 3.0.0
- Rails (optional, for automatic middleware integration)
Add this line to your application's Gemfile:
gem "dristi-client"Then execute:
bundle installCreate 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| 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 |
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 pathrequest_params- Request parameters (sensitive params filtered)query_string- Query stringuser_agent- Browser/client user agentremote_ip- Client IP addressrequest_id- Rails request IDreferer- HTTP referer URL (if present)referer_path- Path portion of the referer URL
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
endAdd 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
})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"
}- 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
Bug reports and pull requests are welcome on GitHub at https://github.com/logicalgroove/dristi-client.
MIT License. See LICENSE.txt.