sixty

agent serveur

Ruby & Rails

La seule installation sans étape deux. Le railtie ajoute le middleware, s’abonne à sql.active_record et enveloppe les actions de contrôleur au démarrage — il n’y a aucun initializer à écrire.

paquet
sixty sur RubyGems
tourne sur
Ruby 2.7 ou plus récent. Rails 6.1+ s’installe tout seul ; Rack suffit pour le reste.
source
sixty-sh/sixty-ruby

L’installer

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.

L’installation est écrite comme un prompt pour l’agent de code que vous avez déjà ouvert, pas comme une liste de tâches pour vous. C’est délibéré : elle nomme ce qui doit être vrai une fois l’installation terminée plutôt que les fichiers à modifier, parce que l’endroit où va le code dépend du framework et que le mettre au mauvais endroit échoue silencieusement. Un agent peut lire votre dépôt et le déduire ; un paragraphe sur une page de documentation, non.

Le même texte est ce que renvoie install_sixty via le serveur MCP et ce que le collecteur sert à /v1/setup?kind=ruby. Il n’en existe qu’une seule copie.

l’installation Ruby & Rails, en entier
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.

Il lui faut une clé secrète — elle commence par sixty_sk_ et reste côté serveur. Générez-en une sur la page Réglages une fois connecté.

Ce qu’il mesure

signalunitéce que cela veut dire
rowsrows per callthis query returns more rows than it used to
fanoutqueries per callthis operation now issues more database calls per invocation — an N+1
latencyms per callthis operation takes longer end to end than it used to
self_latencyms per callthe time spent in this function itself got longer — its children did not
payloadbytes per callthe serialized result of this operation got bigger
errorserror ratea larger fraction of calls are throwing
runawaycalls per minutethis operation is being called far more often than anything triggers it
repeated_querytimes per requestthe identical query runs several times within one request
overfetchrows per callfar more rows are fetched than the code appears to use
unboundedrows per callthis query has no upper bound on what it can return
recursionlevels deepthis operation calls itself, deeper than it should
new_erroroccurrencesan 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.
round_tripsround trips per readone read now waits on the database many times instead of once
plan—the database chose a different plan for this query

Où il s’accroche

  • Rails — Automatique. Les contrôleurs deviennent des opérations, nommées par contrôleur#action.
  • Rack — use Sixty::Instrument::Rack dans config.ru, pour Sinatra, Hanami ou une application nue.
  • Vos propres classes — include Sixty::Instrumented — chaque méthode d’instance publique devient une opération. Les méthodes privées et les accesseurs sont laissés tranquilles.
  • Tout le reste — Sixty.instrument(Stripe::Charge, :create), ou Sixty.trace("job") { }.

Bases de données

  • pg — Lignes, forme de la requête, et plans de requête via EXPLAIN.
  • mysql2 / trilogy — Lus selon les règles de citation de MySQL, pas celles de Postgres — une chaîne entre guillemets doubles est un littéral dans l’une et un identifiant dans l’autre.
  • mongo — Ce qu’utilise Mongoid. La forme de la commande comme identité.

Ce que seul celui-ci fait

  • Rien à écrire — Rails a un point d’accroche de démarrage documenté et un bus d’événements qui annonce déjà chaque requête : la gem n’a donc besoin ni d’initializer ni d’enveloppe.
  • Des plans de requête sur Postgres — Le même EXPLAIN que l’agent Node, mis en cache par requête.

Ce qu’il ne peut pas faire

  • Les plans de requête ne concernent que Postgres. MySQL n’a pas d’EXPLAIN à plan générique, et MongoDB n’a pas de requête à expliquer.
  • Le CPU et l’attente ne sont pas séparés.
  • Sous Puma avec des workers, ou sous Sidekiq, chaque processus remonte indépendamment et le collecteur les fusionne.

Configuration

Chaque agent lit les mêmes quatre variables, et DRIFT_* répond toujours partout où SIXTY_* répond — le produit a été renommé, et ce nom ne nous appartient pas au point de le retirer des déploiements des autres.

SIXTY_API_KEYSans elle l’agent reste inerte et le dit. Il ne devine jamais, ne réessaie jamais contre un point d’entrée inconnu, et ne lève jamais d’exception.
SIXTY_SERVICEComment appeler ce service. Par défaut le nom du projet là où il est lisible.
SIXTY_RELEASELa plus importante. Récupérée automatiquement sur Vercel, Render, Railway, Fly, Heroku et GitHub Actions ; partout ailleurs, mettez-y le SHA du commit. Sans elle, chaque mesure atterrit dans un unique seau sans nom et aucune comparaison n’est jamais possible.
SIXTY_ENDPOINTOù remonter. Par défaut http://localhost:4319, ce qui est juste sur un portable et faux dès l’instant où l’application est servie à quelqu’un d’autre.

Le reste — intervalle d’envoi, taux d’échantillonnage, quoi instrumenter — est dans le README du paquet lui-même, là où il peut rester vrai à mesure que l’agent change.

L’agent Ruby & Rails de sixty — ce qu’il mesure et comment l’installer