scheduler

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package scheduler exposes utilities for scheduling and running OpenTelemetry Collector components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Host

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

Host implements otelcomponent.Host for Grafana Alloy.

func NewHost

func NewHost(l log.Logger, opts ...HostOption) *Host

NewHost creates a new Host.

func (*Host) GetExtensions

func (h *Host) GetExtensions() map[otelcomponent.ID]otelcomponent.Component

GetExtensions implements otelcomponent.Host.

type HostOption

type HostOption func(*Host)

HostOption customizes behavior of the Host.

func WithHostExporters

func WithHostExporters(exporters map[pipeline.Signal]map[otelcomponent.ID]otelcomponent.Component) HostOption

WithHostExporters provides a custom set of exporters to the Host.

func WithHostExtensions

func WithHostExtensions(extensions map[otelcomponent.ID]otelcomponent.Component) HostOption

WithHostExtensions provides a custom set of extensions to the Host.

type Scheduler

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

Scheduler implements manages a set of OpenTelemetry Collector components. Scheduler is intended to be used from Alloy components which need to schedule OpenTelemetry Collector components; it does not implement the full component.Component interface.

Each OpenTelemetry Collector component has one instance per supported telemetry signal, which is why Scheduler supports multiple components. For example, when creating the otlpreceiver component, you would have three total instances: one for logs, one for metrics, and one for traces. Scheduler should only be used to manage the different signals of the same OpenTelemetry Collector component; this means that otlpreceiver and jaegerreceiver should not share the same Scheduler.

func New

func New(l log.Logger) *Scheduler

New creates a new unstarted Scheduler. Call Run to start it, and call Schedule to schedule components to run.

func NewWithPauseCallbacks added in v1.6.0

func NewWithPauseCallbacks(l log.Logger, onPause func(), onResume func()) *Scheduler

NewWithPauseCallbacks is like New, but allows to specify onPause() and onResume() callbacks. The callbacks are a useful way of pausing and resuming the ingestion of data by the components: * onPause() is called before the scheduler stops the components. * onResume() is called after the scheduler starts the components. The callbacks are used by the Schedule() and Run() functions. The scheduler is assumed to start paused; Schedule() won't call onPause() if Run() was never ran.

func (*Scheduler) CurrentHealth

func (cs *Scheduler) CurrentHealth() component.Health

CurrentHealth implements component.HealthComponent. The component is reported as healthy when the most recent set of scheduled components were started successfully.

func (*Scheduler) Run

func (cs *Scheduler) Run(ctx context.Context) error

Run starts the Scheduler and stops the components when the context is cancelled.

func (*Scheduler) Schedule

func (cs *Scheduler) Schedule(ctx context.Context, updateConsumers func(), h otelcomponent.Host, cc ...otelcomponent.Component)

Schedule a new set of OpenTelemetry Components to run. Components will only be started when the Scheduler's Run() function has been called.

Schedule() completely overrides the set of previously running components. Components which have been removed since the last call to Schedule will be stopped.

updateConsumers is called after the components are paused and before starting the new components. It is expected that this function will set the new set of consumers to the wrapping consumer that's assigned to the Alloy component.

Jump to

Keyboard shortcuts

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