github.com/kubewharf/katalyst-core@v0.5.3/pkg/metaserver/agent/metric/provisioner/cgroup/provisioner.go (about)

     1  /*
     2  Copyright 2022 The Katalyst 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 cgroup
    18  
    19  import (
    20  	"context"
    21  
    22  	"github.com/kubewharf/katalyst-core/pkg/config/agent/global"
    23  	"github.com/kubewharf/katalyst-core/pkg/config/agent/metaserver"
    24  	"github.com/kubewharf/katalyst-core/pkg/metaserver/agent/metric/types"
    25  	"github.com/kubewharf/katalyst-core/pkg/metaserver/agent/pod"
    26  	"github.com/kubewharf/katalyst-core/pkg/metrics"
    27  	utilmetric "github.com/kubewharf/katalyst-core/pkg/util/metric"
    28  )
    29  
    30  // NewCGroupMetricsProvisioner returns the default implementation of CGroup.
    31  func NewCGroupMetricsProvisioner(baseConf *global.BaseConfiguration, _ *metaserver.MetricConfiguration,
    32  	emitter metrics.MetricEmitter, _ pod.PodFetcher, metricStore *utilmetric.MetricStore,
    33  ) types.MetricsProvisioner {
    34  	return &CGroupMetricsProvisioner{
    35  		metricStore: metricStore,
    36  		emitter:     emitter,
    37  		baseConf:    baseConf,
    38  	}
    39  }
    40  
    41  type CGroupMetricsProvisioner struct {
    42  	baseConf    *global.BaseConfiguration
    43  	metricStore *utilmetric.MetricStore
    44  	emitter     metrics.MetricEmitter
    45  }
    46  
    47  func (m *CGroupMetricsProvisioner) Run(ctx context.Context) {
    48  	m.sample(ctx)
    49  }
    50  
    51  func (m *CGroupMetricsProvisioner) sample(ctx context.Context) {
    52  	// todo, we should add sample logic here by cgroupManager
    53  
    54  	// todo, we should also make sure that the self-collected metrics
    55  	//  should be checked firstly (whether malachite missed)
    56  }