Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeExporterFactoryMap

func MakeExporterFactoryMap(factories ...ExporterFactory) (map[configmodels.Type]ExporterFactory, error)

    MakeExporterFactoryMap takes a list of exporter factories and returns a map with factory type as keys. It returns a non-nil error when more than one factories have the same type.

    func MakeExtensionFactoryMap

    func MakeExtensionFactoryMap(factories ...ExtensionFactory) (map[configmodels.Type]ExtensionFactory, error)

      MakeExtensionFactoryMap takes a list of extension factories and returns a map with factory type as keys. It returns a non-nil error when more than one factories have the same type.

      func MakeProcessorFactoryMap

      func MakeProcessorFactoryMap(factories ...ProcessorFactory) (map[configmodels.Type]ProcessorFactory, error)

        MakeProcessorFactoryMap takes a list of processor factories and returns a map with factory type as keys. It returns a non-nil error when more than one factories have the same type.

        func MakeReceiverFactoryMap

        func MakeReceiverFactoryMap(factories ...ReceiverFactory) (map[configmodels.Type]ReceiverFactory, error)

          MakeReceiverFactoryMap takes a list of receiver factories and returns a map with factory type as keys. It returns a non-nil error when more than one factories have the same type.

          Types

          type ApplicationStartInfo

          type ApplicationStartInfo struct {
          	// Executable file name, e.g. "otelcol".
          	ExeName string
          
          	// Long name, used e.g. in the logs.
          	LongName string
          
          	// Version string.
          	Version string
          
          	// Git hash of the source code.
          	GitHash string
          }

            ApplicationStartInfo is the information that is logged at the application start and passed into each component. This information can be overridden in custom builds.

            type Component

            type Component interface {
            	// Start tells the component to start. Host parameter can be used for communicating
            	// with the host after Start() has already returned. If error is returned by
            	// Start() then the collector startup will be aborted.
            	// If this is an exporter component it may prepare for exporting
            	// by connecting to the endpoint.
            	//
            	// If the component needs to perform a long-running starting operation then it is recommended
            	// that Start() returns quickly and the long-running operation is performed in background.
            	// In that case make sure that the long-running operation does not use the context passed
            	// to Start() function since that context will be cancelled soon and can abort the long-running operation.
            	// Create a new context from the context.Background() for long-running operations.
            	Start(ctx context.Context, host Host) error
            
            	// Shutdown is invoked during service shutdown.
            	//
            	// If there are any background operations running by the component they must be aborted as soon as possible.
            	// Remember that if you started any long-running background operation from the Start() method that operation
            	// must be also cancelled.
            	Shutdown(ctx context.Context) error
            }

              Component is either a receiver, exporter, processor or extension.

              type ConfigUnmarshaler

              type ConfigUnmarshaler interface {
              	// Unmarshal is a function that un-marshals a viper data into a config struct in a custom way.
              	// componentViperSection *viper.Viper
              	//   The config for this specific component. May be nil or empty if no config available.
              	// intoCfg interface{}
              	//   An empty interface wrapping a pointer to the config struct to unmarshal into.
              	Unmarshal(componentViperSection *viper.Viper, intoCfg interface{}) error
              }

                ConfigUnmarshaler interface is an optional interface that if implemented by a Factory, the configuration loading system will use to unmarshal the config.

                type CustomUnmarshaler

                type CustomUnmarshaler func(componentViperSection *viper.Viper, intoCfg interface{}) error

                  CustomUnmarshaler is a function that un-marshals a viper data into a config struct in a custom way. componentViperSection *viper.Viper

                  The config for this specific component. May be nil or empty if no config available.
                  

                  intoCfg interface{}

                  An empty interface wrapping a pointer to the config struct to unmarshal into.
                  

                  type Exporter

                  type Exporter interface {
                  	Component
                  }

                    Exporter defines functions that all exporters must implement.

                    type ExporterCreateParams

                    type ExporterCreateParams struct {
                    	// Logger that the factory can use during creation and can pass to the created
                    	// component to be used later as well.
                    	Logger *zap.Logger
                    
                    	// ApplicationStartInfo can be used by components for informational purposes
                    	ApplicationStartInfo ApplicationStartInfo
                    }

                      ExporterCreateParams is passed to Create*Exporter functions.

                      type ExporterFactory

                      type ExporterFactory interface {
                      	Factory
                      
                      	// CreateDefaultConfig creates the default configuration for the Exporter.
                      	// This method can be called multiple times depending on the pipeline
                      	// configuration and should not cause side-effects that prevent the creation
                      	// of multiple instances of the Exporter.
                      	// The object returned by this method needs to pass the checks implemented by
                      	// 'configcheck.ValidateConfig'. It is recommended to have such check in the
                      	// tests of any implementation of the Factory interface.
                      	CreateDefaultConfig() configmodels.Exporter
                      
                      	// CreateTracesExporter creates a trace exporter based on this config.
                      	// If the exporter type does not support tracing or if the config is not valid
                      	// error will be returned instead.
                      	CreateTracesExporter(
                      		ctx context.Context,
                      		params ExporterCreateParams,
                      		cfg configmodels.Exporter,
                      	) (TracesExporter, error)
                      
                      	// CreateMetricsExporter creates a metrics exporter based on this config.
                      	// If the exporter type does not support metrics or if the config is not valid
                      	// error will be returned instead.
                      	CreateMetricsExporter(
                      		ctx context.Context,
                      		params ExporterCreateParams,
                      		cfg configmodels.Exporter,
                      	) (MetricsExporter, error)
                      
                      	// CreateLogsExporter creates an exporter based on the config.
                      	// If the exporter type does not support logs or if the config is not valid
                      	// error will be returned instead.
                      	CreateLogsExporter(
                      		ctx context.Context,
                      		params ExporterCreateParams,
                      		cfg configmodels.Exporter,
                      	) (LogsExporter, error)
                      }

                        ExporterFactory can create TracesExporter and MetricsExporter. This is the new factory type that can create new style exporters.

                        type ExtensionCreateParams

                        type ExtensionCreateParams struct {
                        	// Logger that the factory can use during creation and can pass to the created
                        	// component to be used later as well.
                        	Logger *zap.Logger
                        
                        	// ApplicationStartInfo can be used by components for informational purposes
                        	ApplicationStartInfo ApplicationStartInfo
                        }

                          ExtensionCreateParams is passed to ExtensionFactory.Create* functions.

                          type ExtensionFactory

                          type ExtensionFactory interface {
                          	Factory
                          
                          	// CreateDefaultConfig creates the default configuration for the Extension.
                          	// This method can be called multiple times depending on the pipeline
                          	// configuration and should not cause side-effects that prevent the creation
                          	// of multiple instances of the Extension.
                          	// The object returned by this method needs to pass the checks implemented by
                          	// 'configcheck.ValidateConfig'. It is recommended to have such check in the
                          	// tests of any implementation of the Factory interface.
                          	CreateDefaultConfig() configmodels.Extension
                          
                          	// CreateExtension creates a service extension based on the given config.
                          	CreateExtension(ctx context.Context, params ExtensionCreateParams, cfg configmodels.Extension) (ServiceExtension, error)
                          }

                            ExtensionFactory is a factory interface for extensions to the service.

                            type Factories

                            type Factories struct {
                            	// Receivers maps receiver type names in the config to the respective factory.
                            	Receivers map[configmodels.Type]ReceiverFactory
                            
                            	// Processors maps processor type names in the config to the respective factory.
                            	Processors map[configmodels.Type]ProcessorFactory
                            
                            	// Exporters maps exporter type names in the config to the respective factory.
                            	Exporters map[configmodels.Type]ExporterFactory
                            
                            	// Extensions maps extension type names in the config to the respective factory.
                            	Extensions map[configmodels.Type]ExtensionFactory
                            }

                              Factories struct holds in a single type all component factories that can be handled by the Config.

                              type Factory

                              type Factory interface {
                              	// Type gets the type of the component created by this factory.
                              	Type() configmodels.Type
                              }

                                Factory interface must be implemented by all component factories.

                                type Host

                                type Host interface {
                                	// ReportFatalError is used to report to the host that the extension
                                	// encountered a fatal error (i.e.: an error that the instance can't recover
                                	// from) after its start function had already returned.
                                	ReportFatalError(err error)
                                
                                	// GetFactory of the specified kind. Returns the factory for a component type.
                                	// This allows components to create other components. For example:
                                	//   func (r MyReceiver) Start(host component.Host) error {
                                	//     apacheFactory := host.GetFactory(KindReceiver,"apache").(component.ReceiverFactory)
                                	//     receiver, err := apacheFactory.CreateMetricsReceiver(...)
                                	//     ...
                                	//   }
                                	// GetFactory can be called by the component anytime after Start() begins and
                                	// until Shutdown() is called. Note that the component is responsible for destroying
                                	// other components that it creates.
                                	GetFactory(kind Kind, componentType configmodels.Type) Factory
                                
                                	// Return map of extensions. Only enabled and created extensions will be returned.
                                	// Typically is used to find an extension by type or by full config name. Both cases
                                	// can be done by iterating the returned map. There are typically very few extensions
                                	// so there there is no performance implications due to iteration.
                                	GetExtensions() map[configmodels.Extension]ServiceExtension
                                
                                	// Return map of exporters. Only enabled and created exporters will be returned.
                                	// Typically is used to find exporters by type or by full config name. Both cases
                                	// can be done by iterating the returned map. There are typically very few exporters
                                	// so there there is no performance implications due to iteration.
                                	// This returns a map by DataType of maps by exporter configs to the exporter instance.
                                	// Note that an exporter with the same name may be attached to multiple pipelines and
                                	// thus we may have an instance of the exporter for multiple data types.
                                	// This is an experimental function that may change or even be removed completely.
                                	GetExporters() map[configmodels.DataType]map[configmodels.Exporter]Exporter
                                }

                                  Host represents the entity that is hosting a Component. It is used to allow communication between the Component and its host (normally the service.Application is the host).

                                  type Kind

                                  type Kind int

                                    Kind specified one of the 4 components kinds, see consts below.

                                    const (
                                    	KindReceiver Kind
                                    	KindProcessor
                                    	KindExporter
                                    	KindExtension
                                    )

                                    type LogsExporter

                                    type LogsExporter interface {
                                    	Exporter
                                    	consumer.LogsConsumer
                                    }

                                      LogsExporter is an Exporter that can consume logs.

                                      type LogsProcessor

                                      type LogsProcessor interface {
                                      	Processor
                                      	consumer.LogsConsumer
                                      }

                                        LogsProcessor is a processor that can consume logs.

                                        type LogsReceiver

                                        type LogsReceiver interface {
                                        	Receiver
                                        }

                                          A LogsReceiver is a "log data"-to-"internal format" converter. Its purpose is to translate data from the wild into internal data format. LogsReceiver feeds a consumer.LogsConsumer with data.

                                          type MetricsExporter

                                          type MetricsExporter interface {
                                          	Exporter
                                          	consumer.MetricsConsumer
                                          }

                                            MetricsExporter is an Exporter that can consume metrics.

                                            type MetricsProcessor

                                            type MetricsProcessor interface {
                                            	Processor
                                            	consumer.MetricsConsumer
                                            }

                                              MetricsProcessor is a processor that can consume metrics.

                                              type MetricsReceiver

                                              type MetricsReceiver interface {
                                              	Receiver
                                              }

                                                A MetricsReceiver is an "arbitrary data"-to-"internal format" converter. Its purpose is to translate data from the wild into internal metrics format. MetricsReceiver feeds a consumer.MetricsConsumer with data.

                                                For example it could be Prometheus data source which translates Prometheus metrics into consumerdata.MetricsData.

                                                type PipelineWatcher

                                                type PipelineWatcher interface {
                                                	// Ready notifies the ServiceExtension that all pipelines were built and the
                                                	// receivers were started, i.e.: the service is ready to receive data
                                                	// (notice that it may already have received data when this method is called).
                                                	Ready() error
                                                
                                                	// NotReady notifies the ServiceExtension that all receivers are about to be stopped,
                                                	// i.e.: pipeline receivers will not accept new data.
                                                	// This is sent before receivers are stopped, so the ServiceExtension can take any
                                                	// appropriate action before that happens.
                                                	NotReady() error
                                                }

                                                  PipelineWatcher is an extra interface for ServiceExtension hosted by the OpenTelemetry Collector that is to be implemented by extensions interested in changes to pipeline states. Typically this will be used by extensions that change their behavior if data is being ingested or not, e.g.: a k8s readiness probe.

                                                  type Processor

                                                  type Processor interface {
                                                  	Component
                                                  
                                                  	// GetCapabilities must return the capabilities of the processor.
                                                  	GetCapabilities() ProcessorCapabilities
                                                  }

                                                    Processor defines the common functions that must be implemented by TracesProcessor and MetricsProcessor.

                                                    type ProcessorCapabilities

                                                    type ProcessorCapabilities struct {
                                                    	// MutatesConsumedData is set to true if Consume* function of the
                                                    	// processor modifies the input TraceData or MetricsData argument.
                                                    	// Processors which modify the input data MUST set this flag to true. If the processor
                                                    	// does not modify the data it MUST set this flag to false. If the processor creates
                                                    	// a copy of the data before modifying then this flag can be safely set to false.
                                                    	MutatesConsumedData bool
                                                    }

                                                      ProcessorCapabilities describes the capabilities of a Processor.

                                                      type ProcessorCreateParams

                                                      type ProcessorCreateParams struct {
                                                      	// Logger that the factory can use during creation and can pass to the created
                                                      	// component to be used later as well.
                                                      	Logger *zap.Logger
                                                      
                                                      	// ApplicationStartInfo can be used by components for informational purposes
                                                      	ApplicationStartInfo ApplicationStartInfo
                                                      }

                                                        ProcessorCreateParams is passed to Create* functions in ProcessorFactory.

                                                        type ProcessorFactory

                                                        type ProcessorFactory interface {
                                                        	Factory
                                                        
                                                        	// CreateDefaultConfig creates the default configuration for the Processor.
                                                        	// This method can be called multiple times depending on the pipeline
                                                        	// configuration and should not cause side-effects that prevent the creation
                                                        	// of multiple instances of the Processor.
                                                        	// The object returned by this method needs to pass the checks implemented by
                                                        	// 'configcheck.ValidateConfig'. It is recommended to have such check in the
                                                        	// tests of any implementation of the Factory interface.
                                                        	CreateDefaultConfig() configmodels.Processor
                                                        
                                                        	// CreateTraceProcessor creates a trace processor based on this config.
                                                        	// If the processor type does not support tracing or if the config is not valid
                                                        	// error will be returned instead.
                                                        	CreateTracesProcessor(
                                                        		ctx context.Context,
                                                        		params ProcessorCreateParams,
                                                        		cfg configmodels.Processor,
                                                        		nextConsumer consumer.TracesConsumer,
                                                        	) (TracesProcessor, error)
                                                        
                                                        	// CreateMetricsProcessor creates a metrics processor based on this config.
                                                        	// If the processor type does not support metrics or if the config is not valid
                                                        	// error will be returned instead.
                                                        	CreateMetricsProcessor(
                                                        		ctx context.Context,
                                                        		params ProcessorCreateParams,
                                                        		cfg configmodels.Processor,
                                                        		nextConsumer consumer.MetricsConsumer,
                                                        	) (MetricsProcessor, error)
                                                        
                                                        	// CreateLogsProcessor creates a processor based on the config.
                                                        	// If the processor type does not support logs or if the config is not valid
                                                        	// error will be returned instead.
                                                        	CreateLogsProcessor(
                                                        		ctx context.Context,
                                                        		params ProcessorCreateParams,
                                                        		cfg configmodels.Processor,
                                                        		nextConsumer consumer.LogsConsumer,
                                                        	) (LogsProcessor, error)
                                                        }

                                                          ProcessorFactory is factory interface for processors. This is the new factory type that can create new style processors.

                                                          type Receiver

                                                          type Receiver interface {
                                                          	Component
                                                          }

                                                            Receiver defines functions that trace and metric receivers must implement.

                                                            type ReceiverCreateParams

                                                            type ReceiverCreateParams struct {
                                                            	// Logger that the factory can use during creation and can pass to the created
                                                            	// component to be used later as well.
                                                            	Logger *zap.Logger
                                                            
                                                            	// ApplicationStartInfo can be used by components for informational purposes
                                                            	ApplicationStartInfo ApplicationStartInfo
                                                            }

                                                              ReceiverCreateParams is passed to ReceiverFactory.Create* functions.

                                                              type ReceiverFactory

                                                              type ReceiverFactory interface {
                                                              	Factory
                                                              
                                                              	// CreateDefaultConfig creates the default configuration for the Receiver.
                                                              	// This method can be called multiple times depending on the pipeline
                                                              	// configuration and should not cause side-effects that prevent the creation
                                                              	// of multiple instances of the Receiver.
                                                              	// The object returned by this method needs to pass the checks implemented by
                                                              	// 'configcheck.ValidateConfig'. It is recommended to have such check in the
                                                              	// tests of any implementation of the Factory interface.
                                                              	CreateDefaultConfig() configmodels.Receiver
                                                              
                                                              	// CreateTraceReceiver creates a trace receiver based on this config.
                                                              	// If the receiver type does not support tracing or if the config is not valid
                                                              	// error will be returned instead.
                                                              	CreateTracesReceiver(ctx context.Context, params ReceiverCreateParams,
                                                              		cfg configmodels.Receiver, nextConsumer consumer.TracesConsumer) (TracesReceiver, error)
                                                              
                                                              	// CreateMetricsReceiver creates a metrics receiver based on this config.
                                                              	// If the receiver type does not support metrics or if the config is not valid
                                                              	// error will be returned instead.
                                                              	CreateMetricsReceiver(ctx context.Context, params ReceiverCreateParams,
                                                              		cfg configmodels.Receiver, nextConsumer consumer.MetricsConsumer) (MetricsReceiver, error)
                                                              
                                                              	// CreateLogsReceiver creates a log receiver based on this config.
                                                              	// If the receiver type does not support the data type or if the config is not valid
                                                              	// error will be returned instead.
                                                              	CreateLogsReceiver(ctx context.Context, params ReceiverCreateParams,
                                                              		cfg configmodels.Receiver, nextConsumer consumer.LogsConsumer) (LogsReceiver, error)
                                                              }

                                                                ReceiverFactory can create TracesReceiver and MetricsReceiver. This is the new factory type that can create new style receivers.

                                                                type ServiceExtension

                                                                type ServiceExtension interface {
                                                                	Component
                                                                }

                                                                  ServiceExtension is the interface for objects hosted by the OpenTelemetry Collector that don't participate directly on data pipelines but provide some functionality to the service, examples: health check endpoint, z-pages, etc.

                                                                  type TracesExporter

                                                                  type TracesExporter interface {
                                                                  	Exporter
                                                                  	consumer.TracesConsumer
                                                                  }

                                                                    TracesExporter is a Exporter that can consume traces.

                                                                    type TracesProcessor

                                                                    type TracesProcessor interface {
                                                                    	Processor
                                                                    	consumer.TracesConsumer
                                                                    }

                                                                      TracesProcessor is a processor that can consume traces.

                                                                      type TracesReceiver

                                                                      type TracesReceiver interface {
                                                                      	Receiver
                                                                      }

                                                                        A TracesReceiver is an "arbitrary data"-to-"internal format" converter. Its purpose is to translate data from the wild into internal trace format. TracesReceiver feeds a consumer.TracesConsumer with data.

                                                                        For example it could be Zipkin data source which translates Zipkin spans into consumerdata.TraceData.

                                                                        Directories

                                                                        Path Synopsis
                                                                        Package oterr provides helper functions to create and process OpenTelemetry specific errors
                                                                        Package oterr provides helper functions to create and process OpenTelemetry specific errors
                                                                        Package componenttest define types and functions used to help test packages implementing the component package interfaces.
                                                                        Package componenttest define types and functions used to help test packages implementing the component package interfaces.