Railwatch
First-class monitoring for Rails. One gem instruments requests, jobs, scheduled tasks, commands, queries, exceptions, cache, mail, broadcasts, outgoing HTTP, storage, views, and logs, and links them into one trace per execution, for about half a millisecond per request plus tens of microseconds per query, with zero writes to your database.
The gem is the agent. It sends what it records over HTTPS to a Railwatch server, which stores it, groups exceptions into issues, sends alerts, and serves the dashboard and an MCP server:
- Railwatch Cloud at https://app.railwatch.dev, the default.
- Self-hosted railwatch-rs, one static binary for many apps (Self-hosting).
-
Embedded: the
railwatch-sidecargem runs that server next to Puma for one app and serves the dashboard at/railwatch, with nothing else to run.
Install
bundle add railwatch # 1. add the public gem
bin/rails generate railwatch:install --prompt-token # 2. hidden token input plus app wiring
bin/rails railwatch:doctor # check every piece is wired up after restartFor a self-hosted server, add --url=https://telemetry.example.com.
The generator's flags, getting a token, and deploying with Kamal,
Docker, Heroku, or Render are covered in
Getting started. For an unreleased revision,
use the Git source instead:
gem "railwatch", github: "Rebulk/railwatch"Embedded
To keep everything inside the app, add railwatch-sidecar next to this
gem:
# Gemfile
gem "railwatch"
gem "railwatch-sidecar"# config/puma.rb
plugin :railwatch_sidecarIt provisions its data under storage/railwatch/<env> on first boot and
points this gem at it, so there is no token to manage. The dashboard at
/railwatch is open in development and answers 401 elsewhere until you
give it a password with
RAILS_ENV=production bin/rails railwatch:authentication:configure, or
put it behind your own admin authentication
(Configuration).
Everything else is in the
railwatch-sidecar README.
Railwatch 0.x kept embedded telemetry in two SQLite databases written by
plugin :railwatch. 1.0 removes that mode; see
Coming from 0.x embedded mode.
What you get
- Requests, jobs, scheduled tasks, commands, queries, exceptions, and logs, linked into one trace per execution (Record types).
- Sampling decided once per execution, plus tail sampling that keeps a sampled-out request that turns out slow or raises (Configuration).
- An optional stack profiler through
vernierorstackprof, off by default (Configuration). - LLM calls made through RubyLLM: tokens, cost, cut-off answers, tool calls and workflows, each tied to the request or job that made it (Record types).
- A browser client for Inertia apps: page-visit timing, Core Web Vitals, and browser errors (Getting started).
- RSpec and Minitest matchers that turn a query budget into a CI gate (Testing).
- An MCP server on the Railwatch server, so Claude Code, Cursor, VS Code, or Zed can read your production data (AI assistants and MCP).
Configuration lives in config/initializers/railwatch.rb; most options
also have a RAILWATCH_* environment variable.
Railwatch.configure do |c|
c.sample = { requests: 0.1, jobs: 1.0 }
c.user { |u| { id: u.id, name: u.name, email: u.email } }
endThe same instrumentation runs in your test suite, so a spec can hold a hot path to a query budget:
expect { get "/widgets" }.to have_railwatch_queries(at_most: 6)
expect { get "/widgets" }.not_to have_railwatch_n_plus_oneDocumentation
- Getting started — the install and its token, embedded with railwatch-sidecar, moving from 0.x embedded mode, the three optional lines, and deploying with Kamal, Docker, Heroku, Render, or none of them.
-
Configuration — every option and
RAILWATCH_*variable, field by field. - Record types — every record Railwatch ships and every attribute on it, sourced from the code that builds it.
- Testing — the RSpec and Minitest matchers, and a CI performance gate.
- AI assistants and MCP — connecting Claude Code, Cursor, VS Code, or Zed to your production data.
- Replacing Sentry — a step-by-step migration, option by option and call site by call site.
- Coming from Laravel Nightwatch — the record-type mapping and the sampling model, for Laravel people.
- Self-hosting — pointing the gem at your own railwatch-rs server.
-
Troubleshooting — every failure mode, paired
with the
railwatch:doctorline it shows up as. - FAQ — overhead numbers, retention, PII posture, SQLite.
- Security — transport, capture defaults, the browser beacon, and application responsibilities.
AI coding agents working on an app that uses Railwatch: llms.txt
and AGENTS.md.
Replacing Sentry
Railwatch subscribes to Rails.error on install, so existing
Rails.error.report and Rails.error.handle calls are captured with no
code changes. Each exception is linked to the request, job, or command
it happened inside. The option-by-option mapping and the
supported-workload matrix live in
Replacing Sentry.
Development
bundle install
bundle exec rspec