mirror of
https://github.com/go-gitea/gitea.git
synced 2025-02-02 15:09:33 -05:00
feat(metrics): add use labels in cache response
This commit is contained in:
parent
3e06c39d2f
commit
c666f4d9cc
47
modules/cache/cache.go
vendored
47
modules/cache/cache.go
vendored
@ -9,32 +9,39 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||||
|
|
||||||
_ "gitea.com/go-chi/cache/memcache" //nolint:depguard // memcache plugin for cache, it is required for config "ADAPTER=memcache"
|
_ "gitea.com/go-chi/cache/memcache" //nolint:depguard // memcache plugin for cache, it is required for config "ADAPTER=memcache"
|
||||||
)
|
)
|
||||||
|
|
||||||
var defaultCache StringCache
|
var (
|
||||||
var hitCounter = promauto.NewCounter(prometheus.CounterOpts{
|
defaultCache StringCache
|
||||||
Namespace: "gitea",
|
|
||||||
Help: "Cache hit count",
|
// TODO: Combine hit and miss into one
|
||||||
Subsystem: "cache",
|
hitCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||||||
Name: "hit",
|
Namespace: "gitea",
|
||||||
})
|
Help: "Cache count",
|
||||||
var missCounter = promauto.NewCounter(prometheus.CounterOpts{
|
Subsystem: "cache",
|
||||||
Namespace: "gitea",
|
Name: "response",
|
||||||
Help: "Cache miss count",
|
ConstLabels: prometheus.Labels{"state": "hit"},
|
||||||
Subsystem: "cache",
|
})
|
||||||
Name: "miss",
|
missCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||||||
})
|
Namespace: "gitea",
|
||||||
var latencyHistogram = promauto.NewHistogram(
|
Help: "Cache count",
|
||||||
prometheus.HistogramOpts{
|
Subsystem: "cache",
|
||||||
Namespace: "gitea",
|
Name: "response",
|
||||||
Help: "Cache latency",
|
ConstLabels: prometheus.Labels{"state": "miss"},
|
||||||
Subsystem: "cache",
|
})
|
||||||
Name: "duration",
|
latencyHistogram = promauto.NewHistogram(
|
||||||
},
|
prometheus.HistogramOpts{
|
||||||
|
Namespace: "gitea",
|
||||||
|
Help: "Cache latency",
|
||||||
|
Subsystem: "cache",
|
||||||
|
Name: "duration",
|
||||||
|
},
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
// Init start cache service
|
// Init start cache service
|
||||||
|
Loading…
Reference in New Issue
Block a user