volcano.sh/volcano@v1.9.0/pkg/scheduler/metrics/namespace.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  	namespaceShare = promauto.NewGaugeVec(
    26  		prometheus.GaugeOpts{
    27  			Subsystem: VolcanoNamespace,
    28  			Name:      "namespace_share",
    29  			Help:      "Share for one namespace",
    30  		}, []string{"namespace_name"},
    31  	)
    32  
    33  	namespaceWeight = promauto.NewGaugeVec(
    34  		prometheus.GaugeOpts{
    35  			Subsystem: VolcanoNamespace,
    36  			Name:      "namespace_weight",
    37  			Help:      "Weight for one namespace",
    38  		}, []string{"namespace_name"},
    39  	)
    40  
    41  	namespaceWeightedShare = promauto.NewGaugeVec(
    42  		prometheus.GaugeOpts{
    43  			Subsystem: VolcanoNamespace,
    44  			Name:      "namespace_weighted_share",
    45  			Help:      "Weighted share for one namespace",
    46  		}, []string{"namespace_name"},
    47  	)
    48  )
    49  
    50  // UpdateNamespaceShare records share for one namespace
    51  func UpdateNamespaceShare(namespaceName string, share float64) {
    52  	namespaceShare.WithLabelValues(namespaceName).Set(share)
    53  }
    54  
    55  // UpdateNamespaceWeight records weight for one namespace
    56  func UpdateNamespaceWeight(namespaceName string, weight int64) {
    57  	namespaceWeight.WithLabelValues(namespaceName).Set(float64(weight))
    58  }
    59  
    60  // UpdateNamespaceWeightedShare records weighted share for one namespace
    61  func UpdateNamespaceWeightedShare(namespaceName string, weightedShare float64) {
    62  	namespaceWeightedShare.WithLabelValues(namespaceName).Set(weightedShare)
    63  }