...

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

Documentation: k8s.io/kubernetes/pkg/controller/ttlafterfinished/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  // TTLAfterFinishedSubsystem - subsystem name used for this controller.
    27  const TTLAfterFinishedSubsystem = "ttl_after_finished_controller"
    28  
    29  var (
    30  	// JobDeletionDurationSeconds tracks the time it took to delete the job since it
    31  	// became eligible for deletion.
    32  	JobDeletionDurationSeconds = metrics.NewHistogram(
    33  		&metrics.HistogramOpts{
    34  			Subsystem:      TTLAfterFinishedSubsystem,
    35  			Name:           "job_deletion_duration_seconds",
    36  			Help:           "The time it took to delete the job since it became eligible for deletion",
    37  			StabilityLevel: metrics.ALPHA,
    38  			// Start with 100ms with the last bucket being [~27m, Inf).
    39  			Buckets: metrics.ExponentialBuckets(0.1, 2, 14),
    40  		},
    41  	)
    42  )
    43  
    44  var registerMetrics sync.Once
    45  
    46  // Register registers TTL after finished controller metrics.
    47  func Register() {
    48  	registerMetrics.Do(func() {
    49  		legacyregistry.MustRegister(JobDeletionDurationSeconds)
    50  	})
    51  }
    52  

View as plain text