Ruby

Ruby SDK

Installation

Add to your Gemfile:

gem 'sentry-ruby'

For Rails:

gem 'sentry-ruby'
gem 'sentry-rails'

Then:

bundle install

Setup

Plain Ruby

Sentry.init do |config|
  config.dsn = 'https://your-key@your-hostname.tindra.sh/1'
  config.environment = ENV['RACK_ENV'] || 'production'
  config.release = ENV['APP_VERSION']
  config.traces_sample_rate = 0.1
end

Rails

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

Sentry.init do |config|
  config.dsn = ENV['SENTRY_DSN']
  config.breadcrumbs_logger = [:active_support_logger, :http_logger]
  config.traces_sample_rate = 0.1
  config.profiles_sample_rate = 0.1
end

Add to .env or credentials:

SENTRY_DSN=https://your-key@your-hostname.tindra.sh/1

Additional integrations

For background jobs, install the relevant gems:

Integration Gem
Sidekiq sentry-sidekiq
OpenTelemetry sentry-opentelemetry

Manual error capturing

begin
  process_order(order)
rescue => e
  Sentry.capture_exception(e)
  raise
end

Capture a message

Sentry.capture_message("User exceeded quota", level: :warning)

User context

Sentry.set_user(id: current_user.id, email: current_user.email)

Extra context

Sentry.set_extras(order_id: order.id, cart_total: cart.total)
Sentry.set_tags(checkout_flow: 'express')

Testing

Sentry.capture_exception(RuntimeError.new("Hello Tindra"))

Check your dashboard. The event should appear within a few seconds.