vis: Observability That Lives in Your Go Binary, With a Way Back In

Instrumentation inside a service is mostly one way: signals go out to a platform, and acting on them happens somewhere else. vis is a Go library that keeps a live dashboard, SLOs and bounded runtime knobs inside the service itself, for the person on call and for the agent.

In this post

Go ships with a lot of tooling around its build system and its runtime. runtime/metrics reports what the scheduler and the garbage collector are doing. pprof profiles a running process. debug/buildinfo says what a binary was built from. go/analysis and go generate let a library check and write code at build time.

I wanted to see if those parts are enough to make a Go service observable from the inside. Self-contained in the executable, without marrying an observability platform to get there.

The second thing that bugged me is that the tooling we have is mostly read-only. OpenTelemetry and the other probes push metrics and signals out to a platform, and that’s where the story ends. You look at a dashboard, you understand something, and then you go change the service some other way: a config push, a redeploy, a feature flag in yet another system. There is no feedback loop.

So the question became: can the service itself tell you how it behaves, where it slows down or degrades, and also let you tweak and fix it while it runs? Regardless of where it runs. And given where software is heading, the one asking might be a person looking at a dashboard, or an agent on call.

That’s vis.

Signals out, and a way back inTwo pipelines. Observability today: the service exports to a collector, a metrics store and a dashboard, one way, and nothing comes back to the service. With vis: the service with vis inside serves a dashboard and MCP, a person or an agent makes a bounded change, vis measures what the change did, and that goes back into the same service.Signals out, and a way back inExporting sends a service's signals one way. vis keeps them in the binary, next to the knobs.one way outinside the binaryback into the serviceOBSERVABILITY TODAYExport✗ nothing comes backservicecollectormetrics storedashboardWITH VISIn the binary✓ a loopservice + visdashboard ยท MCPbounded changeimpact reportwhat the change did, measured in the same service
Exported signals go one way: the dashboard that shows them can’t change the service. vis keeps the signals in the binary next to the knobs, so a change and its measured effect happen in the same place.

Two lines to see it#

The first step asks for nothing to design: two lines, vis.Start to start vis and vis.HTTP(mux) to wrap your mux.

mux := http.NewServeMux()
mux.HandleFunc("GET /hello", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("hello")) })

ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
if err := vis.Start(ctx, vis.Service("myservice")); err != nil {
	log.Fatal(err)
}
defer vis.Stop()
srv := &http.Server{Addr: ":8080", Handler: vis.HTTP(mux)}
go srv.ListenAndServe()
<-ctx.Done()
srv.Shutdown(context.Background())

Run it and open http://localhost:7071. There is no collector, no exporter and no account anywhere. The dashboard is served by the process it describes, and it shows the p99 of every route over the last hour, CPU and throttling, the scheduler and the GC, memory, and why the last process died if one did.

vis's routes table: each route with a sparkline of its p99 over the last hour, its p99 now and its SLO. GET /images/{id} at 386 ms against 500 ms, then meta, search, upload, healthz and unmatched requests with none.

The routes of an image service under simulated load. Requests no route matched get a row too, so they don’t disappear.

gin and echo get their own middleware, so routes are named the way the router names them.

Where it slows down, and where the memory went#

Latency is judged against an objective once you declare one, as a comment above the handler:

mux.HandleFunc("GET /images/{id}", p.serveImage)

// vis:slo p99=500ms
func (p *Proxy) serveImage(w http.ResponseWriter, r *http.Request) { ... }
How vis judges a routevis's latency chart, redrawn with example numbers: the worst p99 of an image route in each 15 seconds over the last hour, on a log scale, against its 500 ms objective drawn as a red dashed line. For most of the hour p99 runs near 215 ms. About half an hour ago an origin slowdown pushed it over 500 ms, where the ticks turn red. Thirty seconds over 400 ms, the quality_backoff rule stepped jpeg_quality from 95 to 90, and 30 seconds later to 85, which brought the route back under. Ten minutes later the rule's leases ended and jpeg_quality went back to 95.How vis judges a routeGET /images/{id}, the last hour, as vis's dashboard draws it.worst p99, every 15 sover the SLOthe SLO, p99 500 msP99 · NOW 203 MS · WITHIN THE SLO100 ms200 ms1 s2 s500 msquality_backoff: jpeg_quality 95 โ†’ 90 โ†’ 85leases end: back to 951 h ago30 min agonow
vis’s latency chart, redrawn with example numbers. A tick is the worst p99 in its 15 s, on a log scale, and ticks over the objective turn red. When an origin slowdown pushed the route over 500 ms, the quality_backoff rule declared further down stepped jpeg_quality down twice, 30 s apart, and the route came back under. Its leases ended 10 minutes later.

You don’t name the route. The middleware times each request under the route the router matched, and vis gen finds which route the handler is registered under. With the objective, the headline says “All good.” or which route is over its SLO, the latency chart draws the objective, and every change is judged by what it did to that route.

vis's dashboard during a breach: the headline says GET /images/{id} is over its SLO, the p99 chart spikes over the 500 ms line after an hour under it, the rule has stepped jpeg_quality from 95 to 90 under a lease, and Today lists the rule's step and a DEBUG pin on logging.

The same service a minute into a slowdown. quality_backoff has stepped jpeg_quality from 95 to 90 and holds it under a 10 minute lease. It kept stepping until p99 was back under 400 ms.

Most Go services don’t set GOMEMLIMIT, and Go doesn’t set it from a container’s limit. So by default (GOGC=100), Go’s garbage collector lets the heap grow to about twice what the program keeps before it collects. That makes memory hard to read. A heap profile can say 184 MiB in use while the container holds 379, because the profile counts only what the program keeps. The garbage the GC hasn’t collected yet, and the memory the Go runtime holds for itself, aren’t in it.

vis draws the memory against the limit, and forecasts when it gets there: at the rate memory is growing now, a dotted line runs from now to where it meets the limit.

When memory gets to the limitvis's memory chart, redrawn with example numbers: a leaking service's memory since its process started 4 minutes ago, rising from 120 to 379 MiB, about 1.1 MiB a second, against a 512 MiB limit drawn as a red dashed line with a faint band from 85% of it. From now, a dotted forecast runs at that rate to where memory meets the limit, labeled limit in 120 s.When memory gets to the limitA leaking service, the last 10 minutes and the next 3, as vis's dashboard draws it.memory, every 10 sthe limitthe forecast, at the current rateMEMORY IN USE · 379 MIB OF 512256 MiB512 MiBthe process started herelimit in 120 s10 min agonow+3 min
The memory tile on vis’s dashboard, redrawn with example numbers. The faint band starts at 85% of the limit, where vis calls memory short. The forecast assumes memory keeps growing as fast as it does now.

Next to it, the live heap is drawn as a waffle of the limit:

Where the container's 379 MiB wentThe 512 MiB memory limit drawn as 100 cells. 36 cells are the live heap, 184 MiB. 36 cells are garbage the GC allows before it collects, 185 MiB. 2 cells are the rest in use, 10 MiB. 26 cells are free, 133 MiB. Without GOMEMLIMIT the heap reaches about twice what the program keeps.Where the container's 379 MiB wentcacheproxy at 15:38 UTC: cache_size 150, the leak on, no GOMEMLIMIT.THE 512 MIB LIMIT IN 100 CELLSlive heapwhat the program keeps184 MiB36 cellsgarbage the GC allowsnot yet collected185 MiB36 cellsthe rest in useoutside the heap10 MiB2 cellsfreebefore the kill133 MiB26 cellsWithout GOMEMLIMIT the GC lets the heapreach abouttwicewhat the program keeps.
The live-heap tile on vis’s dashboard, redrawn: the memory limit as 100 cells. About as much garbage as live heap, because GOMEMLIMIT isn’t set.

It isn’t tied to containers. In a cgroup (a container, a Kubernetes pod, a systemd unit with MemoryMax) it reads the cgroup. Outside one it reads what the Go runtime holds, and the limit is the platform’s memory size where vis can read it (AWS Lambda’s, today) or GOMEMLIMIT. With no limit at all, you still get the memory and the live heap, just no forecast of when it runs out.

A process killed for memory gets no chance to say so. So vis keeps a short note of its last readings, written every couple of seconds to the temp dir (on Kubernetes, point VIS_STATE_DIR at an emptyDir; in a fleet, its peers keep the readings too). When a process dies without stopping cleanly, the one that replaces it reads the note and tells you on the dashboard: “most likely killed for memory”, its last reading, and the values set at runtime that the restart dropped.

Tweak and fix while it runs#

A knob is a setting you declare as changeable at runtime, within a range. The declarations are comments that vis’s tool turns into code, so add the tool to your module once:

go get -tool github.com/tfcace/vis/cmd/vis
//go:generate go tool vis gen

// vis:knob range=1..16384 default=100 unit=MB uses=memory pull=agent
var CacheSize vis.Int // Memory for cached images.

// vis:knob range=1..100 default=95 uses=cpu pull=agent,rule
// vis:rule name=quality_backoff when="slo.p99 > 400ms" for=30s do=step(-5) cooldown=30s lease=10m
var JPEGQuality vis.Int // JPEG quality of resized images.

// vis:knob pull=agent
var Logging vis.LogLevel // What the service logs.

A log level is a knob too. vis.LogLevel is a slog.Leveler, so giving it to the handler (slog.HandlerOptions{Level: Logging}) is all the wiring it needs.

The rule watches slo.p99, the objective declared by the // vis:slo above, so it lives in the same package. go generate turns the comments into ordinary Go in a vis_gen.go you check in, and go tool vis vet catches the mistakes that compile but are wrong. The declaration is reviewed code: the range, the default and who may change it (pull=agent) don’t change at runtime. Only the value does.

Every change to a value is bounded by that range, carries a lease so it ends on its own, and goes to an audit trail with who made it and why. A change sits on a layer (a person’s pin, a rule, an agent, a fleet rollout), so a person’s value wins over an agent’s, and removing one falls back to the layer below. A freeze stops every automated change with one click, and says who froze it and why.

The logging knob on vis's dashboard, turned from INFO to DEBUG: who holds it, a 30 minute lease, dropped on restart, the reason, and the plan before applying it, with the same change as an MCP set_knob call.

Turning logging up to DEBUG on the dashboard. Before anything changes, the plan says what will hold and for how long, and shows the same change as an agent would send it.

And then the loop closes. About 30 seconds after a change, vis reports what it did: the route’s p99 before and after, CPU, memory, the service’s own signals, and anything else that changed in the same window that might be the real cause. That’s the part I missed in every one-way setup. The answer to “did that help?” comes from the same place the change went to.

vis's Today panel: rule quality_backoff moved jpeg_quality from 95 to 80, its first step measured at p99 705 to 638 ms after 30 s; a person pinned logging to DEBUG with a reason, measured at no change in p99.

Every change gets measured, the rule’s and the person’s. The rule’s first step took p99 from 705 to 638 ms. DEBUG logging made no difference to this route’s p99.

For a person, and for an agent#

The dashboard is for the person on call. The same state is served over MCP for an agent, at http://127.0.0.1:7070 (localhost only by default, like the dashboard). Its tools are describe, metrics, profile, history, impact, set_knob, revert and a few more. Without tokens it’s read-only, and an agent can only act with a token granted to act:

VIS_TOKENS=s3cret=agent:oncall:act go run .

The token s3cret makes whoever sends it an agent named oncall, which may act. Every change it makes is recorded as agent:oncall, and dropping :act makes the token read-only.

I didn’t want two products here. A change an agent makes shows up on the dashboard with its reason, its lease and its measured effect, the same as one made by a person.

How I checked it was any good#

I could have convinced myself of anything with a demo, so most of the work went into testing vis on services and seeing where it broke. Four services, each testing something different:

  1. cacheproxy is a small HTTP cache Claude wrote for vis, with faults I can inject. It’s where the on-call evals run: an agent gets paged with nothing but “the container restarted”, vis’s MCP tools and the service’s source, and is scored on what it does and on what happens after. It’s also where control got designed. Rules judged by the objective, steps by a percent of the value, and impact reports all came out of those evals.
  2. imageproxy (willnorris/imageproxy) tested adoption. An agent gets the service and go doc for vis, and nothing else. In the first scored round none of the 3 agent runs adopted it cleanly, and they found two things vis got wrong: the guide’s own main ignored Ctrl-C and SIGTERM, and a knob had no way to say its 0 means none. After the fixes all 3 runs were clean, about a minute each.
  3. Ollama is a fork I adopted vis into from the outside, and it found what adoption needs that cacheproxy never could: a Go version a real service already has, gin routes, configuration from environment variables, a port another vis already holds, and a dashboard that tells the truth before anything is declared. It’s also the showcase video: two lines, a few comments, a log level changed while Ollama runs, and an agent on call that raises max_loaded_models under a lease until p99 on generate comes back under 300 ms.
  4. of-watchdog (openfaas/of-watchdog) is a service none of the guide was written from. All 3 agent runs adopted it cleanly. Every agent made its concurrency cap a knob by writing a small limiter that reads it per request, which is also why vis doesn’t ship its own limiter yet.

The on-call evals are where I learned the most, mostly by being wrong. On an early build, an agent read a heap profile, saw 214 MiB in use with the container near its memory limit, and concluded the cache didn’t respect its size. It reverted its own fix and left the service in a crash loop. Another one called the service stable until its lease ended, and it was killed 77 seconds later. Each of those became something vis now says plainly: the forecast to the limit, the gap between the heap and the container, the value a restart dropped.

What it won’t do#

It doesn’t replace OpenTelemetry. If your team already runs a metrics stack, vis is a second place to look for now. An opt-in Prometheus export is on the list, once someone asks for it.

Runtime values are volatile on purpose. A value set while the service runs ends with its lease, and a restart drops it. The one exception is a value its writer asks to keep: vis sets it back after a restart for what is left of its lease, unless it’s what kills the fresh process. Making a value permanent means changing the default in code. Closing that loop too, turning the values that held into pull requests that change the default, and production profiles into PGO builds, is on the backlog.

The dashboard has no login. It listens on localhost, and you reach it from another machine through SSH or kubectl port-forward.

It’s Go only. The fleet support (members that gossip, compare and roll a change out in stages) works, but I’m calling it experimental. Code weaving, where vis inserts its hooks at build time instead of you running go generate, is still on the roadmap.

Try it#

vis is MIT licensed, at github.com/tfcace/vis. The README’s first example is the one above.

What I can’t test on my own is the part that matters most: a team I don’t know putting it on a service I’ve never seen, and still using it a couple of weeks later. If you run a Go service, and especially one without a metrics stack of its own, I’d love for you to try it. Tell me what broke, what you expected it to say and it didn’t, or that it just worked. If there’s anything I can do to help you get started, please let me know.