github.com/oam-dev/kubevela@v1.9.11/pkg/monitor/metrics/workflow.go (about)

     1  /*
     2   Copyright 2021. The KubeVela Authors.
     3   Licensed under the Apache License, Version 2.0 (the "License");
     4   you may not use this file except in compliance with the License.
     5   You may obtain a copy of the License at
     6       http://www.apache.org/licenses/LICENSE-2.0
     7   Unless required by applicable law or agreed to in writing, software
     8   distributed under the License is distributed on an "AS IS" BASIS,
     9   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    10   See the License for the specific language governing permissions and
    11   limitations under the License.
    12  */
    13  
    14  package metrics
    15  
    16  import (
    17  	"github.com/prometheus/client_golang/prometheus"
    18  	"k8s.io/klog/v2"
    19  	"sigs.k8s.io/controller-runtime/pkg/metrics"
    20  
    21  	velametrics "github.com/kubevela/pkg/monitor/metrics"
    22  )
    23  
    24  var (
    25  	// StepDurationHistogram report the step execution duration.
    26  	StepDurationHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
    27  		Name:        "step_duration_ms",
    28  		Help:        "step latency distributions.",
    29  		Buckets:     velametrics.FineGrainedBuckets,
    30  		ConstLabels: prometheus.Labels{},
    31  	}, []string{"controller", "step_type"})
    32  )
    33  
    34  var collectorGroup = []prometheus.Collector{
    35  	AppReconcileStageDurationHistogram,
    36  	StepDurationHistogram,
    37  	ListResourceTrackerCounter,
    38  	ApplicationReconcileTimeHistogram,
    39  	ApplyComponentTimeHistogram,
    40  	WorkflowFinishedTimeHistogram,
    41  	ApplicationPhaseCounter,
    42  	WorkflowStepPhaseGauge,
    43  	ClusterIsConnectedGauge,
    44  	ClusterWorkerNumberGauge,
    45  	ClusterMasterNumberGauge,
    46  	ClusterMemoryCapacityGauge,
    47  	ClusterCPUCapacityGauge,
    48  	ClusterPodCapacityGauge,
    49  	ClusterMemoryAllocatableGauge,
    50  	ClusterCPUAllocatableGauge,
    51  	ClusterPodAllocatableGauge,
    52  	ClusterMemoryUsageGauge,
    53  	ClusterCPUUsageGauge,
    54  }
    55  
    56  func init() {
    57  	for _, collector := range collectorGroup {
    58  		if err := metrics.Registry.Register(collector); err != nil {
    59  			klog.Error(err)
    60  		}
    61  	}
    62  }