summaryrefslogtreecommitdiff
path: root/vendor/github.com/authzed/spicedb/pkg/promutil/promutil.go
blob: 57592a8ec4809ea70564f4affe9b64fbacf9cf4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package promutil

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.
type CollectorFunc func(ch chan<- prometheus.Metric)

func (c CollectorFunc) Collect(ch chan<- prometheus.Metric) { c(ch) }
func (c CollectorFunc) Describe(ch chan<- *prometheus.Desc) { prometheus.DescribeByCollect(c, ch) }