Send a custom metric from Go
One small function with net/http and a context timeout: a counter and a gauge over plain HTTPS. EzStat creates the stat on the first call, draws the chart, and exports CSV or JSON on request. No agent, no collector, no client library.
Free: 10 stats, 300,000 datapoints a month, no card, open to the first 250 accounts. Paid plans are $19, $49 or $99 a month, and every paid plan tracks 10,000 stats. Prices are flat and monthly, in USD, + tax where applicable. /pricing is the source of truth. Alerts on paid plans, by webhook or Slack, checked periodically — not instant.
Before you start
Create an account and copy your API key (shown once) into EZSTAT_API_KEY. The key works at once, with one stat and 500 datapoints a day until you confirm your email address; confirm within 7 days to keep sending. The examples below write more than one stat, so confirm before you run them all.
Record a counter or a gauge
package main
import (
"bytes"
"context"
"fmt"
"net/http"
"net/url"
"os"
"time"
)
const api = "https://api.ezstat.dev/api/v1/stats"
func track(ctx context.Context, stat, kind, jsonBody string) error {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
endpoint := fmt.Sprintf("%s/%s/%s", api, url.PathEscape(stat), kind)
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, bytes.NewBufferString(jsonBody))
if err != nil {
return err
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("EZSTAT_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
return err // no response: the outcome is unknown, not "dropped"
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
return fmt.Errorf("ezstat rejected the point: HTTP %d", res.StatusCode)
}
return nil
}
func main() {
ctx := context.Background()
if err := track(ctx, "signups", "count", `{"count":1}`); err != nil {
fmt.Fprintln(os.Stderr, err)
}
if err := track(ctx, "checkout_ms", "value", `{"value":142}`); err != nil {
fmt.Fprintln(os.Stderr, err)
}
}A counter is a running total; a gauge is a measurement at a moment in time. A stat is one or the other, never both, so stay with /count or /value for each stat.
A timeout is not a failure
No response means the outcome is unknown: the server may have stored the point before the connection dropped. A non-200 status means it was not stored. The helper returns the error either way, so decide per call site whether a metric is worth a retry — and never block a request on it.
Make a retry safe
De-duplication keys on stat + timestamp + ikey, so a retry is stored once when every attempt carries the same explicit timestamp and the same ikey. An ikey without a timestamp does not protect you: each attempt is then stamped on arrival and stored again.
// Retry-safe: the same timestamp + ikey on every attempt for one logical event.
err := track(ctx, "orders", "count",
`{"count":1,"timestamp":"2026-12-03T09:15:00Z","ikey":"order-9831"}`)The timestamp is a date string or epoch milliseconds, and the ikey is at most 128 printable ASCII characters. Rules: /docs#replay-semantics.
Price and limits
Free: 10 stats, 300,000 datapoints a month, no card, open to the first 250 accounts. Paid plans are $19, $49 or $99 a month and every paid plan tracks 10,000 stats; the history you can see and export is 30 days on Free and Indie, 1 year on Pro, 3 years on Scale. A stat is one named metric. See the full table.
Other languages
The same two calls in Python, Node.js and curl. Coming from StatHat? /migrate/stathat keeps your existing calls working. Weighing this against a full observability suite? /datadog-alternative compares the two honestly.
Questions
How do I send a custom metric from Go?
Build a POST with http.NewRequestWithContext, set Authorization: Bearer <key> and Content-Type: application/json, and send {"count":1} to https://api.ezstat.dev/api/v1/stats/signups/count. Use /value with {"value":142} for a gauge. A status of 200 means the point was stored. Use context.WithTimeout so a slow call cannot block your service, and read the key from the environment.
What does a Go timeout mean for a metric write?
It means the outcome is unknown. A timeout or a connection reset can happen after EzStat stored the point, so it is not proof the write failed. A non-200 status means it was not stored. To retry safely, send the same explicit timestamp and idempotency key (ikey) on every attempt.
Does EzStat have a Go SDK?
No, and you do not need one. The API is plain HTTPS with a Bearer token and JSON, so the standard library net/http is enough. There is no agent or collector to run. A stat is created by its first write and appears on an automatic chart.
How do I send a gauge instead of a counter?
POST {"value":142} to /api/v1/stats/{name}/value. A stat is either a counter or a gauge, so stay with /count or /value for each stat.
What are the plan limits?
A stat is one named metric. Free: 10 stats, 300,000 datapoints a month, no card, open to the first 250 accounts. Paid plans start at $19 a month, every paid plan allows 10,000 stats, and the history you can see and export is 30 days on Free and Indie, 1 year on Pro, 3 years on Scale.