Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Okstad <pokstad@gitlab.com>2019-08-02 23:18:23 +0300
committerPaul Okstad <pokstad@gitlab.com>2019-08-02 23:31:43 +0300
commitd491e954b5f79fbc212d3d7f8e20bce6b3e1b88c (patch)
treee0d83da393f526032dfe278e5439ca8d5fe69580
parent0d1a48777ccee82960e1fa1beede6b6b226d1c5e (diff)
New counter for method errors
-rw-r--r--internal/middleware/cache/cache.go35
-rw-r--r--internal/middleware/cache/prometheus.go52
2 files changed, 52 insertions, 35 deletions
diff --git a/internal/middleware/cache/cache.go b/internal/middleware/cache/cache.go
index e39806c7d..6fcd48b81 100644
--- a/internal/middleware/cache/cache.go
+++ b/internal/middleware/cache/cache.go
@@ -6,7 +6,6 @@ import (
"sync"
"github.com/golang/protobuf/proto"
- "github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"
diskcache "gitlab.com/gitlab-org/gitaly/internal/cache"
"gitlab.com/gitlab-org/gitaly/internal/praefect/protoregistry"
@@ -14,40 +13,6 @@ import (
"google.golang.org/grpc"
)
-var (
- rpcTotal = prometheus.NewCounter(
- prometheus.CounterOpts{
- Name: "gitaly_cacheinvalidator_rpc_total",
- Help: "Total number of RPCs encountered by cache invalidator",
- },
- )
- rpcOpTypes = prometheus.NewCounterVec(
- prometheus.CounterOpts{
- Name: "gitaly_cacheinvalidator_optype_total",
- Help: "Total number of operation types encountered by cache invalidator",
- },
- []string{"type"},
- )
-)
-
-func init() {
- prometheus.MustRegister(rpcTotal)
- prometheus.MustRegister(rpcOpTypes)
-}
-
-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()
- }
-}
-
// Invalidator is able to invalidate parts of the cache pertinent to a
// specific repository. Before a repo mutating operation, StartLease should
// be called. Once the operation is complete, the returned LeaseEnder should
diff --git a/internal/middleware/cache/prometheus.go b/internal/middleware/cache/prometheus.go
new file mode 100644
index 000000000..3cabfe9b5
--- /dev/null
+++ b/internal/middleware/cache/prometheus.go
@@ -0,0 +1,52 @@
+package cache
+
+import (
+ "github.com/prometheus/client_golang/prometheus"
+ "gitlab.com/gitlab-org/gitaly/internal/praefect/protoregistry"
+)
+
+var (
+ rpcTotal = prometheus.NewCounter(
+ prometheus.CounterOpts{
+ Name: "gitaly_cacheinvalidator_rpc_total",
+ Help: "Total number of RPCs encountered by cache invalidator",
+ },
+ )
+ rpcOpTypes = prometheus.NewCounterVec(
+ prometheus.CounterOpts{
+ Name: "gitaly_cacheinvalidator_optype_total",
+ Help: "Total number of operation types encountered by cache invalidator",
+ },
+ []string{"type"},
+ )
+ methodErrTotals = prometheus.NewCounterVec(
+ prometheus.CounterOpts{
+ Name: "gitaly_cache_invalidator_error_total",
+ Help: "Total number of cache invalidation errors by method",
+ },
+ []string{"method"},
+ )
+)
+
+func init() {
+ prometheus.MustRegister(rpcTotal)
+ prometheus.MustRegister(rpcOpTypes)
+ prometheus.MustRegister(methodErrTotals)
+}
+
+// countMethodErr is a package var to allow for overriding in tests
+var (
+ countMethodErr = func(method string) { methodErrTotals.WithLabelValues(method).Add(1) }
+ countRPCType = func(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()
+ }
+ }
+)