Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d8461e6

Browse files
Nathan Mittleristio-merge-robot
authored andcommitted
[pilot] Adding build version to pilot metrics (istio#2167)
Automatic merge from submit-queue. [pilot] Adding build version to pilot metrics **What this PR does / why we need it**: **Which issue this PR fixes** **Special notes for your reviewer**: **Release note**: ```release-note ```
1 parent 15afbf2 commit d8461e6

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

pilot/proxy/envoy/discovery.go

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,44 +43,48 @@ const (
4343
metricsSubsystem = "discovery"
4444
metricLabelCacheName = "cache_name"
4545
metricLabelMethod = "method"
46+
metricBuildVersion = "build_version"
4647
)
4748

4849
var (
50+
// Save the build version information.
51+
buildVersion = version.Line()
52+
4953
cacheSizeGauge = prometheus.NewGaugeVec(
5054
prometheus.GaugeOpts{
5155
Namespace: metricsNamespace,
5256
Subsystem: metricsSubsystem,
5357
Name: "cache_size",
5458
Help: "Current size (in bytes) of a single cache within Pilot",
55-
}, []string{metricLabelCacheName})
59+
}, []string{metricLabelCacheName, metricBuildVersion})
5660
cacheHitCounter = prometheus.NewCounterVec(
5761
prometheus.CounterOpts{
5862
Namespace: metricsNamespace,
5963
Subsystem: metricsSubsystem,
6064
Name: "cache_hit",
6165
Help: "Count of cache hits for a particular cache within Pilot",
62-
}, []string{metricLabelCacheName})
66+
}, []string{metricLabelCacheName, metricBuildVersion})
6367
cacheMissCounter = prometheus.NewCounterVec(
6468
prometheus.CounterOpts{
6569
Namespace: metricsNamespace,
6670
Subsystem: metricsSubsystem,
6771
Name: "cache_miss",
6872
Help: "Count of cache misses for a particular cache within Pilot",
69-
}, []string{metricLabelCacheName})
73+
}, []string{metricLabelCacheName, metricBuildVersion})
7074
callCounter = prometheus.NewCounterVec(
7175
prometheus.CounterOpts{
7276
Namespace: metricsNamespace,
7377
Subsystem: metricsSubsystem,
7478
Name: "calls",
7579
Help: "Counter of individual method calls in Pilot",
76-
}, []string{metricLabelMethod})
80+
}, []string{metricLabelMethod, metricBuildVersion})
7781
errorCounter = prometheus.NewCounterVec(
7882
prometheus.CounterOpts{
7983
Namespace: metricsNamespace,
8084
Subsystem: metricsSubsystem,
8185
Name: "errors",
8286
Help: "Counter of errors encountered during a given method call within Pilot",
83-
}, []string{metricLabelMethod})
87+
}, []string{metricLabelMethod, metricBuildVersion})
8488

8589
resourceBuckets = []float64{0, 10, 20, 30, 40, 50, 75, 100, 150, 250, 500, 1000, 10000}
8690
resourceCounter = prometheus.NewHistogramVec(
@@ -90,7 +94,7 @@ var (
9094
Name: "resources",
9195
Help: "Histogram of returned resource counts per method by Pilot",
9296
Buckets: resourceBuckets,
93-
}, []string{metricLabelMethod})
97+
}, []string{metricLabelMethod, metricBuildVersion})
9498
)
9599

96100
func init() {
@@ -232,6 +236,7 @@ func (c *discoveryCache) stats() map[string]*discoveryCacheStatEntry {
232236
func (c *discoveryCache) cacheSizeLabels() prometheus.Labels {
233237
return prometheus.Labels{
234238
metricLabelCacheName: c.name,
239+
metricBuildVersion: buildVersion,
235240
}
236241
}
237242

@@ -707,15 +712,24 @@ func (ds *DiscoveryService) ListRoutes(request *restful.Request, response *restf
707712
}
708713

709714
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()
711719
}
712720

713721
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()
715726
}
716727

717728
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))
719733
}
720734

721735
func errorResponse(methodName string, r *restful.Response, status int, msg string) {

0 commit comments

Comments
 (0)