Documentation

Overview

    Package config defines the data models for entities. This file defines the models for configuration format. The defined entities are: Config (the top-level structure), Receivers, Exporters, Processors, Pipelines.

    Receivers, Exporters and Processors typically have common configuration settings, however sometimes specific implementations will have extra configuration settings. This requires the configuration data for these entities to be polymorphic.

    To satisfy these requirements we declare interfaces Receiver, Exporter, Processor, which define the behavior. We also provide helper structs ReceiverSettings, ExporterSettings, ProcessorSettings, which define the common settings and un-marshaling from config files.

    Specific Receivers/Exporters/Processors are expected to at the minimum implement the corresponding interface and if they have additional settings they must also extend the corresponding common settings struct (the easiest approach is to embed the common struct).

    Index

    Constants

    View Source
    const (
    	// KeyDelimiter is used as the default key delimiter in the default viper instance.
    	KeyDelimiter = "::"
    )

    Variables

    This section is empty.

    Functions

    This section is empty.

    Types

    type ComponentID

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

      ComponentID represents the identity for a component. It combines two values: * type - the Type of the component. * name - the name of that component. The component ComponentID (combination type + name) is unique for a given component.Kind.

      func IDFromString

      func IDFromString(idStr string) (ComponentID, error)

        IDFromString decodes a string in type[/name] format into ComponentID. The type and name components will have spaces trimmed, the "type" part must be present, the forward slash and "name" are optional. The returned ComponentID will be invalid if err is not-nil.

        func MustIDFromString

        func MustIDFromString(idStr string) ComponentID

          MustIDFromString is equivalent with IDFromString except that it panics instead of returning error. This is useful for testing.

          func (ComponentID) Name

          func (id ComponentID) Name() string

            Name returns the custom name of the component.

            func (ComponentID) String

            func (id ComponentID) String() string

              String returns the ComponentID string representation as "type[/name]" format.

              func (ComponentID) Type

              func (id ComponentID) Type() Type

                Type returns the type of the component.

                type Config

                  Config defines the configuration for the various elements of collector or agent.

                  func (*Config) Validate

                  func (cfg *Config) Validate() error

                    Validate returns an error if the config is invalid.

                    This function performs basic validation of configuration. There may be more subtle invalid cases that we currently don't check for but which we may want to add in the future (e.g. disallowing receiving and exporting on the same endpoint).

                    type CustomUnmarshable

                    type CustomUnmarshable interface {
                    	// Unmarshal is a function that un-marshals a Parser into the unmarshable struct in a custom way.
                    	// componentSection *Parser
                    	//   The config for this specific component. May be nil or empty if no config available.
                    	Unmarshal(componentSection *Parser) error
                    }

                      CustomUnmarshable defines an optional interface for custom configuration unmarshaling. A configuration struct can implement this interface to override the default unmarshaling.

                      type DataType

                      type DataType string

                        DataType is the data type that is supported for collection. We currently support collecting metrics, traces and logs, this can expand in the future.

                        const (
                        	// TracesDataType is the data type tag for traces.
                        	TracesDataType DataType = "traces"
                        
                        	// MetricsDataType is the data type tag for metrics.
                        	MetricsDataType DataType = "metrics"
                        
                        	// LogsDataType is the data type tag for logs.
                        	LogsDataType DataType = "logs"
                        )

                          Currently supported data types. Add new data types here when new types are supported in the future.

                          type Exporter

                          type Exporter interface {
                          	NamedEntity
                          	// contains filtered or unexported methods
                          }

                            Exporter is the configuration of an exporter. Embedded validatable will force each exporter to implement Validate() function

                            type ExporterSettings

                            type ExporterSettings struct {
                            	TypeVal Type   `mapstructure:"-"`
                            	NameVal string `mapstructure:"-"`
                            }

                              ExporterSettings defines common settings for an exporter configuration. Specific exporters can embed this struct and extend it with more fields if needed. When embedded in the exporter config it must be with `mapstructure:"-"` tag.

                              func NewExporterSettings

                              func NewExporterSettings(typeVal Type) *ExporterSettings

                                NewExporterSettings return a new ExporterSettings with the given type.

                                func (*ExporterSettings) Name

                                func (es *ExporterSettings) Name() string

                                  Name gets the exporter name.

                                  func (*ExporterSettings) SetName

                                  func (es *ExporterSettings) SetName(name string)

                                    SetName sets the exporter name.

                                    func (*ExporterSettings) Type

                                    func (es *ExporterSettings) Type() Type

                                      Type sets the exporter type.

                                      func (*ExporterSettings) Validate

                                      func (es *ExporterSettings) Validate() error

                                        Validate validates the configuration and returns an error if invalid.

                                        type Exporters

                                        type Exporters map[string]Exporter

                                          Exporters is a map of names to Exporters.

                                          type Extension

                                          type Extension interface {
                                          	NamedEntity
                                          	// contains filtered or unexported methods
                                          }

                                            Extension is the configuration of a service extension. Specific extensions must implement this interface and will typically embed ExtensionSettings struct or a struct that extends it. Embedded validatable will force each extension to implement Validate() function

                                            type ExtensionSettings

                                            type ExtensionSettings struct {
                                            	TypeVal Type   `mapstructure:"-"`
                                            	NameVal string `mapstructure:"-"`
                                            }

                                              ExtensionSettings defines common settings for a extension configuration. Specific extensions can embed this struct and extend it with more fields if needed. When embedded in the extension config it must be with `mapstructure:"-"` tag.

                                              func NewExtensionSettings

                                              func NewExtensionSettings(typeVal Type) *ExtensionSettings

                                                NewExtensionSettings return a new ExtensionSettings with the given type.

                                                func (*ExtensionSettings) Name

                                                func (ext *ExtensionSettings) Name() string

                                                  Name gets the extension name.

                                                  func (*ExtensionSettings) SetName

                                                  func (ext *ExtensionSettings) SetName(name string)

                                                    SetName sets the extension name.

                                                    func (*ExtensionSettings) Type

                                                    func (ext *ExtensionSettings) Type() Type

                                                      Type sets the extension type.

                                                      func (*ExtensionSettings) Validate

                                                      func (ext *ExtensionSettings) Validate() error

                                                        Validate validates the configuration and returns an error if invalid.

                                                        type Extensions

                                                        type Extensions map[string]Extension

                                                          Extensions is a map of names to extensions.

                                                          type NamedEntity

                                                          type NamedEntity interface {
                                                          	Type() Type
                                                          	Name() string
                                                          	SetName(name string)
                                                          }

                                                            NamedEntity is a configuration entity that has a type and a name.

                                                            type Parser

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

                                                              Parser loads configuration.

                                                              func NewParser

                                                              func NewParser() *Parser

                                                                NewParser creates a new empty Parser instance.

                                                                func NewParserFromBuffer

                                                                func NewParserFromBuffer(buf io.Reader) (*Parser, error)

                                                                  NewParserFromBuffer creates a new Parser by reading the given yaml buffer.

                                                                  func NewParserFromFile

                                                                  func NewParserFromFile(fileName string) (*Parser, error)

                                                                    NewParserFromFile creates a new Parser by reading the given file.

                                                                    func NewParserFromStringMap

                                                                    func NewParserFromStringMap(data map[string]interface{}) *Parser

                                                                      NewParserFromStringMap creates a parser from a map[string]interface{}.

                                                                      func (*Parser) AllKeys

                                                                      func (l *Parser) AllKeys() []string

                                                                        AllKeys returns all keys holding a value, regardless of where they are set. Nested keys are returned with a KeyDelimiter separator

                                                                        func (*Parser) Get

                                                                        func (l *Parser) Get(key string) interface{}

                                                                          Get can retrieve any value given the key to use.

                                                                          func (*Parser) IsSet

                                                                          func (l *Parser) IsSet(key string) bool

                                                                            IsSet checks to see if the key has been set in any of the data locations. IsSet is case-insensitive for a key.

                                                                            func (*Parser) MergeStringMap

                                                                            func (l *Parser) MergeStringMap(cfg map[string]interface{}) error

                                                                              MergeStringMap merges the configuration from the given map with the existing config. Note that the given map may be modified.

                                                                              func (*Parser) Set

                                                                              func (l *Parser) Set(key string, value interface{})

                                                                                Set sets the value for the key.

                                                                                func (*Parser) Sub

                                                                                func (l *Parser) Sub(key string) (*Parser, error)

                                                                                  Sub returns new Parser instance representing a sub tree of this instance.

                                                                                  func (*Parser) ToStringMap

                                                                                  func (l *Parser) ToStringMap() map[string]interface{}

                                                                                    ToStringMap creates a map[string]interface{} from a Parser.

                                                                                    func (*Parser) Unmarshal

                                                                                    func (l *Parser) Unmarshal(rawVal interface{}) error

                                                                                      Unmarshal unmarshals the config into a struct. Make sure that the tags on the fields of the structure are properly set.

                                                                                      func (*Parser) UnmarshalExact

                                                                                      func (l *Parser) UnmarshalExact(intoCfg interface{}) error

                                                                                        UnmarshalExact unmarshals the config into a struct, erroring if a field is nonexistent.

                                                                                        func (*Parser) Viper

                                                                                        func (l *Parser) Viper() *viper.Viper

                                                                                          Viper returns the viper.Viper implementation of this Parser.

                                                                                          type Pipeline

                                                                                          type Pipeline struct {
                                                                                          	Name       string
                                                                                          	InputType  DataType
                                                                                          	Receivers  []string
                                                                                          	Processors []string
                                                                                          	Exporters  []string
                                                                                          }

                                                                                            Pipeline defines a single pipeline.

                                                                                            type Pipelines

                                                                                            type Pipelines map[string]*Pipeline

                                                                                              Pipelines is a map of names to Pipelines.

                                                                                              type Processor

                                                                                              type Processor interface {
                                                                                              	NamedEntity
                                                                                              	// contains filtered or unexported methods
                                                                                              }

                                                                                                Processor is the configuration of a processor. Specific processors must implement this interface and will typically embed ProcessorSettings struct or a struct that extends it. Embedded validatable will force each processor to implement Validate() function

                                                                                                type ProcessorSettings

                                                                                                type ProcessorSettings struct {
                                                                                                	TypeVal Type   `mapstructure:"-"`
                                                                                                	NameVal string `mapstructure:"-"`
                                                                                                }

                                                                                                  ProcessorSettings defines common settings for a processor configuration. Specific processors can embed this struct and extend it with more fields if needed. When embedded in the processor config it must be with `mapstructure:"-"` tag.

                                                                                                  func NewProcessorSettings

                                                                                                  func NewProcessorSettings(typeVal Type) *ProcessorSettings

                                                                                                    NewProcessorSettings return a new ProcessorSettings with the given type.

                                                                                                    func (*ProcessorSettings) Name

                                                                                                    func (proc *ProcessorSettings) Name() string

                                                                                                      Name gets the processor name.

                                                                                                      func (*ProcessorSettings) SetName

                                                                                                      func (proc *ProcessorSettings) SetName(name string)

                                                                                                        SetName sets the processor name.

                                                                                                        func (*ProcessorSettings) Type

                                                                                                        func (proc *ProcessorSettings) Type() Type

                                                                                                          Type sets the processor type.

                                                                                                          func (*ProcessorSettings) Validate

                                                                                                          func (proc *ProcessorSettings) Validate() error

                                                                                                            Validate validates the configuration and returns an error if invalid.

                                                                                                            type Processors

                                                                                                            type Processors map[string]Processor

                                                                                                              Processors is a map of names to Processors.

                                                                                                              type Receiver

                                                                                                              type Receiver interface {
                                                                                                              	NamedEntity
                                                                                                              	// contains filtered or unexported methods
                                                                                                              }

                                                                                                                Receiver is the configuration of a receiver. Specific receivers must implement this interface and will typically embed ReceiverSettings struct or a struct that extends it. Embedded validatable will force each receiver to implement Validate() function

                                                                                                                type ReceiverSettings

                                                                                                                type ReceiverSettings struct {
                                                                                                                	TypeVal Type   `mapstructure:"-"`
                                                                                                                	NameVal string `mapstructure:"-"`
                                                                                                                }

                                                                                                                  ReceiverSettings defines common settings for a receiver configuration. Specific receivers can embed this struct and extend it with more fields if needed. It is highly recommended to "override" the Validate() function. When embedded in the processor config it must be with `mapstructure:"-"` tag.

                                                                                                                  func (*ReceiverSettings) Name

                                                                                                                  func (rs *ReceiverSettings) Name() string

                                                                                                                    Name gets the receiver name.

                                                                                                                    func (*ReceiverSettings) SetName

                                                                                                                    func (rs *ReceiverSettings) SetName(name string)

                                                                                                                      SetName sets the receiver name.

                                                                                                                      func (*ReceiverSettings) Type

                                                                                                                      func (rs *ReceiverSettings) Type() Type

                                                                                                                        Type sets the receiver type.

                                                                                                                        func (*ReceiverSettings) Validate

                                                                                                                        func (rs *ReceiverSettings) Validate() error

                                                                                                                          Validate validates the configuration and returns an error if invalid.

                                                                                                                          type Receivers

                                                                                                                          type Receivers map[string]Receiver

                                                                                                                            Receivers is a map of names to Receivers.

                                                                                                                            type Service

                                                                                                                            type Service struct {
                                                                                                                            	// Extensions is the ordered list of extensions configured for the service.
                                                                                                                            	Extensions []string
                                                                                                                            
                                                                                                                            	// Pipelines is the set of data pipelines configured for the service.
                                                                                                                            	Pipelines Pipelines
                                                                                                                            }

                                                                                                                              Service defines the configurable components of the service.

                                                                                                                              type Type

                                                                                                                              type Type string

                                                                                                                                Type is the component type as it is used in the config.

                                                                                                                                Directories

                                                                                                                                Path Synopsis
                                                                                                                                Package configcheck has checks to be applied to configuration objects implemented by factories of components used in the OpenTelemetry collector.
                                                                                                                                Package configcheck has checks to be applied to configuration objects implemented by factories of components used in the OpenTelemetry collector.
                                                                                                                                Package configgrpc defines the gRPC configuration settings.
                                                                                                                                Package configgrpc defines the gRPC configuration settings.
                                                                                                                                Package configloader implements configuration loading from a config.Parser.
                                                                                                                                Package configloader implements configuration loading from a config.Parser.
                                                                                                                                experimental
                                                                                                                                configsource
                                                                                                                                Package configsource is an experimental package that defines the interface of "configuration sources," e.g., Vault, ZooKeeper, etcd2, and others.
                                                                                                                                Package configsource is an experimental package that defines the interface of "configuration sources," e.g., Vault, ZooKeeper, etcd2, and others.
                                                                                                                                internal