allocation

package
v0.108.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// TargetsPerCollector records how many targets have been assigned to each collector.
	// It is currently the responsibility of the strategy to track this information.
	TargetsPerCollector = promauto.NewGaugeVec(prometheus.GaugeOpts{
		Name: "opentelemetry_allocator_targets_per_collector",
		Help: "The number of targets for each collector.",
	}, []string{"collector_name", "strategy"})
	CollectorsAllocatable = promauto.NewGaugeVec(prometheus.GaugeOpts{
		Name: "opentelemetry_allocator_collectors_allocatable",
		Help: "Number of collectors the allocator is able to allocate to.",
	}, []string{"strategy"})
	TimeToAssign = promauto.NewHistogramVec(prometheus.HistogramOpts{
		Name: "opentelemetry_allocator_time_to_allocate",
		Help: "The time it takes to allocate",
	}, []string{"method", "strategy"})

	TargetsUnassigned = promauto.NewGauge(prometheus.GaugeOpts{
		Name: "opentelemetry_allocator_targets_unassigned",
		Help: "Number of targets that could not be assigned due to missing node label.",
	})
)

Functions

func GetRegisteredAllocatorNames

func GetRegisteredAllocatorNames() []string

func MakeNCollectors

func MakeNCollectors(n int, startingIndex int) map[string]*Collector

func MakeNNewTargets

func MakeNNewTargets(n int, numCollectors int, startingIndex int) map[string]*target.Item

func MakeNNewTargetsWithEmptyCollectors

func MakeNNewTargetsWithEmptyCollectors(n int, startingIndex int) map[string]*target.Item

func RecordTargetsKept

func RecordTargetsKept(targets map[string]*target.Item)

func Register

func Register(name string, provider AllocatorProvider) error

func RunForAllStrategies added in v0.100.1

func RunForAllStrategies(t *testing.T, f func(t *testing.T, allocator Allocator))

Types

type AllocationOption

type AllocationOption func(Allocator)

func WithFilter

func WithFilter(filter Filter) AllocationOption

type Allocator

type Allocator interface {
	SetCollectors(collectors map[string]*Collector)
	SetTargets(targets map[string]*target.Item)
	TargetItems() map[string]*target.Item
	Collectors() map[string]*Collector
	GetTargetsForCollectorAndJob(collector string, job string) []*target.Item
	SetFilter(filter Filter)
}

func New

func New(name string, log logr.Logger, opts ...AllocationOption) (Allocator, error)

type AllocatorProvider

type AllocatorProvider func(log logr.Logger, opts ...AllocationOption) Allocator

type Collector

type Collector struct {
	Name       string
	NodeName   string
	NumTargets int
}

Collector Creates a struct that holds Collector information. This struct will be parsed into endpoint with Collector and jobs info. This struct can be extended with information like annotations and labels in the future.

func NewCollector

func NewCollector(name, node string) *Collector

func (Collector) Hash

func (c Collector) Hash() string

func (Collector) String

func (c Collector) String() string

type Filter

type Filter interface {
	Apply(map[string]*target.Item) map[string]*target.Item
}

type Strategy added in v0.100.1

type Strategy interface {
	GetCollectorForTarget(map[string]*Collector, *target.Item) (*Collector, error)
	// SetCollectors exists for strategies where changing the collector set is potentially an expensive operation.
	// The caller must guarantee that the collectors map passed in GetCollectorForTarget is consistent with the latest
	// SetCollectors call. Strategies which don't need this information can just ignore it.
	SetCollectors(map[string]*Collector)
	GetName() string
}

Jump to

Keyboard shortcuts

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