coss.comshipyard

Leadline

What your code did in development, as tabs on a worktree: database queries with their N+1s, request traces, logs and endpoints, kept on the box.

Leadline is a plugin that shows what a worktree's app did while it ran in development: every database query, each request's trace, and the logs. A small program on the box, berth-leadline, records it beside your dev servers; four tabs on the worktree read it. Nothing it records leaves the box.

It isn't built in. Install it from Settings → Plugins → Browse, then turn it on under Installed. Because it carries a program for your boxes, the dialog that asks before it runs says so, by the program's name.

What it shows

Open any of the four from a worktree's + menu, or from ⌘K ("Show this worktree's queries"). Each one is about the worktree in front, and only that worktree.

The time window at the top right (15 minutes unless you change it) is one for all four tabs. A tab reads again every few seconds while it is on screen, and not at all while it is behind another.

Send to the agent

A slow query, an N+1 or a failing endpoint has Send to the agent. It writes the problem up: what is wrong with its numbers, the statement's shape, the requests that show it, and what done looks like. The sheet shows exactly the text that will be sent, and you can change any of it first. Then it goes to the worktree's agent, held on the box until the agent is idle if it is busy; with no agent in the worktree, it starts one on it.

A statement is only ever written by its shape. The values your app sent (an email address, an id) are not shown in the tabs and are not put in what is sent, and an error's words have their values taken out the same way.

Turning it on for a box

Leadline is off on every box until you turn it on there. Open Leadline (under More in the sidebar, or "Show Leadline" in ⌘K): it lists your boxes and what each one has.

A worktree's tab on a box where Leadline is off says so, with the same Turn on….

Update appears when the plugin carries a newer program than the box runs. Turn off stops and removes the program and keeps what it recorded for next time. Remove data also deletes what it recorded on that box, for every worktree; it can't be undone.

What an app needs to send

Leadline shows a worktree once something arrives from it.

  1. Start the app as a service of its worktree. With Leadline on for a box, Shipyard sets the variables that point an app at it (OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_PROTOCOL, OTEL_SERVICE_NAME, OTEL_RESOURCE_ATTRIBUTES) for the services it starts. A service that was already running needs a restart to get them. A server you start by hand in a terminal isn't given them.
  2. Queries need nothing more. When a service's DATABASE_URL or POSTGRES_URL names a Postgres on the box itself, Shipyard routes it through Leadline, which records every statement as it goes by: its text, its time on the wire, and whether it failed. No SDK, in any language.
  3. Traces and logs need an OpenTelemetry SDK in the app. Any OpenTelemetry SDK reads those variables and sends its traces and logs. Without one, Queries still fills in, but nothing ties a query to the request that ran it: Endpoints stays empty and an N+1 goes unflagged.

A tab for a worktree that has sent nothing says so, and says this.

A worktree's telemetry is filed under <project>/<worktree>, or the project's name alone for its main checkout; a second service in the same worktree adds :<name>, and shows in the worktree's tabs with a small label.

What is kept, and for how long

Everything is in one SQLite file in a folder the box gives the helper, readable only by you on that box.

  • A row is kept for 72 hours.
  • Past 2 GB, the oldest rows go early.
  • Old rows are dropped once a minute.

The Leadline screen shows how much a box holds. Remove data empties it.

What is stored is a statement's text and up to 32 of its parameters (200 bytes each), spans with their attributes, and log records. The tabs show a statement by its shape, and leave its parameters out.

Nothing leaves the box

berth-leadline listens on the box's loopback address only, has no password because nothing on the network can reach it, and connects to nothing but the Postgres servers on the same box it was asked to stand in front of. The app reads it through the box's own API, the way it reads everything else on a box.

The one way anything goes further is by your hand: Send to the agent puts the text you see in the sheet into your agent's prompt, which the agent's own provider then sees, like any prompt.

Limits

  • Postgres only, on the box only. Statements are recorded off the wire for a Postgres on the same box. A database on another machine, a URL that insists on TLS (sslmode=require and stronger) or a Unix socket is left alone; its queries show only if the app's own OpenTelemetry SDK reports them. Other databases show the same way: through the app's spans.
  • Services Shipyard starts. A dev server started by hand isn't pointed at Leadline.
  • An app that names itself. The tabs show what is filed under the worktree's name. An app that sets its own OTEL_SERVICE_NAME may be filed under that name instead, and then doesn't show in the worktree's tabs.
  • Not live to the millisecond. A tab asks again every 3 seconds (less often for a wide window), not as each row arrives.
  • Wide windows are slow. 15 minutes answers in a few milliseconds; a whole day on a full store can take seconds.
  • The N+1 rule is one number. Five of the same statement in one request. It needs traces, so it needs an OpenTelemetry SDK in the app.
  • Metrics are not kept. An SDK may send them; Leadline takes them and drops them.
  • No comparison with main, no table editor and no SQL console.
  • Where it runs. The program is built for Linux and macOS, on amd64 and arm64.

Last updated