Skip to content

Commit bb228f0

Browse files
fixing Refresh client_golang examples prometheus#1652
Signed-off-by: samuelgrant123 <[email protected]>
1 parent 9138a91 commit bb228f0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

examples/random/main.go

+25
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import (
3333
type metrics struct {
3434
rpcDurations *prometheus.SummaryVec
3535
rpcDurationsHistogram prometheus.Histogram
36+
rpcRequests *prometheus.CounterVec
37+
activeRpcs *prometheus.GaugeVec
3638
}
3739

3840
func NewMetrics(reg prometheus.Registerer, normMean, normDomain float64) *metrics {
@@ -65,9 +67,32 @@ func NewMetrics(reg prometheus.Registerer, normMean, normDomain float64) *metric
6567
Buckets: prometheus.LinearBuckets(normMean-5*normDomain, .5*normDomain, 20),
6668
NativeHistogramBucketFactor: 1.1,
6769
}),
70+
71+
//Adding the counter metric type
72+
rpcRequests: prometheus.NewCounterVec(
73+
prometheus.CounterOpts{
74+
Name: "rpc_requests_total",
75+
Help: "RPC request distributions.",
76+
},
77+
[]string{"service"},
78+
),
79+
80+
//Adding the gauge metric type
81+
activeRpcs: prometheus.NewGaugeVec(
82+
prometheus.GaugeOpts{
83+
Name: "rpc_active_calls",
84+
Help: "RPC call distributions.",
85+
},
86+
[]string{"service"},
87+
),
6888
}
89+
6990
reg.MustRegister(m.rpcDurations)
7091
reg.MustRegister(m.rpcDurationsHistogram)
92+
//Registering the counter vec
93+
reg.MustRegister(m.rpcRequests)
94+
//Registing the gauge vec
95+
reg.MustRegister(m.activeRpcs)
7196
return m
7297
}
7398

0 commit comments

Comments
 (0)