config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package config implements loading of configuration from Viper configuration. The implementation relies on registered factories that allow creating default configuration for each type of receiver/exporter/processor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(
	v *viper.Viper,
	factories Factories,
	logger *zap.Logger,
) (*configmodels.Config, error)

Load loads a Config from Viper.

func LoadConfigFile

func LoadConfigFile(t *testing.T, fileName string, factories Factories) (*configmodels.Config, error)

LoadConfigFile loads a config from file.

Types

type ExampleExporter

type ExampleExporter struct {
	configmodels.ExporterSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
	ExtraInt                      int32                    `mapstructure:"extra_int"`
	ExtraSetting                  string                   `mapstructure:"extra"`
	ExtraMapSetting               map[string]string        `mapstructure:"extra_map"`
	ExtraListSetting              []string                 `mapstructure:"extra_list"`
	ExporterShutdown              bool
}

ExampleExporter is for testing purposes. We are defining an example config and factory for "exampleexporter" exporter type.

type ExampleExporterConsumer

type ExampleExporterConsumer struct {
	Traces           []consumerdata.TraceData
	Metrics          []consumerdata.MetricsData
	ExporterShutdown bool
}

ExampleExporterConsumer stores consumed traces and metrics for testing purposes.

func (*ExampleExporterConsumer) ConsumeMetricsData

func (exp *ExampleExporterConsumer) ConsumeMetricsData(ctx context.Context, md consumerdata.MetricsData) error

ConsumeMetricsData receives consumerdata.MetricsData for processing by the MetricsConsumer.

func (*ExampleExporterConsumer) ConsumeTraceData

func (exp *ExampleExporterConsumer) ConsumeTraceData(ctx context.Context, td consumerdata.TraceData) error

ConsumeTraceData receives consumerdata.TraceData for processing by the TraceConsumer.

func (*ExampleExporterConsumer) Name

func (exp *ExampleExporterConsumer) Name() string

Name returns the name of the exporter.

func (*ExampleExporterConsumer) Shutdown

func (exp *ExampleExporterConsumer) Shutdown() error

Shutdown is invoked during shutdown.

type ExampleExporterFactory

type ExampleExporterFactory struct {
}

ExampleExporterFactory is factory for ExampleExporter.

func (*ExampleExporterFactory) CreateDefaultConfig

func (f *ExampleExporterFactory) CreateDefaultConfig() configmodels.Exporter

CreateDefaultConfig creates the default configuration for the Exporter.

func (*ExampleExporterFactory) CreateMetricsExporter

func (f *ExampleExporterFactory) CreateMetricsExporter(logger *zap.Logger, cfg configmodels.Exporter) (exporter.MetricsExporter, error)

CreateMetricsExporter creates a metrics exporter based on this config.

func (*ExampleExporterFactory) CreateTraceExporter

func (f *ExampleExporterFactory) CreateTraceExporter(logger *zap.Logger, cfg configmodels.Exporter) (exporter.TraceExporter, error)

CreateTraceExporter creates a trace exporter based on this config.

func (*ExampleExporterFactory) Type

func (f *ExampleExporterFactory) Type() string

Type gets the type of the Exporter config created by this factory.

type ExampleExtension

type ExampleExtension struct {
	configmodels.ExtensionSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
	ExtraSetting                   string                   `mapstructure:"extra"`
	ExtraMapSetting                map[string]string        `mapstructure:"extra_map"`
	ExtraListSetting               []string                 `mapstructure:"extra_list"`
}

ExampleExtension is for testing purposes. We are defining an example config and factory for "exampleextension" extension type.

type ExampleExtensionFactory

type ExampleExtensionFactory struct {
}

ExampleExtensionFactory is factory for ExampleExtension.

func (*ExampleExtensionFactory) CreateDefaultConfig

func (f *ExampleExtensionFactory) CreateDefaultConfig() configmodels.Extension

CreateDefaultConfig creates the default configuration for the Extension.

func (*ExampleExtensionFactory) CreateExtension

CreateExtension creates an Extension based on this config.

func (*ExampleExtensionFactory) Type

func (f *ExampleExtensionFactory) Type() string

Type gets the type of the Extension config created by this factory.

type ExampleProcessor

type ExampleProcessor struct {
	configmodels.ProcessorSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
	ExtraSetting                   string                   `mapstructure:"extra"`
	ExtraMapSetting                map[string]string        `mapstructure:"extra_map"`
	ExtraListSetting               []string                 `mapstructure:"extra_list"`
}

ExampleProcessor is for testing purposes. We are defining an example config and factory for "exampleprocessor" processor type.

type ExampleProcessorFactory

type ExampleProcessorFactory struct {
}

ExampleProcessorFactory is factory for ExampleProcessor.

func (*ExampleProcessorFactory) CreateDefaultConfig

func (f *ExampleProcessorFactory) CreateDefaultConfig() configmodels.Processor

CreateDefaultConfig creates the default configuration for the Processor.

func (*ExampleProcessorFactory) CreateMetricsProcessor

func (f *ExampleProcessorFactory) CreateMetricsProcessor(
	logger *zap.Logger,
	nextConsumer consumer.MetricsConsumer,
	cfg configmodels.Processor,
) (processor.MetricsProcessor, error)

CreateMetricsProcessor creates a metrics processor based on this config.

func (*ExampleProcessorFactory) CreateTraceProcessor

func (f *ExampleProcessorFactory) CreateTraceProcessor(
	logger *zap.Logger,
	nextConsumer consumer.TraceConsumer,
	cfg configmodels.Processor,
) (processor.TraceProcessor, error)

CreateTraceProcessor creates a trace processor based on this config.

func (*ExampleProcessorFactory) Type

func (f *ExampleProcessorFactory) Type() string

Type gets the type of the Processor config created by this factory.

type ExampleReceiver

type ExampleReceiver struct {
	configmodels.ReceiverSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
	ExtraSetting                  string                   `mapstructure:"extra"`
	ExtraMapSetting               map[string]string        `mapstructure:"extra_map"`
	ExtraListSetting              []string                 `mapstructure:"extra_list"`

	// FailTraceCreation causes CreateTraceReceiver to fail. Useful for testing.
	FailTraceCreation bool `mapstructure:"-"`

	// FailMetricsCreation causes CreateTraceReceiver to fail. Useful for testing.
	FailMetricsCreation bool `mapstructure:"-"`
}

ExampleReceiver is for testing purposes. We are defining an example config and factory for "examplereceiver" receiver type.

type ExampleReceiverFactory

type ExampleReceiverFactory struct {
}

ExampleReceiverFactory is factory for ExampleReceiver.

func (*ExampleReceiverFactory) CreateDefaultConfig

func (f *ExampleReceiverFactory) CreateDefaultConfig() configmodels.Receiver

CreateDefaultConfig creates the default configuration for the Receiver.

func (*ExampleReceiverFactory) CreateMetricsReceiver

func (f *ExampleReceiverFactory) CreateMetricsReceiver(
	logger *zap.Logger,
	cfg configmodels.Receiver,
	nextConsumer consumer.MetricsConsumer,
) (receiver.MetricsReceiver, error)

CreateMetricsReceiver creates a metrics receiver based on this config.

func (*ExampleReceiverFactory) CreateTraceReceiver

func (f *ExampleReceiverFactory) CreateTraceReceiver(
	ctx context.Context,
	logger *zap.Logger,
	cfg configmodels.Receiver,
	nextConsumer consumer.TraceConsumer,
) (receiver.TraceReceiver, error)

CreateTraceReceiver creates a trace receiver based on this config.

func (*ExampleReceiverFactory) CustomUnmarshaler

func (f *ExampleReceiverFactory) CustomUnmarshaler() receiver.CustomUnmarshaler

CustomUnmarshaler returns nil because we don't need custom unmarshaling for this factory.

func (*ExampleReceiverFactory) Type

func (f *ExampleReceiverFactory) Type() string

Type gets the type of the Receiver config created by this factory.

type ExampleReceiverProducer

type ExampleReceiverProducer struct {
	TraceConsumer   consumer.TraceConsumer
	TraceStarted    bool
	TraceStopped    bool
	MetricsConsumer consumer.MetricsConsumer
	MetricsStarted  bool
	MetricsStopped  bool
}

ExampleReceiverProducer allows producing traces and metrics for testing purposes.

func (*ExampleReceiverProducer) MetricsSource

func (erp *ExampleReceiverProducer) MetricsSource() string

MetricsSource returns the name of the metrics data source.

func (*ExampleReceiverProducer) StartMetricsReception

func (erp *ExampleReceiverProducer) StartMetricsReception(host receiver.Host) error

StartMetricsReception tells the receiver to start its processing.

func (*ExampleReceiverProducer) StartTraceReception

func (erp *ExampleReceiverProducer) StartTraceReception(host receiver.Host) error

StartTraceReception tells the receiver to start its processing.

func (*ExampleReceiverProducer) StopMetricsReception

func (erp *ExampleReceiverProducer) StopMetricsReception() error

StopMetricsReception tells the receiver that should stop reception,

func (*ExampleReceiverProducer) StopTraceReception

func (erp *ExampleReceiverProducer) StopTraceReception() error

StopTraceReception tells the receiver that should stop reception,

func (*ExampleReceiverProducer) TraceSource

func (erp *ExampleReceiverProducer) TraceSource() string

TraceSource returns the name of the trace data source.

type Factories

type Factories struct {
	// Receivers maps receiver type names in the config to the respective factory.
	Receivers map[string]receiver.Factory

	// Processors maps processor type names in the config to the respective factory.
	Processors map[string]processor.Factory

	// Exporters maps exporter type names in the config to the respective factory.
	Exporters map[string]exporter.Factory

	// Extensions maps extension type names in the config to the respective factory.
	Extensions map[string]extension.Factory
}

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

func ExampleComponents

func ExampleComponents() (
	factories Factories,
	err error,
)

ExampleComponents registers example factories. This is only used by tests.

type MultiProtoReceiver

type MultiProtoReceiver struct {
	TypeVal   string                              `mapstructure:"-"`
	NameVal   string                              `mapstructure:"-"`
	Protocols map[string]MultiProtoReceiverOneCfg `mapstructure:"protocols"`
}

MultiProtoReceiver is for testing purposes. We are defining an example multi protocol config and factory for "multireceiver" receiver type.

func (*MultiProtoReceiver) IsEnabled

func (rs *MultiProtoReceiver) IsEnabled() bool

IsEnabled returns true if the entity is enabled.

func (*MultiProtoReceiver) Name

func (rs *MultiProtoReceiver) Name() string

Name gets the exporter name.

func (*MultiProtoReceiver) SetName

func (rs *MultiProtoReceiver) SetName(name string)

SetName sets the receiver name.

func (*MultiProtoReceiver) SetType

func (rs *MultiProtoReceiver) SetType(typeStr string)

SetType sets the receiver type.

func (*MultiProtoReceiver) Type

func (rs *MultiProtoReceiver) Type() string

Type sets the receiver type.

type MultiProtoReceiverFactory

type MultiProtoReceiverFactory struct {
}

MultiProtoReceiverFactory is factory for MultiProtoReceiver.

func (*MultiProtoReceiverFactory) CreateDefaultConfig

func (f *MultiProtoReceiverFactory) CreateDefaultConfig() configmodels.Receiver

CreateDefaultConfig creates the default configuration for the Receiver.

func (*MultiProtoReceiverFactory) CreateMetricsReceiver

func (f *MultiProtoReceiverFactory) CreateMetricsReceiver(
	logger *zap.Logger,
	cfg configmodels.Receiver,
	consumer consumer.MetricsConsumer,
) (receiver.MetricsReceiver, error)

CreateMetricsReceiver creates a metrics receiver based on this config.

func (*MultiProtoReceiverFactory) CreateTraceReceiver

func (f *MultiProtoReceiverFactory) CreateTraceReceiver(
	ctx context.Context,
	logger *zap.Logger,
	cfg configmodels.Receiver,
	nextConsumer consumer.TraceConsumer,
) (receiver.TraceReceiver, error)

CreateTraceReceiver creates a trace receiver based on this config.

func (*MultiProtoReceiverFactory) CustomUnmarshaler

func (f *MultiProtoReceiverFactory) CustomUnmarshaler() receiver.CustomUnmarshaler

CustomUnmarshaler returns nil because we don't need custom unmarshaling for this factory.

func (*MultiProtoReceiverFactory) Type

Type gets the type of the Receiver config created by this factory.

type MultiProtoReceiverOneCfg

type MultiProtoReceiverOneCfg struct {
	Disabled     bool   `mapstructure:"disabled"`
	Endpoint     string `mapstructure:"endpoint"`
	ExtraSetting string `mapstructure:"extra"`
}

MultiProtoReceiverOneCfg is multi proto receiver config.

Directories

Path Synopsis
Package configerror contains the common errors caused by malformed configs.
Package configerror contains the common errors caused by malformed configs.
Package configgrpc defines the gRPC configuration settings.
Package configgrpc defines the gRPC configuration settings.
Package configmodels defines the data models for entities.
Package configmodels defines the data models for entities.

Jump to

Keyboard shortcuts

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