server agent
Ruby & Rails
The only install with no step two. The railtie adds the middleware, subscribes to sql.active_record and wraps controller actions on boot — there is no initializer to write.
- package
sixtyon RubyGems- runs on
- Ruby 2.7 or later. Rails 6.1+ installs itself; Rack alone is enough for the rest.
- source
- packages/ruby
Installing it
Rails installs itself — the railtie adds the middleware, subscribes to sql.active_record and wraps controllers on boot. Postgres, MySQL and MongoDB, with query plans on Postgres.
The install is written as a prompt for the coding agent you already have open, not as a checklist for you. That is deliberate: it names what must be true when the install is finished rather than which files to edit, because where the code goes depends on the framework and putting it in the wrong place fails silently. An agent can read your repository and work that out; a paragraph on a documentation page cannot.
The same text is what install_sixty returns through the MCP server and what the collector serves at /v1/setup?kind=ruby. There is one copy of it.
the Ruby & Rails install, in full
Install the sixty agent in this Ruby application so its controllers, service
objects and database queries report to sixty.
1. Add the gem to the main group of the Gemfile — not to :development and not
to :test. It runs in production; that is the entire point. It has no
dependencies of its own, so nothing else in the lockfile moves.
gem 'sixty'
Then bundle install.
2. Rails needs no further wiring. The railtie adds the middleware, subscribes
to sql.active_record and wraps controller actions on boot. Do NOT write an
initializer that calls Sixty.init — in a Rails app that is a second boot
path for the same thing.
If this is Sinatra, Hanami, a bare Rack app or a non-web process, then and
only then do it by hand: require 'sixty' and call Sixty.init at startup,
and add "use Sixty::Instrument::Rack" to config.ru.
3. Measure the layer between the controller and the database. This is the step
the install exists for: without it the feed has routes and SQL and nothing
in between, and an N+1 can be seen but not attributed to the object that
causes it. In a Rails app that object is a query object, a service object,
a serializer or a job — rarely the controller.
class OrdersQuery
include Sixty::Instrumented
end
Every public instance method of that class becomes an operation, with its
queries and rows attributed to it. Private methods and plain accessors are
skipped. Add it to the few classes that do real work per request — not to
models, and not to anything called in a tight loop.
For a class you do not own: Sixty.instrument(Stripe::Charge, :create)
For a block: Sixty.trace('nightly-reconciliation') { ... }
4. Set these environment variables wherever the application is deployed:
SIXTY_API_KEY = a secret key starting sixty_sk_ — ask me for it. Do not
invent one, and do not commit it.
SIXTY_SERVICE = my-app
SIXTY_ENDPOINT = https://ingest.sixty.sh
The release identifier is picked up automatically on Vercel, Render,
Railway, Fly, Heroku and GitHub Actions. If this deploys some other way,
set SIXTY_RELEASE to the commit SHA — without one, every measurement lands
in a single nameless bucket and no comparison can ever be made.
Constraints — correctness requirements, not style preferences:
- Do NOT change any application behaviour. This is instrumentation only: no
refactors, no reordering of business logic, no "while I was in here" fixes.
- Do NOT include Sixty::Instrumented in ActiveRecord models or in anything
called per row. A span costs a few microseconds, which is nothing next to a
request and everything next to a loop over a result set.
- Do NOT add any analytics, user id, session id, or cookie to what is
reported. The agent is deliberately anonymous and must stay that way.
- Leave the database configuration alone. pg, mysql2, trilogy and mongo are
all instrumented already; if this application reaches its database some
other way, tell me rather than wiring something up.
If this runs under Puma with workers, or under Sidekiq, note how many
processes it runs: each reports independently and the collector merges them,
which is correct, but it is worth knowing when you read the numbers.
When you are done, tell me which files you changed, so I can confirm data is
arriving.It needs a secret key — it starts sixty_sk_ and stays server-side. Mint one on the Settings page once you have signed in.
What it measures
| signal | unit | what it means |
|---|---|---|
rows | rows per call | this query returns more rows than it used to |
fanout | queries per call | this operation now issues more database calls per invocation — an N+1 |
latency | ms per call | this operation takes longer end to end than it used to |
self_latency | ms per call | the time spent in this function itself got longer — its children did not |
payload | bytes per call | the serialized result of this operation got bigger |
errors | error rate | a larger fraction of calls are throwing |
runaway | calls per minute | this operation is being called far more often than anything triggers it |
repeated_query | times per request | the identical query runs several times within one request |
overfetch | rows per call | far more rows are fetched than the code appears to use |
unbounded | rows per call | this query has no upper bound on what it can return |
recursion | levels deep | this operation calls itself, deeper than it should |
new_error | occurrences | an error that did not occur in the previous release |
missing_tenancy | — | This reads a table of per-person data without saying whose rows it wants. Unless your database is filtering it for you, everyone gets everyone else's. |
collapse | — | This is handing back roughly half the data it used to, or less. If that was not deliberate, something is filtering out rows that somebody expects to see. |
vanished | — | It was being used steadily until this release and has not been used once since. Usually the link, button, or redirect that led here stopped working. |
traffic_drop | — | This is still being used, but a fraction as often, and its share of your traffic fell too — so it is not just a quiet period. |
plan | — | the database chose a different plan for this query |
Where it hooks in
- Rails — Automatic. Controllers become operations, named by controller#action.
- Rack — use Sixty::Instrument::Rack in config.ru, for Sinatra, Hanami or a bare app.
- Your own classes — include Sixty::Instrumented — every public instance method becomes an operation. Private methods and accessors are left alone.
- Anything else — Sixty.instrument(Stripe::Charge, :create), or Sixty.trace("job") { }.
Databases
- pg — Rows, statement shape, and query plans via EXPLAIN.
- mysql2 / trilogy — Read by MySQL's quoting rules, not Postgres's — a double-quoted string is a literal in one and an identifier in the other.
- mongo — Which is what Mongoid uses. Command shape as identity.
What only this one does
- Nothing to write — Rails has a documented boot hook and an event bus that already announces every query, so the gem needs neither an initializer nor a wrapper.
- Query plans on Postgres — Same EXPLAIN as the Node agent, cached per statement.
What it cannot do
- Query plans are Postgres only. MySQL has no generic-plan EXPLAIN, and MongoDB has no statement to explain.
- CPU and waiting are not split.
- Under Puma with workers, or Sidekiq, each process reports independently and the collector merges them.
Configuration
Every agent reads the same four variables, and DRIFT_* still answers everywhere SIXTY_* does — the product was renamed and that name is not ours to retire from other people’s deployments.
SIXTY_API_KEY | Without it the agent stays inert and says so. It never guesses, never retries against an unknown endpoint, and never throws. |
|---|---|
SIXTY_SERVICE | What to call this service. Defaults to the project name where one is legible. |
SIXTY_RELEASE | The one that matters most. Picked up automatically on Vercel, Render, Railway, Fly, Heroku and GitHub Actions; set it to the commit SHA anywhere else. Without it every measurement lands in a single nameless bucket and no comparison can ever be made. |
SIXTY_ENDPOINT | Where to report. Defaults to http://localhost:4319, which is right on a laptop and wrong the moment the app is served to anyone else. |
The rest — flush interval, sample rate, what to instrument — is in the package’s own README, which is where it can stay true as the agent changes.