1package grpc_prometheus
2
3import (
4	prom "github.com/prometheus/client_golang/prometheus"
5)
6
7// A CounterOption lets you add options to Counter metrics using With* funcs.
8type CounterOption func(*prom.CounterOpts)
9
10type counterOptions []CounterOption
11
12func (co counterOptions) apply(o prom.CounterOpts) prom.CounterOpts {
13	for _, f := range co {
14		f(&o)
15	}
16	return o
17}
18
19// WithConstLabels allows you to add ConstLabels to Counter metrics.
20func WithConstLabels(labels prom.Labels) CounterOption {
21	return func(o *prom.CounterOpts) {
22		o.ConstLabels = labels
23	}
24}
25
26// A HistogramOption lets you add options to Histogram metrics using With*
27// funcs.
28type HistogramOption func(*prom.HistogramOpts)
29
30// WithHistogramBuckets allows you to specify custom bucket ranges for histograms if EnableHandlingTimeHistogram is on.
31func WithHistogramBuckets(buckets []float64) HistogramOption {
32	return func(o *prom.HistogramOpts) { o.Buckets = buckets }
33}
34
35// WithHistogramConstLabels allows you to add custom ConstLabels to
36// histograms metrics.
37func WithHistogramConstLabels(labels prom.Labels) HistogramOption {
38	return func(o *prom.HistogramOpts) {
39		o.ConstLabels = labels
40	}
41}
42