mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
unparameterize 'webhook' from conversion metrics since it's the only one
Change-Id: I6dda5c033786f128e9b2d5d889e47f3dc7937ed5
This commit is contained in:
parent
4f2faa2f1c
commit
849185a1fa
@ -37,7 +37,7 @@ type CRConverterFactory struct {
|
||||
|
||||
// converterMetricFactorySingleton protects us from reregistration of metrics on repeated
|
||||
// apiextensions-apiserver runs.
|
||||
var converterMetricFactorySingleton = newConverterMertricFactory()
|
||||
var converterMetricFactorySingleton = newConverterMetricFactory()
|
||||
|
||||
// NewCRConverterFactory creates a new CRConverterFactory
|
||||
func NewCRConverterFactory(serviceResolver webhook.ServiceResolver, authResolverWrapper webhook.AuthenticationInfoResolverWrapper) (*CRConverterFactory, error) {
|
||||
@ -66,7 +66,7 @@ func (m *CRConverterFactory) NewConverter(crd *apiextensionsv1.CustomResourceDef
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
converter, err = converterMetricFactorySingleton.addMetrics("webhook", crd.Name, converter)
|
||||
converter, err = converterMetricFactorySingleton.addMetrics(crd.Name, converter)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
||||
package conversion
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
@ -40,7 +39,7 @@ type converterMetricFactory struct {
|
||||
factoryLock sync.Mutex
|
||||
}
|
||||
|
||||
func newConverterMertricFactory() *converterMetricFactory {
|
||||
func newConverterMetricFactory() *converterMetricFactory {
|
||||
return &converterMetricFactory{durations: map[string]*metrics.HistogramVec{}, factoryLock: sync.Mutex{}}
|
||||
}
|
||||
|
||||
@ -52,15 +51,15 @@ type converterMetric struct {
|
||||
crdName string
|
||||
}
|
||||
|
||||
func (c *converterMetricFactory) addMetrics(converterName string, crdName string, converter crConverterInterface) (crConverterInterface, error) {
|
||||
func (c *converterMetricFactory) addMetrics(crdName string, converter crConverterInterface) (crConverterInterface, error) {
|
||||
c.factoryLock.Lock()
|
||||
defer c.factoryLock.Unlock()
|
||||
metric, exists := c.durations[converterName]
|
||||
metric, exists := c.durations["webhook"]
|
||||
if !exists {
|
||||
metric = metrics.NewHistogramVec(
|
||||
&metrics.HistogramOpts{
|
||||
Name: fmt.Sprintf("apiserver_crd_%s_conversion_duration_seconds", converterName),
|
||||
Help: fmt.Sprintf("CRD %s conversion duration in seconds", converterName),
|
||||
Name: "apiserver_crd_webhook_conversion_duration_seconds",
|
||||
Help: "CRD webhook conversion duration in seconds",
|
||||
Buckets: latencyBuckets,
|
||||
StabilityLevel: metrics.ALPHA,
|
||||
},
|
||||
@ -69,7 +68,7 @@ func (c *converterMetricFactory) addMetrics(converterName string, crdName string
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.durations[converterName] = metric
|
||||
c.durations["webhook"] = metric
|
||||
}
|
||||
return &converterMetric{latencies: metric, delegate: converter, crdName: crdName}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user