All Integrations
Languagestigerops-rails gem

Ruby on Rails Integration

Auto-instrument Rails applications with one gem install. ActiveRecord query spans, N+1 detection, Sidekiq job tracing, and ActionController request visibility — zero configuration.

Setup

How It Works

01

Add to Gemfile

Add gem "tigerops-rails" to your Gemfile and run bundle install. The Rails-specific gem includes all tigerops base instrumentation plus Rails-framework patches for ActiveRecord, ActionController, ActionView, and ActiveJob.

02

Create the Initializer

Create config/initializers/tigerops.rb with your TigerOps.configure block. The Rails initializer is loaded after all gems are initialized, ensuring all ActiveRecord adapters and middleware stacks are patched correctly.

03

Set Environment Variables

Set TIGEROPS_API_KEY, TIGEROPS_SERVICE_NAME, and TIGEROPS_ENVIRONMENT in your credentials file, .env, or Heroku/Render config vars. The initializer reads these via Rails.application.credentials or ENV fallback.

04

Requests, Queries & Jobs Flow

Within seconds TigerOps receives ActionController request spans, ActiveRecord query traces with N+1 flags, Sidekiq job execution spans, and Action Cable WebSocket event traces.

Capabilities

What You Get Out of the Box

ActiveRecord Query Spans

Every ActiveRecord query creates a child span with normalized SQL, adapter type (PostgreSQL, MySQL, SQLite), row count, and connection pool wait time. Eager loading effectiveness is measured and reported.

N+1 Query Detection

TigerOps detects N+1 query patterns by analyzing repeated identical queries within a single request trace. Detected N+1s are flagged with the association name and a suggested includes() fix.

ActionController Tracing

Controller class, action name, route path, HTTP method, status code, and before/after filter timing are captured for every request. Redirect and render timings are tracked as child span events.

Sidekiq Job Visibility

Sidekiq worker class, queue, job arguments (sanitized), retry count, enqueue time, queue wait duration, and execution time create a full trace for every background job execution.

Action Cable & Turbo

Action Cable channel subscriptions, message broadcasts, and Turbo Stream updates create spans tagged with the channel class and stream name. Connection counts and message rates are reported as metrics.

ActiveSupport Notifications

TigerOps subscribes to all ActiveSupport::Notifications events and creates spans for View rendering, cache operations, and mailer delivery. Custom notification events in your app are automatically captured.

Configuration

Install & Initialize

One gem. One initializer. Full Rails observability.

Gemfile + config/initializers/tigerops.rb
# Gemfile
gem "tigerops-rails"

# Run
bundle install

# config/initializers/tigerops.rb
TigerOps.configure do |config|
  config.api_key      = Rails.application.credentials.tigerops&.api_key ||
                        ENV["TIGEROPS_API_KEY"]
  config.service_name = ENV.fetch("TIGEROPS_SERVICE_NAME", Rails.application.class.module_parent_name.downcase)
  config.environment  = Rails.env

  # Enable instrumentations
  config.instrument :active_record      # SQL spans + N+1 detection
  config.instrument :action_controller  # Request spans
  config.instrument :action_view        # View render timing
  config.instrument :sidekiq            # Background job traces
  config.instrument :action_cable       # WebSocket events
  config.instrument :active_job         # Job queue spans

  # N+1 detection threshold
  config.n_plus_one_threshold = 3

  # Slow query threshold
  config.slow_query_threshold_ms = 100
end

# Custom spans in a service object
class ShipmentService
  def schedule(order)
    TigerOps.tracer.in_span("shipment.schedule") do |span|
      span.set_attribute("order.id", order.id.to_s)
      span.set_attribute("shipment.carrier", order.preferred_carrier)

      carrier = CarrierApi.book(order)
      order.update!(
        tracking_number: carrier.tracking_id,
        shipped_at: Time.current
      )

      span.set_attribute("shipment.tracking_number", carrier.tracking_id)
      carrier
    end
  end
end
FAQ

Common Questions

Does tigerops-rails work with Rails API-only mode?

Yes. In API mode, ActionView and Turbo instrumentation is disabled automatically. Only ActionController, ActiveRecord, and ActiveJob patches are applied. The middleware is inserted into the slim API middleware stack.

How does N+1 detection work without slowing down requests?

TigerOps uses a lightweight hash map to track query fingerprints within a request lifecycle. When the same fingerprint appears more than a configurable threshold (default 3), it is flagged as a potential N+1 without interrupting the request.

Does TigerOps integrate with Rails credentials and encrypted secrets?

Yes. In the initializer, access the API key via Rails.application.credentials.tigerops&.api_key or fall back to ENV["TIGEROPS_API_KEY"]. The initializer runs after credentials are decrypted, so both approaches work in production.

Can I use TigerOps with multiple Sidekiq processes and queues?

Yes. Each Sidekiq process registers the TigerOps middleware independently. Worker spans are tagged with the queue name and Sidekiq process hostname, making it easy to compare performance across queues and workers.

Does TigerOps work with Hotwire and Stimulus?

Server-side Turbo Stream and Turbo Frame responses are traced as part of the controller action span. Client-side Stimulus controller actions are not traced by default, but you can instrument them using the @tigerops/browser JavaScript SDK.

Get Started

Full Rails Observability in One Gem Install

ActiveRecord spans, N+1 detection, Sidekiq visibility, and ActionController tracing — no code changes required.