component

package
Version: v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package receivertest define types and functions used to help test packages implementing the receiver package interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeExporterFactoryMap added in v0.2.8

func MakeExporterFactoryMap(factories ...ExporterFactoryBase) (map[string]ExporterFactoryBase, 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 added in v0.2.8

func MakeExtensionFactoryMap(factories ...ExtensionFactory) (map[string]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 added in v0.2.8

func MakeProcessorFactoryMap(factories ...ProcessorFactoryBase) (map[string]ProcessorFactoryBase, 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 added in v0.2.8

func MakeReceiverFactoryMap(factories ...ReceiverFactoryBase) (map[string]ReceiverFactoryBase, 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 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.
	Start(host Host) error

	// Shutdown is invoked during service shutdown.
	Shutdown() error
}

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

type CustomUnmarshaler added in v0.2.8

type CustomUnmarshaler func(v *viper.Viper, viperKey string, sourceViperSection *viper.Viper, intoCfg interface{}) error

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

A viper instance at the "receivers" node in the config yaml.  v.Sub(viperKey) is
the raw config this function should load.

viperKey string

The name of this config.  i.e. "jaeger/custom".  v.Sub(viperKey) is the raw config
this function should load.

sourceViperSection *viper.Viper

The value of v.Sub(viperKey) with all environment substitution complete.

intoCfg interface{}

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

type Exporter added in v0.2.8

type Exporter interface {
	Component
}

Exporter defines functions that trace and metric exporters must implement.

type ExporterCreateParams added in v0.2.8

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
}

ExporterCreateParams is passed to ExporterFactory.Create* functions.

type ExporterFactory added in v0.2.8

type ExporterFactory interface {
	ExporterFactoryBase

	// CreateTraceExporter 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.
	CreateTraceExporter(ctx context.Context, params ExporterCreateParams,
		cfg configmodels.Exporter) (TraceExporter, 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)
}

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

type ExporterFactoryBase added in v0.2.8

type ExporterFactoryBase 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
}

ExporterFactoryBase defines the common functions for all exporter factories.

type ExporterFactoryOld added in v0.2.8

type ExporterFactoryOld interface {
	ExporterFactoryBase

	// CreateTraceExporter creates a trace exporter based on this config.
	CreateTraceExporter(logger *zap.Logger, cfg configmodels.Exporter) (TraceExporterOld, error)

	// CreateMetricsExporter creates a metrics exporter based on this config.
	CreateMetricsExporter(logger *zap.Logger, cfg configmodels.Exporter) (MetricsExporterOld, error)
}

ExporterFactoryOld can create TraceExporterOld and MetricsExporterOld.

type ExtensionFactory added in v0.2.8

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(logger *zap.Logger, cfg configmodels.Extension) (ServiceExtension, error)
}

ExtensionFactory is a factory interface for extensions to the service.

type Factory added in v0.2.8

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

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)

	// Context returns a context provided by the host to be used on the component
	// operations.
	Context() context.Context
}

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).

func NewMockHost

func NewMockHost() Host

NewMockHost returns a new instance of MockHost with proper defaults for most tests.

type MetricsExporter added in v0.2.8

type MetricsExporter interface {
	consumer.MetricsConsumer
	MetricsExporterBase
}

MetricsExporter is a MetricsConsumer that is also an Exporter.

type MetricsExporterBase added in v0.2.9

type MetricsExporterBase interface {
	Exporter
}

MetricsExporterBase defines a common interface for MetricsExporter and MetricsExporterOld

type MetricsExporterOld added in v0.2.8

type MetricsExporterOld interface {
	consumer.MetricsConsumerOld
	MetricsExporterBase
}

MetricsExporterOld is a MetricsConsumer that is also an Exporter.

type MetricsProcessor added in v0.2.8

type MetricsProcessor interface {
	consumer.MetricsConsumer
	MetricsProcessorBase
}

MetricsProcessor composes MetricsConsumer with some additional processor-specific functions.

type MetricsProcessorBase added in v0.2.9

type MetricsProcessorBase interface {
	Processor
}

MetricsProcessorBase is a common interface for MetricsProcessor and MetricsProcessorV2

type MetricsProcessorOld added in v0.2.8

type MetricsProcessorOld interface {
	consumer.MetricsConsumerOld
	MetricsProcessorBase
}

MetricsProcessor composes MetricsConsumer with some additional processor-specific functions.

type MetricsReceiver added in v0.2.8

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 MockHost

type MockHost struct {
}

MockHost mocks a receiver.ReceiverHost for test purposes.

func (*MockHost) Context

func (mh *MockHost) Context() context.Context

Context returns a context provided by the host to be used on the receiver operations.

func (*MockHost) ReportFatalError

func (mh *MockHost) ReportFatalError(err error)

ReportFatalError is used to report to the host that the receiver encountered a fatal error (i.e.: an error that the instance can't recover from) after its start function has already returned.

type PipelineWatcher added in v0.2.8

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 Service 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 added in v0.2.8

type Processor interface {
	Component

	// GetCapabilities must return the capabilities of the processor.
	GetCapabilities() ProcessorCapabilities
}

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

type ProcessorCapabilities added in v0.2.8

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 added in v0.2.8

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
}

ProcessorCreateParams is passed to Create* functions in ProcessorFactory.

type ProcessorFactory added in v0.2.8

type ProcessorFactory interface {
	ProcessorFactoryBase

	// 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.
	CreateTraceProcessor(ctx context.Context, params ProcessorCreateParams,
		nextConsumer consumer.TraceConsumer, cfg configmodels.Processor) (TraceProcessor, 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,
		nextConsumer consumer.MetricsConsumer, cfg configmodels.Processor) (MetricsProcessor, error)
}

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

type ProcessorFactoryBase added in v0.2.8

type ProcessorFactoryBase 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
}

ProcessorFactoryBase defines the common functions for all processor factories.

type ProcessorFactoryOld added in v0.2.8

type ProcessorFactoryOld interface {
	ProcessorFactoryBase

	// 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.
	CreateTraceProcessor(logger *zap.Logger, nextConsumer consumer.TraceConsumerOld,
		cfg configmodels.Processor) (TraceProcessorOld, 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(logger *zap.Logger, nextConsumer consumer.MetricsConsumerOld,
		cfg configmodels.Processor) (MetricsProcessorOld, error)
}

ProcessorFactoryOld is factory interface for processors.

type Receiver added in v0.2.8

type Receiver interface {
	Component
}

Receiver defines functions that trace and metric receivers must implement.

type ReceiverCreateParams added in v0.2.8

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
}

ReceiverCreateParams is passed to ReceiverFactory.Create* functions.

type ReceiverFactory added in v0.2.8

type ReceiverFactory interface {
	ReceiverFactoryBase

	// 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.
	CreateTraceReceiver(ctx context.Context, params ReceiverCreateParams,
		cfg configmodels.Receiver, nextConsumer consumer.TraceConsumer) (TraceReceiver, 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)
}

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

type ReceiverFactoryBase added in v0.2.8

type ReceiverFactoryBase 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

	// CustomUnmarshaler returns a custom unmarshaler for the configuration or nil if
	// there is no need for custom unmarshaling. This is typically used if viper.UnmarshalExact()
	// is not sufficient to unmarshal correctly.
	CustomUnmarshaler() CustomUnmarshaler
}

ReceiverFactoryBase defines the common functions for all receiver factories.

type ReceiverFactoryOld added in v0.2.8

type ReceiverFactoryOld interface {
	ReceiverFactoryBase

	// 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.
	CreateTraceReceiver(ctx context.Context, logger *zap.Logger, cfg configmodels.Receiver,
		nextConsumer consumer.TraceConsumerOld) (TraceReceiver, 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(logger *zap.Logger, cfg configmodels.Receiver,
		consumer consumer.MetricsConsumerOld) (MetricsReceiver, error)
}

ReceiverFactoryOld can create TraceReceiver and MetricsReceiver.

type ServiceExtension added in v0.2.8

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 TraceExporter added in v0.2.8

type TraceExporter interface {
	consumer.TraceConsumer
	TraceExporterBase
}

TraceExporter is an TraceConsumer that is also an Exporter.

type TraceExporterBase added in v0.2.9

type TraceExporterBase interface {
	Exporter
}

TraceExporterBase defines a common interface for TraceExporter and TraceExporterOld

type TraceExporterOld added in v0.2.8

type TraceExporterOld interface {
	consumer.TraceConsumerOld
	TraceExporterBase
}

TraceExporterOld is a TraceConsumer that is also an Exporter.

type TraceProcessor added in v0.2.8

type TraceProcessor interface {
	consumer.TraceConsumer
	TraceProcessorBase
}

TraceProcessor composes TraceConsumer with some additional processor-specific functions.

type TraceProcessorBase added in v0.2.9

type TraceProcessorBase interface {
	Processor
}

TraceProcessorBase is a common interface for TraceProcessor and TraceProcessorOld

type TraceProcessorOld added in v0.2.8

type TraceProcessorOld interface {
	consumer.TraceConsumerOld
	TraceProcessorBase
}

TraceProcessorOld composes TraceConsumer with some additional processor-specific functions.

type TraceReceiver added in v0.2.8

type TraceReceiver interface {
	Receiver
}

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

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

Jump to

Keyboard shortcuts

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