From d837bac67a0da44ed5a7333646af9cdea6a7249a Mon Sep 17 00:00:00 2001 From: Scott Kinghorn Date: Wed, 9 Sep 2026 13:18:10 -0700 Subject: [PATCH] docs: fix Prometheus README snippet, remove nonexistent NewHandler() Handler has never had a NewHandler constructor at any version (confirmed back through v4.7.2) -- it's a plain struct, used via a literal or the package's own DefaultHandler var. This snippet was added in 7e7070d alongside the OTLP exporter and appears to be a copy-paste from otlp.NewHandler (a real constructor on that subpackage). Anyone following the README as written gets a compile error. Co-Authored-By: Claude Sonnet 5 --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ed4af80..e41627f 100644 --- a/README.md +++ b/README.md @@ -197,11 +197,14 @@ import ( "github.com/segmentio/stats/v5/prometheus" ) -handler := prometheus.NewHandler() -stats.Register(handler) -http.Handle("/metrics", handler) +stats.Register(prometheus.DefaultHandler) +http.Handle("/metrics", prometheus.DefaultHandler) ``` +`Handler` has no `NewHandler` constructor; `DefaultHandler` is a ready-to-use zero-config +instance. Construct your own `&prometheus.Handler{}` literal instead if you need to set +`TrimPrefix`, `MetricTimeout`, or `Buckets`. + ### InfluxDB The [github.com/segmentio/stats/v5/influxdb](https://godoc.org/github.com/segmentio/stats/v5/influxdb) package sends metrics to InfluxDB using the line protocol over HTTP.