...

Source file src/k8s.io/kubernetes/pkg/credentialprovider/plugin/metrics.go

Documentation: k8s.io/kubernetes/pkg/credentialprovider/plugin

     1  /*
     2  Copyright 2021 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package plugin
    18  
    19  import (
    20  	"sync"
    21  
    22  	"k8s.io/component-base/metrics"
    23  	"k8s.io/component-base/metrics/legacyregistry"
    24  )
    25  
    26  const (
    27  	KubeletSubsystem = "kubelet"
    28  )
    29  
    30  var (
    31  	registerOnce sync.Once
    32  
    33  	kubeletCredentialProviderPluginErrors = metrics.NewCounterVec(
    34  		&metrics.CounterOpts{
    35  			Subsystem:      KubeletSubsystem,
    36  			Name:           "credential_provider_plugin_errors",
    37  			Help:           "Number of errors from credential provider plugin",
    38  			StabilityLevel: metrics.ALPHA,
    39  		},
    40  		[]string{"plugin_name"},
    41  	)
    42  
    43  	kubeletCredentialProviderPluginDuration = metrics.NewHistogramVec(
    44  		&metrics.HistogramOpts{
    45  			Subsystem:      KubeletSubsystem,
    46  			Name:           "credential_provider_plugin_duration",
    47  			Help:           "Duration of execution in seconds for credential provider plugin",
    48  			Buckets:        metrics.DefBuckets,
    49  			StabilityLevel: metrics.ALPHA,
    50  		},
    51  		[]string{"plugin_name"},
    52  	)
    53  )
    54  
    55  // registerMetrics registers credential provider metrics.
    56  func registerMetrics() {
    57  	registerOnce.Do(func() {
    58  		legacyregistry.MustRegister(kubeletCredentialProviderPluginErrors)
    59  		legacyregistry.MustRegister(kubeletCredentialProviderPluginDuration)
    60  	})
    61  }
    62  

View as plain text