From 1ba190ea57e54983fa934b0b01b2302b60e3f2c6 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Mon, 25 Nov 2019 11:39:21 +0100 Subject: Use regular function to count RPC types --- internal/middleware/cache/prometheus.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/internal/middleware/cache/prometheus.go b/internal/middleware/cache/prometheus.go index 949945382..87ae7bfca 100644 --- a/internal/middleware/cache/prometheus.go +++ b/internal/middleware/cache/prometheus.go @@ -37,16 +37,17 @@ func init() { // counter functions are package vars to allow for overriding in tests var ( countMethodErr = func(method string) { methodErrTotals.WithLabelValues(method).Inc() } - countRPCType = func(mInfo protoregistry.MethodInfo) { - rpcTotal.Inc() +) + +func countRPCType(mInfo protoregistry.MethodInfo) { + rpcTotal.Inc() - switch mInfo.Operation { - case protoregistry.OpAccessor: - rpcOpTypes.WithLabelValues("accessor").Inc() - case protoregistry.OpMutator: - rpcOpTypes.WithLabelValues("mutator").Inc() - default: - rpcOpTypes.WithLabelValues("unknown").Inc() - } + switch mInfo.Operation { + case protoregistry.OpAccessor: + rpcOpTypes.WithLabelValues("accessor").Inc() + case protoregistry.OpMutator: + rpcOpTypes.WithLabelValues("mutator").Inc() + default: + rpcOpTypes.WithLabelValues("unknown").Inc() } -) +} -- cgit v1.2.3