Live analytics for your Go service
Live analytics for Go: middleware for net/http, chi, Gin and Echo sends crawler visits, 404s, panics, response times and your own events, with the standard library only.
One middleware
go get github.com/mettrhq/mettr-go
client := mettr.New(mettr.Options{}) defer client.Close() http.ListenAndServe(":8080", client.Middleware(mux))
Gin and Echo have their own (mettrgin, mettrecho); chi and gorilla/mux take the net/http one. It reads METTR_SECRET_KEY and METTR_PUBLIC_KEY. Go 1.23 or later, the standard library only.
What it sends on its own
- Crawler visits, with their page and status: search engines and AI crawlers seldom run the browser script, so only your server sees them.
- 404s of people, as errors.
- Panics, by their type only, never the message; then the panic goes on.
- Response times of one request in twenty, by the route's pattern.
- The browser script, served from
/_liveon your own domain withclient.ScriptTag(): page views and who is online, past most ad blockers.
Your own events
mettr.SetUser(r.Context(), user.ID) client.Event(r.Context(), "signup", mettr.Props{"plan": "pro"})
Events wait a second to go together, off the request's path. Sending never panics into your app.
Revenue, history and deploys
Billing of your own? client.Subscription sends each subscription as it changes, and mettr works out MRR, churn and revenue by source. client.Import brings your history, and client.Annotation marks a deploy under the traffic chart.
Open source
mettr-go is MIT licensed, on GitHub and pkg.go.dev. The full guide.
Read on
See your site live in two minutes
Free for one site. No card, no cookie banner