|
1 | 1 | package server |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "github.com/prometheus/client_golang/prometheus" |
5 | 4 | "strings" |
| 5 | + |
| 6 | + "github.com/prometheus/client_golang/prometheus" |
6 | 7 | ) |
7 | 8 |
|
8 | 9 | var ( |
| 10 | + buildInfoGaugeVec = prometheus.NewGaugeVec( |
| 11 | + prometheus.GaugeOpts{ |
| 12 | + Name: "sidecache_admission_build_info", |
| 13 | + Help: "Build info for sidecache admission webhook", |
| 14 | + }, []string{"version"}) |
| 15 | + |
9 | 16 | cacheHitCounter = prometheus.NewCounter( |
10 | 17 | prometheus.CounterOpts{ |
11 | 18 | Namespace: "sidecache_" + ProjectName, |
12 | 19 | Name: "cache_hit_counter", |
13 | 20 | Help: "Cache hit count", |
14 | 21 | }) |
15 | 22 |
|
| 23 | + lockAcquiringAttemptsHistogram = prometheus.NewHistogram( |
| 24 | + prometheus.HistogramOpts{ |
| 25 | + Namespace: "sidecache_" + ProjectName, |
| 26 | + Name: "lock_acquiring_attempts_histogram", |
| 27 | + Help: "Lock acquiring attempts histogram", |
| 28 | + Buckets: []float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 100}, |
| 29 | + }) |
| 30 | + |
16 | 31 | totalRequestCounter = prometheus.NewCounter( |
17 | 32 | prometheus.CounterOpts{ |
18 | 33 | Namespace: "sidecache_" + ProjectName, |
19 | 34 | Name: "all_request_hit_counter", |
20 | 35 | Help: "All request hit counter", |
21 | 36 | }) |
22 | | - |
23 | | - buildInfoGaugeVec = prometheus.NewGaugeVec( |
24 | | - prometheus.GaugeOpts{ |
25 | | - Name: "sidecache_admission_build_info", |
26 | | - Help: "Build info for sidecache admission webhook", |
27 | | - }, []string{"version"}) |
28 | 37 | ) |
29 | 38 |
|
30 | 39 | type Prometheus struct { |
31 | | - CacheHitCounter prometheus.Counter |
32 | | - TotalRequestCounter prometheus.Counter |
| 40 | + CacheHitCounter prometheus.Counter |
| 41 | + LockAcquiringAttemptsHistogram prometheus.Histogram |
| 42 | + TotalRequestCounter prometheus.Counter |
33 | 43 | } |
34 | 44 |
|
35 | 45 | func NewPrometheusClient() *Prometheus { |
36 | | - prometheus.MustRegister(cacheHitCounter, totalRequestCounter, buildInfoGaugeVec) |
| 46 | + prometheus.MustRegister(buildInfoGaugeVec, cacheHitCounter, lockAcquiringAttemptsHistogram, totalRequestCounter) |
37 | 47 |
|
38 | | - return &Prometheus{TotalRequestCounter: totalRequestCounter, CacheHitCounter: cacheHitCounter} |
| 48 | + return &Prometheus{ |
| 49 | + CacheHitCounter: cacheHitCounter, |
| 50 | + LockAcquiringAttemptsHistogram: lockAcquiringAttemptsHistogram, |
| 51 | + TotalRequestCounter: totalRequestCounter, |
| 52 | + } |
39 | 53 | } |
40 | 54 |
|
41 | 55 | func BuildInfo(admission string) { |
|
0 commit comments