You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've used this helper in a few places and wondered if there's interest upstream. Basically, I'm applying a similar pattern to http.Handler/http.HandlerFunc so that you only need to implement one function to implement Collector:
import"github.com/prometheus/client_golang/prometheus"var_ prometheus.Collector= (CollectorFunc)(nil)
// CollectorFunc is a convenient way to implement a Prometheus Collector// without interface boilerplate.//// This implementation relies on prometheus.DescribeByCollect; familiarize// yourself with that documentation before using.typeCollectorFuncfunc(chchan<- prometheus.Metric)
func (cCollectorFunc) Collect(chchan<- prometheus.Metric) { c(ch) }
func (cCollectorFunc) Describe(chchan<-*prometheus.Desc) { prometheus.DescribeByCollect(c, ch) }
The text was updated successfully, but these errors were encountered:
I've used this helper in a few places and wondered if there's interest upstream. Basically, I'm applying a similar pattern to
http.Handler
/http.HandlerFunc
so that you only need to implement one function to implementCollector
:The text was updated successfully, but these errors were encountered: