Documentation
¶
Overview ¶
Package componentstatus is an experimental module that defines how components should report health statues, how collector hosts should facilitate component status reporting, and how extensions should watch for new component statuses.
This package is currently under development and is exempt from the Collector SIG's breaking change policy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReportStatus ¶ added in v0.108.0
ReportStatus is a helper function that handles checking if the component.Host has implemented Reporter. If it has, the Event is reported. Otherwise, nothing happens.
func StatusIsError ¶
StatusIsError returns true for error statuses (e.g. StatusRecoverableError, StatusPermanentError, or StatusFatalError)
Types ¶
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event contains a status, a timestamp, optional error information, and additional attributes
func NewEvent ¶
func NewEvent(st Status, opts ...EventBuilderOption) *Event
NewEvent creates and returns an Event with the specified options and sets the timestamp time.Now(). To set an error on the event for an error status use the WithError with one of the dedicated status (e.g. StatusRecoverableError, StatusPermanentError, StatusFatalError)
func NewFatalErrorEvent ¶
NewFatalErrorEvent wraps the fatal runtime error passed as argument as a Event with a status StatusFatalError and a timestamp set to time.Now().
func NewPermanentErrorEvent ¶
NewPermanentErrorEvent wraps an error requiring human intervention to fix passed as argument as a Event with a status StatusPermanentError and a timestamp set to time.Now().
func NewRecoverableErrorEvent ¶
NewRecoverableErrorEvent wraps a transient error passed as argument as a Event with a status StatusRecoverableError and a timestamp set to time.Now().
func (*Event) Attributes ¶ added in v0.132.0
Attributes returns the attributes (pcommon.Map) associated with the Event.
type EventBuilderOption ¶ added in v0.132.0
type EventBuilderOption interface {
// contains filtered or unexported methods
}
EventBuilderOption is a sealed interface wrapping options for NewEvent.
func WithAttributes ¶ added in v0.132.0
func WithAttributes(attributes pcommon.Map) EventBuilderOption
WithAttributes sets the Event attributes.
func WithError ¶ added in v0.132.0
func WithError(err error) EventBuilderOption
WithError sets the Event error.
type InstanceID ¶
type InstanceID struct {
// contains filtered or unexported fields
}
InstanceID uniquely identifies a component instance
TODO: consider moving this struct to a new package/module like `extension/statuswatcher` https://github.com/open-telemetry/opentelemetry-collector/issues/10764
func NewInstanceID ¶ added in v0.108.0
func NewInstanceID(componentID component.ID, kind component.Kind, pipelineIDs ...pipeline.ID) *InstanceID
NewInstanceID returns an ID that uniquely identifies a component.
func (*InstanceID) AllPipelineIDs ¶ added in v0.108.0
func (id *InstanceID) AllPipelineIDs(f func(pipeline.ID) bool)
AllPipelineIDs calls f for each pipeline this instance is associated with. If f returns false it will stop iteration.
func (*InstanceID) ComponentID ¶ added in v0.108.0
func (id *InstanceID) ComponentID() component.ID
ComponentID returns the ComponentID associated with this instance.
func (*InstanceID) Kind ¶
func (id *InstanceID) Kind() component.Kind
Kind returns the component Kind associated with this instance.
func (*InstanceID) WithPipelines ¶ added in v0.108.0
func (id *InstanceID) WithPipelines(pipelineIDs ...pipeline.ID) *InstanceID
WithPipelines returns a new InstanceID updated to include the given pipelineIDs.
type Reporter ¶ added in v0.108.0
type Reporter interface {
// Report allows a component to report runtime changes in status. The service
// will automatically report status for a component during startup and shutdown. Components can
// use this method to report status after start and before shutdown. For more details about
// component status reporting see: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-status.md
Report(*Event)
}
Reporter is an extra interface for `component.Host` implementations. A Reporter defines how to report a `componentstatus.Event`.
type Status ¶
type Status int32
const ( // StatusNone indicates absence of component status. StatusNone Status = iota // StatusStarting indicates the component is starting. StatusStarting // StatusOK indicates the component is running without issues. StatusOK // StatusRecoverableError indicates that the component has experienced a transient error and may recover. StatusRecoverableError // StatusPermanentError indicates that the component has detected a condition at runtime that will need human intervention to fix. The collector will continue to run in a degraded mode. StatusPermanentError // StatusFatalError indicates that the collector has experienced a fatal runtime error and will shut down. StatusFatalError // StatusStopping indicates that the component is in the process of shutting down. StatusStopping // StatusStopped indicates that the component has completed shutdown. StatusStopped )
Enumeration of possible component statuses
type Watcher ¶
type Watcher interface {
// ComponentStatusChanged notifies about a change in the source component status.
// Extensions that implement this interface must be ready that the ComponentStatusChanged
// may be called before, after or concurrently with calls to Component.Start() and Component.Shutdown().
// The function may be called concurrently with itself.
ComponentStatusChanged(source *InstanceID, event *Event)
}
Watcher is an extra interface for Extension hosted by the OpenTelemetry Collector that is to be implemented by extensions interested in changes to component status.
TODO: consider moving this interface to a new package/module like `extension/statuswatcher` https://github.com/open-telemetry/opentelemetry-collector/issues/10764