...
1 package grpc_prometheus
2
3 import (
4 prom "github.com/prometheus/client_golang/prometheus"
5 )
6
7
8 type CounterOption func(*prom.CounterOpts)
9
10 type counterOptions []CounterOption
11
12 func (co counterOptions) apply(o prom.CounterOpts) prom.CounterOpts {
13 for _, f := range co {
14 f(&o)
15 }
16 return o
17 }
18
19
20 func WithConstLabels(labels prom.Labels) CounterOption {
21 return func(o *prom.CounterOpts) {
22 o.ConstLabels = labels
23 }
24 }
25
26
27
28 type HistogramOption func(*prom.HistogramOpts)
29
30
31 func WithHistogramBuckets(buckets []float64) HistogramOption {
32 return func(o *prom.HistogramOpts) { o.Buckets = buckets }
33 }
34
35
36
37 func WithHistogramConstLabels(labels prom.Labels) HistogramOption {
38 return func(o *prom.HistogramOpts) {
39 o.ConstLabels = labels
40 }
41 }
42
View as plain text