mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Merge pull request #110337 from logicalhan/deprecate-metrics
cleanup deprecated metrics and usages
This commit is contained in:
commit
e66a016b73
@ -163,8 +163,6 @@ type WatchServer struct {
|
||||
// or over a websocket connection.
|
||||
func (s *WatchServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
kind := s.Scope.Kind
|
||||
metrics.RegisteredWatchers.WithContext(req.Context()).WithLabelValues(kind.Group, kind.Version, kind.Kind).Inc()
|
||||
defer metrics.RegisteredWatchers.WithContext(req.Context()).WithLabelValues(kind.Group, kind.Version, kind.Kind).Dec()
|
||||
|
||||
if wsstream.IsWebSocketRequest(req) {
|
||||
w.Header().Set("Content-Type", s.MediaType)
|
||||
|
@ -136,16 +136,6 @@ var (
|
||||
},
|
||||
[]string{"verb", "group", "version", "resource", "subresource", "scope", "component"},
|
||||
)
|
||||
// droppedRequests is a number of requests dropped with 'Try again later' response"
|
||||
droppedRequests = compbasemetrics.NewCounterVec(
|
||||
&compbasemetrics.CounterOpts{
|
||||
Name: "apiserver_dropped_requests_total",
|
||||
Help: "Number of requests dropped with 'Try again later' response. Use apiserver_request_total and/or apiserver_request_terminations_total metrics instead.",
|
||||
StabilityLevel: compbasemetrics.ALPHA,
|
||||
DeprecatedVersion: "1.24.0",
|
||||
},
|
||||
[]string{"request_kind"},
|
||||
)
|
||||
// TLSHandshakeErrors is a number of requests dropped with 'TLS handshake error from' error
|
||||
TLSHandshakeErrors = compbasemetrics.NewCounter(
|
||||
&compbasemetrics.CounterOpts{
|
||||
@ -154,16 +144,6 @@ var (
|
||||
StabilityLevel: compbasemetrics.ALPHA,
|
||||
},
|
||||
)
|
||||
// RegisteredWatchers is a number of currently registered watchers splitted by resource.
|
||||
RegisteredWatchers = compbasemetrics.NewGaugeVec(
|
||||
&compbasemetrics.GaugeOpts{
|
||||
Name: "apiserver_registered_watchers",
|
||||
Help: "Number of currently registered watchers for a given resources",
|
||||
StabilityLevel: compbasemetrics.ALPHA,
|
||||
DeprecatedVersion: "1.23.0",
|
||||
},
|
||||
[]string{"group", "version", "kind"},
|
||||
)
|
||||
WatchEvents = compbasemetrics.NewCounterVec(
|
||||
&compbasemetrics.CounterOpts{
|
||||
Name: "apiserver_watch_events_total",
|
||||
@ -266,9 +246,7 @@ var (
|
||||
requestSloLatencies,
|
||||
fieldValidationRequestLatencies,
|
||||
responseSizes,
|
||||
droppedRequests,
|
||||
TLSHandshakeErrors,
|
||||
RegisteredWatchers,
|
||||
WatchEvents,
|
||||
WatchEventsSizes,
|
||||
currentInflightRequests,
|
||||
@ -427,12 +405,6 @@ func RecordDroppedRequest(req *http.Request, requestInfo *request.RequestInfo, c
|
||||
} else {
|
||||
requestCounter.WithContext(req.Context()).WithLabelValues(reportedVerb, dryRun, "", "", "", requestInfo.Subresource, scope, component, codeToString(http.StatusTooManyRequests)).Inc()
|
||||
}
|
||||
|
||||
if isMutatingRequest {
|
||||
droppedRequests.WithContext(req.Context()).WithLabelValues(MutatingKind).Inc()
|
||||
} else {
|
||||
droppedRequests.WithContext(req.Context()).WithLabelValues(ReadOnlyKind).Inc()
|
||||
}
|
||||
}
|
||||
|
||||
// RecordRequestTermination records that the request was terminated early as part of a resource
|
||||
|
@ -283,7 +283,6 @@ func TestResponseWriterDecorator(t *testing.T) {
|
||||
func TestRecordDroppedRequests(t *testing.T) {
|
||||
testedMetrics := []string{
|
||||
"apiserver_request_total",
|
||||
"apiserver_dropped_requests_total",
|
||||
}
|
||||
|
||||
testCases := []struct {
|
||||
@ -310,9 +309,6 @@ func TestRecordDroppedRequests(t *testing.T) {
|
||||
},
|
||||
isMutating: false,
|
||||
want: `
|
||||
# HELP apiserver_dropped_requests_total [ALPHA] Number of requests dropped with 'Try again later' response. Use apiserver_request_total and/or apiserver_request_terminations_total metrics instead.
|
||||
# TYPE apiserver_dropped_requests_total counter
|
||||
apiserver_dropped_requests_total{request_kind="readOnly"} 1
|
||||
# HELP apiserver_request_total [STABLE] Counter of apiserver requests broken out for each verb, dry run value, group, version, resource, scope, component, and HTTP response code.
|
||||
# TYPE apiserver_request_total counter
|
||||
apiserver_request_total{code="429",component="apiserver",dry_run="",group="",resource="pods",scope="cluster",subresource="",verb="LIST",version="v1"} 1
|
||||
@ -335,9 +331,6 @@ func TestRecordDroppedRequests(t *testing.T) {
|
||||
},
|
||||
isMutating: true,
|
||||
want: `
|
||||
# HELP apiserver_dropped_requests_total [ALPHA] Number of requests dropped with 'Try again later' response. Use apiserver_request_total and/or apiserver_request_terminations_total metrics instead.
|
||||
# TYPE apiserver_dropped_requests_total counter
|
||||
apiserver_dropped_requests_total{request_kind="mutating"} 1
|
||||
# HELP apiserver_request_total [STABLE] Counter of apiserver requests broken out for each verb, dry run value, group, version, resource, scope, component, and HTTP response code.
|
||||
# TYPE apiserver_request_total counter
|
||||
apiserver_request_total{code="429",component="apiserver",dry_run="",group="",resource="pods",scope="resource",subresource="",verb="POST",version="v1"} 1
|
||||
@ -363,9 +356,6 @@ func TestRecordDroppedRequests(t *testing.T) {
|
||||
},
|
||||
isMutating: true,
|
||||
want: `
|
||||
# HELP apiserver_dropped_requests_total [ALPHA] Number of requests dropped with 'Try again later' response. Use apiserver_request_total and/or apiserver_request_terminations_total metrics instead.
|
||||
# TYPE apiserver_dropped_requests_total counter
|
||||
apiserver_dropped_requests_total{request_kind="mutating"} 1
|
||||
# HELP apiserver_request_total [STABLE] Counter of apiserver requests broken out for each verb, dry run value, group, version, resource, scope, component, and HTTP response code.
|
||||
# TYPE apiserver_request_total counter
|
||||
apiserver_request_total{code="429",component="apiserver",dry_run="All",group="batch",resource="jobs",scope="resource",subresource="status",verb="PATCH",version="v1"} 1
|
||||
@ -378,12 +368,10 @@ func TestRecordDroppedRequests(t *testing.T) {
|
||||
// This also implies that we can't run this test in parallel with other tests.
|
||||
Register()
|
||||
requestCounter.Reset()
|
||||
droppedRequests.Reset()
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
defer requestCounter.Reset()
|
||||
defer droppedRequests.Reset()
|
||||
|
||||
RecordDroppedRequest(test.request, test.requestInfo, APIServerComponent, test.isMutating)
|
||||
|
||||
|
@ -217,7 +217,7 @@ func TestApfRejectRequest(t *testing.T) {
|
||||
|
||||
checkForExpectedMetrics(t, []string{
|
||||
"apiserver_request_terminations_total",
|
||||
"apiserver_dropped_requests_total",
|
||||
"apiserver_request_total",
|
||||
})
|
||||
}
|
||||
|
||||
@ -367,7 +367,7 @@ func TestApfCancelWaitRequest(t *testing.T) {
|
||||
checkForExpectedMetrics(t, []string{
|
||||
"apiserver_current_inflight_requests",
|
||||
"apiserver_request_terminations_total",
|
||||
"apiserver_dropped_requests_total",
|
||||
"apiserver_request_total",
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -43,15 +43,6 @@ var (
|
||||
},
|
||||
[]string{"operation", "type"},
|
||||
)
|
||||
etcdObjectCounts = compbasemetrics.NewGaugeVec(
|
||||
&compbasemetrics.GaugeOpts{
|
||||
Name: "etcd_object_counts",
|
||||
DeprecatedVersion: "1.22.0",
|
||||
Help: "Number of stored objects at the time of last check split by kind. This metric is replaced by apiserver_storage_object_counts.",
|
||||
StabilityLevel: compbasemetrics.ALPHA,
|
||||
},
|
||||
[]string{"resource"},
|
||||
)
|
||||
objectCounts = compbasemetrics.NewGaugeVec(
|
||||
&compbasemetrics.GaugeOpts{
|
||||
Name: "apiserver_storage_objects",
|
||||
@ -127,7 +118,6 @@ func Register() {
|
||||
registerMetrics.Do(func() {
|
||||
legacyregistry.MustRegister(etcdRequestLatency)
|
||||
legacyregistry.MustRegister(objectCounts)
|
||||
legacyregistry.MustRegister(etcdObjectCounts)
|
||||
legacyregistry.MustRegister(dbTotalSize)
|
||||
legacyregistry.MustRegister(etcdBookmarkCounts)
|
||||
legacyregistry.MustRegister(etcdLeaseObjectCounts)
|
||||
@ -138,10 +128,9 @@ func Register() {
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateObjectCount sets the apiserver_storage_object_counts and etcd_object_counts (deprecated) metric.
|
||||
// UpdateObjectCount sets the apiserver_storage_object_counts metric.
|
||||
func UpdateObjectCount(resourcePrefix string, count int64) {
|
||||
objectCounts.WithLabelValues(resourcePrefix).Set(float64(count))
|
||||
etcdObjectCounts.WithLabelValues(resourcePrefix).Set(float64(count))
|
||||
}
|
||||
|
||||
// RecordEtcdRequestLatency sets the etcd_request_duration_seconds metrics.
|
||||
|
Loading…
Reference in New Issue
Block a user