Documentation ¶
Overview ¶
Package receiver defines components that allows the collector to receive metrics, traces and logs.
Receiver receives data from a source (either from a remote source via network or scrapes from a local host) and pushes the data to the pipelines it is attached to by calling the nextConsumer.Consume*() function.
Error Handling ¶
The nextConsumer.Consume*() function may return an error to indicate that the data was not accepted. There are 2 types of possible errors: Permanent and non-Permanent. The receiver must check the type of the error using IsPermanent() helper.
If the error is Permanent, then the nextConsumer.Consume*() call should not be retried with the same data. This typically happens when the data cannot be serialized by the exporter that is attached to the pipeline or when the destination refuses the data because it cannot decode it. The receiver must indicate to the source from which it received the data that the received data was bad, if the receiving protocol allows to do that. In case of OTLP/HTTP for example, this means that HTTP 400 response is returned to the sender.
If the error is non-Permanent then the nextConsumer.Consume*() call should be retried with the same data. This may be done by the receiver itself, however typically it is done by the original sender, after the receiver returns a response to the sender indicating that the Collector is currently overloaded and the request must be retried. In case of OTLP/HTTP for example, this means that HTTP 429 or 503 response is returned.
Acknowledgment and Checkpointing ¶
The receivers that receive data via a network protocol that support acknowledgments MUST follow this order of operations:
- Receive data from some sender (typically from a network).
- Push received data to the pipeline by calling nextConsumer.Consume*() function.
- Acknowledge successful data receipt to the sender if Consume*() succeeded or return a failure to the sender if Consume*() returned an error.
This ensures there are strong delivery guarantees once the data is acknowledged by the Collector.
Similarly, receivers that use checkpointing to remember the position of last processed data (e.g. via storage extension) MUST store the checkpoint only AFTER the Consume*() call returns.
Index ¶
- func MakeFactoryMap(factories ...Factory) (map[component.Type]Factory, error)
- type Builder
- func (b *Builder) CreateLogs(ctx context.Context, set CreateSettings, next consumer.Logs) (Logs, error)
- func (b *Builder) CreateMetrics(ctx context.Context, set CreateSettings, next consumer.Metrics) (Metrics, error)
- func (b *Builder) CreateTraces(ctx context.Context, set CreateSettings, next consumer.Traces) (Traces, error)
- func (b *Builder) Factory(componentType component.Type) component.Factory
- type CreateLogsFunc
- type CreateMetricsFunc
- type CreateSettings
- type CreateTracesFunc
- type Factory
- type FactoryOption
- type Logs
- type Metrics
- type Traces
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder receiver is a helper struct that given a set of Configs and Factories helps with creating receivers.
func NewBuilder ¶
func NewBuilder(cfgs map[component.ID]component.Config, factories map[component.Type]Factory) *Builder
NewBuilder creates a new receiver.Builder to help with creating components form a set of configs and factories.
func (*Builder) CreateLogs ¶
func (b *Builder) CreateLogs(ctx context.Context, set CreateSettings, next consumer.Logs) (Logs, error)
CreateLogs creates a Logs receiver based on the settings and config.
func (*Builder) CreateMetrics ¶
func (b *Builder) CreateMetrics(ctx context.Context, set CreateSettings, next consumer.Metrics) (Metrics, error)
CreateMetrics creates a Metrics receiver based on the settings and config.
func (*Builder) CreateTraces ¶
func (b *Builder) CreateTraces(ctx context.Context, set CreateSettings, next consumer.Traces) (Traces, error)
CreateTraces creates a Traces receiver based on the settings and config.
type CreateLogsFunc ¶
type CreateLogsFunc func(context.Context, CreateSettings, component.Config, consumer.Logs) (Logs, error)
CreateLogsFunc is the equivalent of ReceiverFactory.CreateLogsReceiver().
func (CreateLogsFunc) CreateLogsReceiver ¶
func (f CreateLogsFunc) CreateLogsReceiver( ctx context.Context, set CreateSettings, cfg component.Config, nextConsumer consumer.Logs, ) (Logs, error)
CreateLogsReceiver implements Factory.CreateLogsReceiver().
type CreateMetricsFunc ¶
type CreateMetricsFunc func(context.Context, CreateSettings, component.Config, consumer.Metrics) (Metrics, error)
CreateMetricsFunc is the equivalent of Factory.CreateMetrics.
func (CreateMetricsFunc) CreateMetricsReceiver ¶
func (f CreateMetricsFunc) CreateMetricsReceiver( ctx context.Context, set CreateSettings, cfg component.Config, nextConsumer consumer.Metrics, ) (Metrics, error)
CreateMetricsReceiver implements Factory.CreateMetricsReceiver().
type CreateSettings ¶
type CreateSettings struct { // ID returns the ID of the component that will be created. ID component.ID component.TelemetrySettings // BuildInfo can be used by components for informational purposes. BuildInfo component.BuildInfo }
CreateSettings configures Receiver creators.
type CreateTracesFunc ¶
type CreateTracesFunc func(context.Context, CreateSettings, component.Config, consumer.Traces) (Traces, error)
CreateTracesFunc is the equivalent of Factory.CreateTraces.
func (CreateTracesFunc) CreateTracesReceiver ¶
func (f CreateTracesFunc) CreateTracesReceiver( ctx context.Context, set CreateSettings, cfg component.Config, nextConsumer consumer.Traces) (Traces, error)
CreateTracesReceiver implements Factory.CreateTracesReceiver().
type Factory ¶
type Factory interface { component.Factory // CreateTracesReceiver creates a TracesReceiver based on this config. // If the receiver type does not support tracing or if the config is not valid // an error will be returned instead. `nextConsumer` is never nil. CreateTracesReceiver(ctx context.Context, set CreateSettings, cfg component.Config, nextConsumer consumer.Traces) (Traces, error) // TracesReceiverStability gets the stability level of the TracesReceiver. TracesReceiverStability() component.StabilityLevel // CreateMetricsReceiver creates a MetricsReceiver based on this config. // If the receiver type does not support metrics or if the config is not valid // an error will be returned instead. `nextConsumer` is never nil. CreateMetricsReceiver(ctx context.Context, set CreateSettings, cfg component.Config, nextConsumer consumer.Metrics) (Metrics, error) // MetricsReceiverStability gets the stability level of the MetricsReceiver. MetricsReceiverStability() component.StabilityLevel // CreateLogsReceiver creates a LogsReceiver based on this config. // If the receiver type does not support the data type or if the config is not valid // an error will be returned instead. `nextConsumer` is never nil. CreateLogsReceiver(ctx context.Context, set CreateSettings, cfg component.Config, nextConsumer consumer.Logs) (Logs, error) // LogsReceiverStability gets the stability level of the LogsReceiver. LogsReceiverStability() component.StabilityLevel // contains filtered or unexported methods }
Factory is factory interface for receivers.
This interface cannot be directly implemented. Implementations must use the NewReceiverFactory to implement it.
func NewFactory ¶
func NewFactory(cfgType component.Type, createDefaultConfig component.CreateDefaultConfigFunc, options ...FactoryOption) Factory
NewFactory returns a Factory.
type FactoryOption ¶
type FactoryOption interface {
// contains filtered or unexported methods
}
FactoryOption apply changes to ReceiverOptions.
func WithLogs ¶
func WithLogs(createLogsReceiver CreateLogsFunc, sl component.StabilityLevel) FactoryOption
WithLogs overrides the default "error not supported" implementation for CreateLogsReceiver and the default "undefined" stability level.
func WithMetrics ¶
func WithMetrics(createMetricsReceiver CreateMetricsFunc, sl component.StabilityLevel) FactoryOption
WithMetrics overrides the default "error not supported" implementation for CreateMetricsReceiver and the default "undefined" stability level.
func WithTraces ¶
func WithTraces(createTracesReceiver CreateTracesFunc, sl component.StabilityLevel) FactoryOption
WithTraces overrides the default "error not supported" implementation for CreateTracesReceiver and the default "undefined" stability level.
type Logs ¶
Logs receiver receives logs. Its purpose is to translate data from any format to the collector's internal logs data format. LogsReceiver feeds a consumer.Logs with data.
For example, it could be a receiver that reads syslogs and convert them into plog.Logs.
type Metrics ¶
Metrics receiver receives metrics. Its purpose is to translate data from any format to the collector's internal metrics format. MetricsReceiver feeds a consumer.Metrics with data.
For example, it could be Prometheus data source which translates Prometheus metrics into pmetric.Metrics.
Directories ¶
Path | Synopsis |
---|---|
nopreceiver
module
|
|
otlpreceiver
module
|
|
receiverprofiles
module
|
|
Package scrapererror provides custom error types for scrapers.
|
Package scrapererror provides custom error types for scrapers. |
Package scraperhelper provides utilities for scrapers.
|
Package scraperhelper provides utilities for scrapers. |