@@ -43,44 +43,48 @@ const (
43
43
metricsSubsystem = "discovery"
44
44
metricLabelCacheName = "cache_name"
45
45
metricLabelMethod = "method"
46
+ metricBuildVersion = "build_version"
46
47
)
47
48
48
49
var (
50
+ // Save the build version information.
51
+ buildVersion = version .Line ()
52
+
49
53
cacheSizeGauge = prometheus .NewGaugeVec (
50
54
prometheus.GaugeOpts {
51
55
Namespace : metricsNamespace ,
52
56
Subsystem : metricsSubsystem ,
53
57
Name : "cache_size" ,
54
58
Help : "Current size (in bytes) of a single cache within Pilot" ,
55
- }, []string {metricLabelCacheName })
59
+ }, []string {metricLabelCacheName , metricBuildVersion })
56
60
cacheHitCounter = prometheus .NewCounterVec (
57
61
prometheus.CounterOpts {
58
62
Namespace : metricsNamespace ,
59
63
Subsystem : metricsSubsystem ,
60
64
Name : "cache_hit" ,
61
65
Help : "Count of cache hits for a particular cache within Pilot" ,
62
- }, []string {metricLabelCacheName })
66
+ }, []string {metricLabelCacheName , metricBuildVersion })
63
67
cacheMissCounter = prometheus .NewCounterVec (
64
68
prometheus.CounterOpts {
65
69
Namespace : metricsNamespace ,
66
70
Subsystem : metricsSubsystem ,
67
71
Name : "cache_miss" ,
68
72
Help : "Count of cache misses for a particular cache within Pilot" ,
69
- }, []string {metricLabelCacheName })
73
+ }, []string {metricLabelCacheName , metricBuildVersion })
70
74
callCounter = prometheus .NewCounterVec (
71
75
prometheus.CounterOpts {
72
76
Namespace : metricsNamespace ,
73
77
Subsystem : metricsSubsystem ,
74
78
Name : "calls" ,
75
79
Help : "Counter of individual method calls in Pilot" ,
76
- }, []string {metricLabelMethod })
80
+ }, []string {metricLabelMethod , metricBuildVersion })
77
81
errorCounter = prometheus .NewCounterVec (
78
82
prometheus.CounterOpts {
79
83
Namespace : metricsNamespace ,
80
84
Subsystem : metricsSubsystem ,
81
85
Name : "errors" ,
82
86
Help : "Counter of errors encountered during a given method call within Pilot" ,
83
- }, []string {metricLabelMethod })
87
+ }, []string {metricLabelMethod , metricBuildVersion })
84
88
85
89
resourceBuckets = []float64 {0 , 10 , 20 , 30 , 40 , 50 , 75 , 100 , 150 , 250 , 500 , 1000 , 10000 }
86
90
resourceCounter = prometheus .NewHistogramVec (
90
94
Name : "resources" ,
91
95
Help : "Histogram of returned resource counts per method by Pilot" ,
92
96
Buckets : resourceBuckets ,
93
- }, []string {metricLabelMethod })
97
+ }, []string {metricLabelMethod , metricBuildVersion })
94
98
)
95
99
96
100
func init () {
@@ -232,6 +236,7 @@ func (c *discoveryCache) stats() map[string]*discoveryCacheStatEntry {
232
236
func (c * discoveryCache ) cacheSizeLabels () prometheus.Labels {
233
237
return prometheus.Labels {
234
238
metricLabelCacheName : c .name ,
239
+ metricBuildVersion : buildVersion ,
235
240
}
236
241
}
237
242
@@ -707,15 +712,24 @@ func (ds *DiscoveryService) ListRoutes(request *restful.Request, response *restf
707
712
}
708
713
709
714
func incCalls (methodName string ) {
710
- callCounter .With (prometheus.Labels {metricLabelMethod : methodName }).Inc ()
715
+ callCounter .With (prometheus.Labels {
716
+ metricLabelMethod : methodName ,
717
+ metricBuildVersion : buildVersion ,
718
+ }).Inc ()
711
719
}
712
720
713
721
func incErrors (methodName string ) {
714
- errorCounter .With (prometheus.Labels {metricLabelMethod : methodName }).Inc ()
722
+ errorCounter .With (prometheus.Labels {
723
+ metricLabelMethod : methodName ,
724
+ metricBuildVersion : buildVersion ,
725
+ }).Inc ()
715
726
}
716
727
717
728
func observeResources (methodName string , count uint32 ) {
718
- resourceCounter .With (prometheus.Labels {metricLabelMethod : methodName }).Observe (float64 (count ))
729
+ resourceCounter .With (prometheus.Labels {
730
+ metricLabelMethod : methodName ,
731
+ metricBuildVersion : buildVersion ,
732
+ }).Observe (float64 (count ))
719
733
}
720
734
721
735
func errorResponse (methodName string , r * restful.Response , status int , msg string ) {
0 commit comments