volcano.sh/volcano@v1.9.0/pkg/scheduler/metrics/job.go (about) 1 /* 2 Copyright 2020 The Volcano 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 "github.com/prometheus/client_golang/prometheus" 21 "github.com/prometheus/client_golang/prometheus/promauto" // auto-registry collectors in default registry 22 ) 23 24 var ( 25 jobShare = promauto.NewGaugeVec( 26 prometheus.GaugeOpts{ 27 Subsystem: VolcanoNamespace, 28 Name: "job_share", 29 Help: "Share for one job", 30 }, []string{"job_ns", "job_id"}, 31 ) 32 33 jobRetryCount = promauto.NewCounterVec( 34 prometheus.CounterOpts{ 35 Subsystem: VolcanoNamespace, 36 Name: "job_retry_counts", 37 Help: "Number of retry counts for one job", 38 }, []string{"job_id"}, 39 ) 40 ) 41 42 // UpdateJobShare records share for one job 43 func UpdateJobShare(jobNs, jobID string, share float64) { 44 jobShare.WithLabelValues(jobNs, jobID).Set(share) 45 } 46 47 // RegisterJobRetries total number of job retries. 48 func RegisterJobRetries(jobID string) { 49 jobRetryCount.WithLabelValues(jobID).Inc() 50 } 51 52 // DeleteJobMetrics delete all metrics related to the job 53 func DeleteJobMetrics(jobName, queue, namespace string) { 54 e2eJobSchedulingDuration.DeleteLabelValues(jobName, queue, namespace) 55 e2eJobSchedulingStartTime.DeleteLabelValues(jobName, queue, namespace) 56 e2eJobSchedulingLastTime.DeleteLabelValues(jobName, queue, namespace) 57 unscheduleTaskCount.DeleteLabelValues(jobName) 58 jobShare.DeleteLabelValues(namespace, jobName) 59 jobRetryCount.DeleteLabelValues(jobName) 60 }