func NewKubeEagleCollector(opts *options.Options) (*KubeEagleCollector, error) {
	collectorByName := make(map[string]Collector)
	for collectorName, factory := range factoriesByCollectorName {
		log.Debugf("Creating collector '%s'", collectorName)
		collector, err := factory(opts)
		if err != nil {
			return nil, fmt.Errorf("failed to create collector '%s': '%s'", collectorName, err)
		}
		collectorByName[collectorName] = collector
	}
	var err error
	kubernetesClient, err = kubernetes.NewClient(opts)
	if err != nil {
		return nil, fmt.Errorf("failed to initialize kubernetes client: '%v'", err)
	}
	scrapeDurationDesc = prometheus.NewDesc(
		prometheus.BuildFQName(opts.Namespace, "scrape", "collector_duration_seconds"),
		"Kube Eagle: Duration of a collector scrape.",
		[]string{"collector"},
		nil,
	)
	scrapeSuccessDesc = prometheus.NewDesc(
		prometheus.BuildFQName(opts.Namespace, "scrape", "collector_success"),
		"Kube Eagle: Whether a collector succeeded.",
		[]string{"collector"},
		nil,
	)
	return &KubeEagleCollector{CollectorByName: collectorByName}, nil
}
NewKubeEagleCollector creates a new KubeEagle collector which can be considered as manager of multiple collectors
package collector
import (
	"fmt"
	"github.com/google-cloud-tools/kube-eagle/kubernetes"
	"github.com/google-cloud-tools/kube-eagle/options"
	"github.com/prometheus/client_golang/prometheus"
	log "github.com/sirupsen/logrus"
	"sync"
	"time"
)
type collectorFactoryFunc = func(opts *options.Options) (Collector, error)
var (
	kubernetesClient         *kubernetes.Client
	scrapeDurationDesc       *prometheus.Desc
	scrapeSuccessDesc        *prometheus.Desc
	factoriesByCollectorName = make(map[string]collectorFactoryFunc)
)
func registerCollector(collectorName string, collectorFactory collectorFactoryFunc) {
	log.Debugf("Registering collector '%s'", collectorName)
	factoriesByCollectorName[collectorName] = collectorFactory
}
type KubeEagleCollector struct {
	CollectorByName map[string]Collector
}