mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +00:00
add support for parsing gauge func
Change-Id: Id0b9cd51dead5ee9f4adac804d62f5d9742320a7
This commit is contained in:
parent
4f2faa2f1c
commit
49c08947f7
@ -70,7 +70,7 @@ func (c *metricDecoder) decodeNewMetricCall(fc *ast.CallExpr) (*metric, error) {
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
switch functionName {
|
switch functionName {
|
||||||
case "NewCounter", "NewGauge", "NewHistogram", "NewSummary", "NewTimingHistogram":
|
case "NewCounter", "NewGauge", "NewHistogram", "NewSummary", "NewTimingHistogram", "NewGaugeFunc":
|
||||||
m, err = c.decodeMetric(fc)
|
m, err = c.decodeMetric(fc)
|
||||||
case "NewCounterVec", "NewGaugeVec", "NewHistogramVec", "NewSummaryVec", "NewTimingHistogramVec":
|
case "NewCounterVec", "NewGaugeVec", "NewHistogramVec", "NewSummaryVec", "NewTimingHistogramVec":
|
||||||
m, err = c.decodeMetricVec(fc)
|
m, err = c.decodeMetricVec(fc)
|
||||||
@ -90,7 +90,7 @@ func getMetricType(functionName string) string {
|
|||||||
switch functionName {
|
switch functionName {
|
||||||
case "NewCounter", "NewCounterVec":
|
case "NewCounter", "NewCounterVec":
|
||||||
return counterMetricType
|
return counterMetricType
|
||||||
case "NewGauge", "NewGaugeVec":
|
case "NewGauge", "NewGaugeVec", "NewGaugeFunc":
|
||||||
return gaugeMetricType
|
return gaugeMetricType
|
||||||
case "NewHistogram", "NewHistogramVec":
|
case "NewHistogram", "NewHistogramVec":
|
||||||
return histogramMetricType
|
return histogramMetricType
|
||||||
@ -104,7 +104,7 @@ func getMetricType(functionName string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *metricDecoder) decodeMetric(call *ast.CallExpr) (metric, error) {
|
func (c *metricDecoder) decodeMetric(call *ast.CallExpr) (metric, error) {
|
||||||
if len(call.Args) != 1 {
|
if len(call.Args) > 2 {
|
||||||
return metric{}, newDecodeErrorf(call, errInvalidNewMetricCall)
|
return metric{}, newDecodeErrorf(call, errInvalidNewMetricCall)
|
||||||
}
|
}
|
||||||
return c.decodeOpts(call.Args[0])
|
return c.decodeOpts(call.Args[0])
|
||||||
|
@ -481,6 +481,20 @@ func Register(collectors ...metrics.StableCollector) {
|
|||||||
for _, collector := range collectors {
|
for _, collector := range collectors {
|
||||||
legacyregistry.CustomMustRegister(collector)
|
legacyregistry.CustomMustRegister(collector)
|
||||||
}
|
}
|
||||||
|
legacyregistry.RawMustRegister(metrics.NewGaugeFunc(
|
||||||
|
&metrics.GaugeOpts{
|
||||||
|
Subsystem: "kubelet",
|
||||||
|
Name: "certificate_manager_client_ttl_seconds",
|
||||||
|
Help: "Gauge of the TTL (time-to-live) of the Kubelet's client certificate. " +
|
||||||
|
"The value is in seconds until certificate expiry (negative if already expired). " +
|
||||||
|
"If client certificate is invalid or unused, the value will be +INF.",
|
||||||
|
StabilityLevel: metrics.BETA,
|
||||||
|
},
|
||||||
|
func() float64 {
|
||||||
|
return 0
|
||||||
|
},
|
||||||
|
))
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
- name: certificate_manager_client_ttl_seconds
|
||||||
|
subsystem: kubelet
|
||||||
|
help: Gauge of the TTL (time-to-live) of the Kubelet's client certificate. The value
|
||||||
|
is in seconds until certificate expiry (negative if already expired). If client
|
||||||
|
certificate is invalid or unused, the value will be +INF.
|
||||||
|
type: Gauge
|
||||||
|
stabilityLevel: BETA
|
||||||
- name: device_plugin_alloc_duration_seconds
|
- name: device_plugin_alloc_duration_seconds
|
||||||
subsystem: kubelet
|
subsystem: kubelet
|
||||||
help: Duration in seconds to serve a device plugin Allocation request. Broken down
|
help: Duration in seconds to serve a device plugin Allocation request. Broken down
|
||||||
|
Loading…
Reference in New Issue
Block a user