feat: kubesphere 4.0 (#6115)
* feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> * feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> --------- Signed-off-by: ci-bot <ci-bot@kubesphere.io> Co-authored-by: ks-ci-bot <ks-ci-bot@example.com> Co-authored-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
committed by
GitHub
parent
b5015ec7b9
commit
447a51f08b
66
vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/metrics.go
generated
vendored
Normal file
66
vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/metrics.go
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package validation
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"k8s.io/component-base/metrics"
|
||||
"k8s.io/component-base/metrics/legacyregistry"
|
||||
)
|
||||
|
||||
const (
|
||||
namespace = "apiextensions_apiserver"
|
||||
subsystem = "validation"
|
||||
)
|
||||
|
||||
// Interface to stub for tests
|
||||
type ValidationMetrics interface {
|
||||
ObserveRatchetingTime(d time.Duration)
|
||||
}
|
||||
|
||||
var Metrics ValidationMetrics = &validationMetrics{
|
||||
RatchetingTime: metrics.NewHistogram(&metrics.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: subsystem,
|
||||
Name: "ratcheting_seconds",
|
||||
Help: "Time for comparison of old to new for the purposes of CRDValidationRatcheting during an UPDATE in seconds.",
|
||||
StabilityLevel: metrics.ALPHA,
|
||||
// Start 0.01ms with the last bucket being [~2.5s, +Inf)
|
||||
Buckets: metrics.ExponentialBuckets(0.00001, 4, 10),
|
||||
}),
|
||||
}
|
||||
|
||||
func init() {
|
||||
legacyregistry.MustRegister(Metrics.(*validationMetrics).RatchetingTime)
|
||||
}
|
||||
|
||||
type validationMetrics struct {
|
||||
RatchetingTime *metrics.Histogram
|
||||
}
|
||||
|
||||
// ObserveRatchetingTime records the time spent on ratcheting
|
||||
func (m *validationMetrics) ObserveRatchetingTime(d time.Duration) {
|
||||
m.RatchetingTime.Observe(d.Seconds())
|
||||
}
|
||||
|
||||
// Reset resets the metrics. This is meant to be used for testing. Panics
|
||||
// if the metrics cannot be re-registered. Returns all the reset metrics
|
||||
func (m *validationMetrics) Reset() []metrics.Registerable {
|
||||
m.RatchetingTime = metrics.NewHistogram(m.RatchetingTime.HistogramOpts)
|
||||
return []metrics.Registerable{m.RatchetingTime}
|
||||
}
|
||||
Reference in New Issue
Block a user