Skip to content

Commit d837bac

Browse files
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 <noreply@anthropic.com>
1 parent 56b5b31 commit d837bac

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,14 @@ import (
197197
"github.com/segmentio/stats/v5/prometheus"
198198
)
199199

200-
handler := prometheus.NewHandler()
201-
stats.Register(handler)
202-
http.Handle("/metrics", handler)
200+
stats.Register(prometheus.DefaultHandler)
201+
http.Handle("/metrics", prometheus.DefaultHandler)
203202
```
204203

204+
`Handler` has no `NewHandler` constructor; `DefaultHandler` is a ready-to-use zero-config
205+
instance. Construct your own `&prometheus.Handler{}` literal instead if you need to set
206+
`TrimPrefix`, `MetricTimeout`, or `Buckets`.
207+
205208
### InfluxDB
206209

207210
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.

0 commit comments

Comments
 (0)