// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 package k8sclusterreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sclusterreceiver" import ( "time" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/receiver" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sclusterreceiver/internal/metadata" ) const ( // supported distributions distributionKubernetes = "kubernetes" distributionOpenShift = "openshift" // Default config values. defaultCollectionInterval = 10 * time.Second defaultDistribution = distributionKubernetes defaultMetadataCollectionInterval = 5 * time.Minute ) var defaultNodeConditionsToReport = []string{"Ready"} func createDefaultConfig() component.Config { return &Config{ Distribution: defaultDistribution, CollectionInterval: defaultCollectionInterval, NodeConditionTypesToReport: defaultNodeConditionsToReport, APIConfig: k8sconfig.APIConfig{ AuthType: k8sconfig.AuthTypeServiceAccount, }, MetadataCollectionInterval: defaultMetadataCollectionInterval, MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(), } } // NewFactory creates a factory for k8s_cluster receiver. func NewFactory() receiver.Factory { return receiver.NewFactory( metadata.Type, createDefaultConfig, receiver.WithMetrics(newMetricsReceiver, metadata.MetricsStability), receiver.WithLogs(newLogsReceiver, metadata.MetricsStability), ) } // This is the map of already created k8scluster receivers for particular configurations. // We maintain this map because the Factory is asked log and metric receivers separately // when it gets CreateLogsReceiver() and CreateMetricsReceiver() but they must not // create separate objects, they must use one receiver object per configuration. var receivers = sharedcomponent.NewSharedComponents()