func (p *kafkaConnectProvider) GetMetricByName(name types.NamespacedName, info provider.CustomMetricInfo, metricSelector labels.Selector) (*custom_metrics.MetricValue, error) {
	klog.Infof("Received request for custom metric: groupresource: %s, namespace: %s, metric name: %s, object name: %s", info.GroupResource.String(), name.Namespace, info.Metric, name.Name)
	metricRequestInfo := custommetrics.NewMetricRequest(info, name)
	val, err := p.kafkaMetricsClient.GetCustomMetric(metricRequestInfo, metricSelector)
	if err != nil {
		return nil, err
	}
	kc, err := p.kclister.KafkaConnects(name.Namespace).Get(name.Name)
	if err != nil {
		return nil, err
	}
	ref := custom_metrics.ObjectReference{
		APIVersion: kc.APIVersion,
		Kind:       kc.Kind,
		Name:       name.Name,
		Namespace:  name.Namespace,
	}
	metricValue := &custom_metrics.MetricValue{
		DescribedObject: ref,
		Metric: custom_metrics.MetricIdentifier{
			Name: info.Metric,
		},
		Timestamp: metav1.Time{Time: time.Now()},
		Value:     *resource.NewQuantity(int64(val), resource.DecimalSI),
	}
	klog.Infof("return metric value %v", val)
	return metricValue, nil
}
GetMetricByName fetches a particular metric for a particular object.
The namespace will be empty if the metric is root-scoped.
package provider
import (
	"fmt"
	"sync"
	"time"
	"k8s.io/klog"
	"github.com/amadeusitgroup/kubernetes-kafka-connect-operator/pkg/custommetrics"
	"github.com/kubernetes-incubator/custom-metrics-apiserver/pkg/provider"
	"k8s.io/apimachinery/pkg/api/errors"
	"k8s.io/apimachinery/pkg/api/resource"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/labels"
	"k8s.io/apimachinery/pkg/runtime/schema"
	"k8s.io/apimachinery/pkg/types"
	"k8s.io/metrics/pkg/apis/custom_metrics"
	listers "github.com/amadeusitgroup/kubernetes-kafka-connect-operator/pkg/generated/listers/kafkaconnect/v1alpha1"
)
type kafkaConnectProvider struct {
	kclister           listers.KafkaConnectLister
	kafkaMetricsClient custommetrics.KafkaMetricsClient
}
func NewKafkaConnectProvider(kclister listers.KafkaConnectLister, kmclient custommetrics.KafkaMetricsClient) provider.CustomMetricsProvider {
	return &kafkaConnectProvider{
		kclister:           kclister,
		kafkaMetricsClient: kmclient,
	}
}