...

Source file src/k8s.io/kubernetes/pkg/controller/resourceclaim/metrics/metrics.go

Documentation: k8s.io/kubernetes/pkg/controller/resourceclaim/metrics

     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 metrics
    18  
    19  import (
    20  	"sync"
    21  
    22  	"k8s.io/component-base/metrics"
    23  	"k8s.io/component-base/metrics/legacyregistry"
    24  )
    25  
    26  // ResourceClaimSubsystem - subsystem name used for ResourceClaim creation
    27  const ResourceClaimSubsystem = "resourceclaim_controller"
    28  
    29  var (
    30  	// ResourceClaimCreateAttempts tracks the number of
    31  	// ResourceClaims().Create calls (both successful and unsuccessful)
    32  	ResourceClaimCreateAttempts = metrics.NewCounter(
    33  		&metrics.CounterOpts{
    34  			Subsystem:      ResourceClaimSubsystem,
    35  			Name:           "create_attempts_total",
    36  			Help:           "Number of ResourceClaims creation requests",
    37  			StabilityLevel: metrics.ALPHA,
    38  		})
    39  	// ResourceClaimCreateFailures tracks the number of unsuccessful
    40  	// ResourceClaims().Create calls
    41  	ResourceClaimCreateFailures = metrics.NewCounter(
    42  		&metrics.CounterOpts{
    43  			Subsystem:      ResourceClaimSubsystem,
    44  			Name:           "create_failures_total",
    45  			Help:           "Number of ResourceClaims creation request failures",
    46  			StabilityLevel: metrics.ALPHA,
    47  		})
    48  )
    49  
    50  var registerMetrics sync.Once
    51  
    52  // RegisterMetrics registers ResourceClaim metrics.
    53  func RegisterMetrics() {
    54  	registerMetrics.Do(func() {
    55  		legacyregistry.MustRegister(ResourceClaimCreateAttempts)
    56  		legacyregistry.MustRegister(ResourceClaimCreateFailures)
    57  	})
    58  }
    59  

View as plain text