k8s.io/kubernetes@v1.29.3/pkg/controller/cronjob/metrics/metrics.go (about) 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 const CronJobControllerSubsystem = "cronjob_controller" 27 28 var ( 29 CronJobCreationSkew = metrics.NewHistogram( 30 &metrics.HistogramOpts{ 31 Subsystem: CronJobControllerSubsystem, 32 Name: "job_creation_skew_duration_seconds", 33 Help: "Time between when a cronjob is scheduled to be run, and when the corresponding job is created", 34 StabilityLevel: metrics.STABLE, 35 Buckets: metrics.ExponentialBuckets(1, 2, 10), 36 }, 37 ) 38 ) 39 40 var registerMetrics sync.Once 41 42 // Register registers CronjobController metrics. 43 func Register() { 44 registerMetrics.Do(func() { 45 legacyregistry.MustRegister(CronJobCreationSkew) 46 }) 47 }