util

package
v1.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodeNameEnvVar           = "POD_NODE_NAME"
	NamespaceNameEnvVar      = "POD_NAMESPACE_NAME"
	InstallationMethodEnvVar = "INSTALLATION_METHOD"
	ForceGC                  = "FORCE_GC"
	KubernetesVersionEnvVar  = "KUBERNETES_VERSION"
	KubernetesProviderEnvVar = "KUBERNETES_PROVIDER"
)
View Source
const (
	POD_PHASE_PENDING = iota + 1
	POD_PHASE_RUNNING
	POD_PHASE_SUCCEEDED
	POD_PHASE_FAILED
	POD_PHASE_UNKNOWN
)
View Source
const (
	CONTAINER_STATE_RUNNING = iota + 1
	CONTAINER_STATE_WAITING
	CONTAINER_STATE_TERMINATED
)

Variables

View Source
var (
	// NeverStop may be passed to make it never stop
	NeverStop <-chan struct{} = make(chan struct{})
)

Functions

func AddK8sTags added in v1.11.0

func AddK8sTags(tags map[string]string)

func ConvertPodPhase added in v1.10.0

func ConvertPodPhase(phase kube_api.PodPhase) int64

func GetFieldSelector added in v0.9.8

func GetFieldSelector(resourceType string) fields.Selector

func GetInstallationMethod added in v1.7.1

func GetInstallationMethod() string

func GetKubernetesProvider added in v1.11.0

func GetKubernetesProvider() string

func GetKubernetesVersion added in v1.11.0

func GetKubernetesVersion() string

func GetNamespaceName added in v0.9.8

func GetNamespaceName() string

func GetNamespaceStore added in v1.0.0

func GetNamespaceStore(kubeClient kubernetes.Interface) cache.Store

func GetNodeHostnameAndIP added in v1.0.0

func GetNodeHostnameAndIP(node *kube_api.Node) (string, net.IP, error)

func GetNodeLister

func GetNodeLister(kubeClient kubernetes.Interface) (v1listers.NodeLister, *cache.Reflector, error)

func GetNodeName added in v0.9.8

func GetNodeName() string

func GetNodeRole added in v1.9.0

func GetNodeRole(node *kube_api.Node) string

func GetPodLister

func GetPodLister(kubeClient kubernetes.Interface) (v1listers.PodLister, error)

func GetServiceLister added in v0.9.4

func GetServiceLister(kubeClient kubernetes.Interface) (v1listers.ServiceLister, error)

func NewDummyMetricsSourceProvider

func NewDummyMetricsSourceProvider(name string, collectionIterval, timeout time.Duration, sources ...metrics.Source) metrics.SourceProvider

func Retry added in v1.11.0

func Retry(f func(), duration time.Duration, stopCh <-chan struct{})

TODO: this needs a test! Tricky... Retry makes the function run infinitely after certain time period

func ScrapeAnyNodes added in v1.12.0

func ScrapeAnyNodes() bool

func ScrapeCluster added in v1.12.0

func ScrapeCluster() bool

func ScrapeOnlyOwnNode added in v1.12.0

func ScrapeOnlyOwnNode() bool

func SetAgentType added in v1.12.0

func SetAgentType(value AgentType)

func SetKubernetesProvider added in v1.11.0

func SetKubernetesProvider(providerID string)

func SetKubernetesVersion added in v1.11.0

func SetKubernetesVersion(version string)

Types

type AgentType added in v1.12.0

type AgentType interface {
	ScrapeCluster() bool
	ScrapeAnyNodes() bool
	ScrapeOnlyOwnNode() bool
}

type ConfigHandler added in v1.0.0

type ConfigHandler interface {
	Handle(cfg interface{})
}

type ContainerStateInfo added in v1.10.0

type ContainerStateInfo struct {
	Value    int
	State    string
	Reason   string
	ExitCode int32
}

func NewContainerStateInfo added in v1.10.0

func NewContainerStateInfo(state kube_api.ContainerState) ContainerStateInfo

func (ContainerStateInfo) AddMetricTags added in v1.10.0

func (csi ContainerStateInfo) AddMetricTags(tags map[string]string)

func (ContainerStateInfo) IsKnownState added in v1.10.0

func (csi ContainerStateInfo) IsKnownState() bool

type DummyDataProcessor

type DummyDataProcessor struct {
	// contains filtered or unexported fields
}

func NewDummyDataProcessor

func NewDummyDataProcessor(latency time.Duration) *DummyDataProcessor

func (*DummyDataProcessor) Name

func (dummy *DummyDataProcessor) Name() string

func (*DummyDataProcessor) Process

func (dummy *DummyDataProcessor) Process(data *metrics.Batch) (*metrics.Batch, error)

type DummyMetricsSource

type DummyMetricsSource struct {
	// contains filtered or unexported fields
}

func NewDummyMetricsSource

func NewDummyMetricsSource(name string, latency time.Duration) *DummyMetricsSource

func NewDummyMetricsSourceWithError added in v1.8.0

func NewDummyMetricsSourceWithError(name string, latency time.Duration, autoDiscovered bool) *DummyMetricsSource

func (*DummyMetricsSource) AutoDiscovered added in v1.8.0

func (dummy *DummyMetricsSource) AutoDiscovered() bool

func (*DummyMetricsSource) Cleanup added in v1.2.4

func (src *DummyMetricsSource) Cleanup()

func (*DummyMetricsSource) Name

func (dummy *DummyMetricsSource) Name() string

func (*DummyMetricsSource) Scrape added in v1.10.0

func (dummy *DummyMetricsSource) Scrape() (*metrics.Batch, error)

type DummyMetricsSourceProvider

type DummyMetricsSourceProvider struct {
	// contains filtered or unexported fields
}

func (*DummyMetricsSourceProvider) CollectionInterval added in v1.0.0

func (dummy *DummyMetricsSourceProvider) CollectionInterval() time.Duration

func (*DummyMetricsSourceProvider) GetMetricsSources

func (dummy *DummyMetricsSourceProvider) GetMetricsSources() []metrics.Source

func (*DummyMetricsSourceProvider) Name

func (dummy *DummyMetricsSourceProvider) Name() string

func (*DummyMetricsSourceProvider) Timeout added in v1.0.0

func (dummy *DummyMetricsSourceProvider) Timeout() time.Duration

type DummyProviderHandler added in v0.9.4

type DummyProviderHandler struct {
	// contains filtered or unexported fields
}

func NewDummyProviderHandler added in v1.3.0

func NewDummyProviderHandler(count int) *DummyProviderHandler

func (*DummyProviderHandler) AddProvider added in v0.9.4

func (d *DummyProviderHandler) AddProvider(provider metrics.SourceProvider)

func (*DummyProviderHandler) DeleteProvider added in v0.9.4

func (d *DummyProviderHandler) DeleteProvider(name string)

type DummySink

type DummySink struct {
	// contains filtered or unexported fields
}

func NewDummySink

func NewDummySink(name string, latency time.Duration) *DummySink

func (*DummySink) Export added in v1.10.0

func (dummy *DummySink) Export(*metrics.Batch)

func (*DummySink) ExportEvent added in v1.0.4

func (dummy *DummySink) ExportEvent(*events.Event)

func (*DummySink) GetExportCount

func (dummy *DummySink) GetExportCount() int

func (*DummySink) IsStopped

func (dummy *DummySink) IsStopped() bool

func (*DummySink) Name

func (dummy *DummySink) Name() string

func (*DummySink) Stop

func (dummy *DummySink) Stop()

type FileListener added in v1.0.0

type FileListener interface {
	Changed(file string)
}

type FileWatcher added in v1.0.0

type FileWatcher interface {
	Watch()
	Stop()
}

func NewFileWatcher added in v1.0.0

func NewFileWatcher(file string, listener FileListener, initialDelay time.Duration) FileWatcher

type LabelCopier

type LabelCopier struct {
	// contains filtered or unexported fields
}

LabelCopier maps kubernetes objects' labels to metrics

func NewLabelCopier

func NewLabelCopier(separator string, storedLabels, ignoredLabels []string) (*LabelCopier, error)

NewLabelCopier creates a new instance of LabelCopier type

func (*LabelCopier) Copy

func (copier *LabelCopier) Copy(in map[string]string, out map[string]string)

Copy copies the given set of pod labels into a set of metric labels, using the following logic: - all labels, unless found in ignoredLabels, are concatenated into a Separator-separated key:value pairs and stored under metrics.LabelLabels.Key - labels found in storedLabels are additionally stored under key provided

type StringInterner added in v1.3.1

type StringInterner map[string]*string

What is an interner? Is that a thing? Good question, here's a good description https://en.wikipedia.org/wiki/String_interning

func NewStringInterner added in v1.3.1

func NewStringInterner() StringInterner

func (StringInterner) Intern added in v1.3.1

func (interner StringInterner) Intern(s string) *string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL