internal

package
v0.114.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ExporterKey used to identify exporters in metrics and traces.
	ExporterKey = "exporter"

	// DataTypeKey used to identify the data type in the queue size metric.
	DataTypeKey = "data_type"

	// SentSpansKey used to track spans sent by exporters.
	SentSpansKey = "sent_spans"
	// FailedToSendSpansKey used to track spans that failed to be sent by exporters.
	FailedToSendSpansKey = "send_failed_spans"

	// SentMetricPointsKey used to track metric points sent by exporters.
	SentMetricPointsKey = "sent_metric_points"
	// FailedToSendMetricPointsKey used to track metric points that failed to be sent by exporters.
	FailedToSendMetricPointsKey = "send_failed_metric_points"

	// SentLogRecordsKey used to track logs sent by exporters.
	SentLogRecordsKey = "sent_log_records"
	// FailedToSendLogRecordsKey used to track logs that failed to be sent by exporters.
	FailedToSendLogRecordsKey = "send_failed_log_records"

	// SentSamplesKey used to track profiles samples sent by exporters.
	SentSamplesKey = "sent_samples"
	// FailedToSendSamplesKey used to track samples that failed to be sent by exporters.
	FailedToSendSamplesKey = "send_failed_samples"

	ExporterPrefix                 = ExporterKey + spanNameSep
	ExportTraceDataOperationSuffix = spanNameSep + "traces"
	ExportMetricsOperationSuffix   = spanNameSep + "metrics"
	ExportLogsOperationSuffix      = spanNameSep + "logs"
)

Variables

This section is empty.

Functions

func CheckStatus added in v0.110.0

func CheckStatus(t *testing.T, sd sdktrace.ReadOnlySpan, err error)

func NewThrottleRetry added in v0.110.0

func NewThrottleRetry(err error, delay time.Duration) error

NewThrottleRetry creates a new throttle retry error.

func RequestFromLogsFunc added in v0.114.0

func RequestFromLogsFunc(reqErr error) func(context.Context, plog.Logs) (internal.Request, error)

func RequestFromMetricsFunc added in v0.114.0

func RequestFromMetricsFunc(reqErr error) func(context.Context, pmetric.Metrics) (internal.Request, error)

func RequestFromProfilesFunc added in v0.114.0

func RequestFromProfilesFunc(reqErr error) func(context.Context, pprofile.Profiles) (internal.Request, error)

func RequestFromTracesFunc added in v0.114.0

func RequestFromTracesFunc(reqErr error) func(context.Context, ptrace.Traces) (internal.Request, error)

Types

type BaseExporter added in v0.110.0

type BaseExporter struct {
	component.StartFunc
	component.ShutdownFunc

	Signal pipeline.Signal

	Marshaler   exporterqueue.Marshaler[internal.Request]
	Unmarshaler exporterqueue.Unmarshaler[internal.Request]

	Set    exporter.Settings
	Obsrep *ObsReport

	// Message for the user to be added with an export failure message.
	ExportFailureMessage string

	// Chain of senders that the exporter helper applies before passing the data to the actual exporter.
	// The data is handled by each sender in the respective order starting from the queueSender.
	// Most of the senders are optional, and initialized with a no-op path-through sender.
	BatchSender   RequestSender
	QueueSender   RequestSender
	ObsrepSender  RequestSender
	RetrySender   RequestSender
	TimeoutSender *TimeoutSender // TimeoutSender is always initialized.

	ConsumerOptions []consumer.Option

	BatcherCfg exporterbatcher.Config
	// contains filtered or unexported fields
}

func NewBaseExporter added in v0.110.0

func NewBaseExporter(set exporter.Settings, signal pipeline.Signal, osf ObsrepSenderFactory, options ...Option) (*BaseExporter, error)

func (*BaseExporter) Send added in v0.110.0

func (be *BaseExporter) Send(ctx context.Context, req internal.Request) error

send sends the request using the first sender in the chain.

func (*BaseExporter) Shutdown added in v0.110.0

func (be *BaseExporter) Shutdown(ctx context.Context) error

func (*BaseExporter) Start added in v0.110.0

func (be *BaseExporter) Start(ctx context.Context, host component.Host) error

type BaseRequestSender added in v0.110.0

type BaseRequestSender struct {
	component.StartFunc
	component.ShutdownFunc
	NextSender RequestSender
}

func (*BaseRequestSender) Send added in v0.110.0

func (*BaseRequestSender) SetNextSender added in v0.110.0

func (b *BaseRequestSender) SetNextSender(nextSender RequestSender)

type BatchSender added in v0.110.0

type BatchSender struct {
	BaseRequestSender
	// contains filtered or unexported fields
}

BatchSender is a component that places requests into batches before passing them to the downstream senders. Batches are sent out with any of the following conditions: - batch size reaches cfg.MinSizeItems - cfg.FlushTimeout is elapsed since the timestamp when the previous batch was sent out. - concurrencyLimit is reached.

func NewBatchSender added in v0.110.0

func NewBatchSender(cfg exporterbatcher.Config, set exporter.Settings) *BatchSender

newBatchSender returns a new batch consumer component.

func (*BatchSender) Send added in v0.110.0

func (bs *BatchSender) Send(ctx context.Context, req internal.Request) error

func (*BatchSender) Shutdown added in v0.110.0

func (bs *BatchSender) Shutdown(context.Context) error

func (*BatchSender) Start added in v0.110.0

func (bs *BatchSender) Start(_ context.Context, _ component.Host) error

type MockHost added in v0.110.0

type MockHost struct {
	component.Host
	Ext map[component.ID]component.Component
}

func (*MockHost) GetExtensions added in v0.110.0

func (nh *MockHost) GetExtensions() map[component.ID]component.Component

type ObsReport added in v0.110.0

type ObsReport struct {
	Signal pipeline.Signal

	TelemetryBuilder *metadata.TelemetryBuilder
	// contains filtered or unexported fields
}

ObsReport is a helper to add observability to an exporter.

func NewExporter added in v0.110.0

func NewExporter(cfg ObsReportSettings) (*ObsReport, error)

func (*ObsReport) EndLogsOp added in v0.110.0

func (or *ObsReport) EndLogsOp(ctx context.Context, numLogRecords int, err error)

EndLogsOp completes the export operation that was started with startLogsOp.

func (*ObsReport) EndMetricsOp added in v0.110.0

func (or *ObsReport) EndMetricsOp(ctx context.Context, numMetricPoints int, err error)

EndMetricsOp completes the export operation that was started with startMetricsOp.

If needed, report your use case in https://github.com/open-telemetry/opentelemetry-collector/issues/10592.

func (*ObsReport) EndProfilesOp added in v0.112.0

func (or *ObsReport) EndProfilesOp(ctx context.Context, numSpans int, err error)

EndProfilesOp completes the export operation that was started with startProfilesOp.

func (*ObsReport) EndTracesOp added in v0.110.0

func (or *ObsReport) EndTracesOp(ctx context.Context, numSpans int, err error)

EndTracesOp completes the export operation that was started with startTracesOp.

func (*ObsReport) RecordEnqueueFailure added in v0.110.0

func (or *ObsReport) RecordEnqueueFailure(ctx context.Context, signal pipeline.Signal, failed int64)

func (*ObsReport) StartLogsOp added in v0.110.0

func (or *ObsReport) StartLogsOp(ctx context.Context) context.Context

StartLogsOp is called at the start of an Export operation. The returned context should be used in other calls to the Exporter functions dealing with the same export operation.

func (*ObsReport) StartMetricsOp added in v0.110.0

func (or *ObsReport) StartMetricsOp(ctx context.Context) context.Context

StartMetricsOp is called at the start of an Export operation. The returned context should be used in other calls to the Exporter functions dealing with the same export operation.

func (*ObsReport) StartProfilesOp added in v0.112.0

func (or *ObsReport) StartProfilesOp(ctx context.Context) context.Context

StartProfilesOp is called at the start of an Export operation. The returned context should be used in other calls to the Exporter functions dealing with the same export operation.

func (*ObsReport) StartTracesOp added in v0.110.0

func (or *ObsReport) StartTracesOp(ctx context.Context) context.Context

StartTracesOp is called at the start of an Export operation. The returned context should be used in other calls to the Exporter functions dealing with the same export operation.

type ObsReportSettings added in v0.110.0

type ObsReportSettings struct {
	ExporterID             component.ID
	ExporterCreateSettings exporter.Settings
	Signal                 pipeline.Signal
}

ObsReportSettings are settings for creating an ObsReport.

type ObsrepSenderFactory added in v0.110.0

type ObsrepSenderFactory = func(obsrep *ObsReport) RequestSender

type Option added in v0.110.0

type Option func(*BaseExporter) error

Option apply changes to BaseExporter.

func WithBatcher added in v0.110.0

func WithBatcher(cfg exporterbatcher.Config) Option

WithBatcher enables batching for an exporter based on custom request types. For now, it can be used only with the New[Traces|Metrics|Logs]RequestExporter exporter helpers and WithRequestBatchFuncs provided. This API is at the early stage of development and may change without backward compatibility until https://github.com/open-telemetry/opentelemetry-collector/issues/8122 is resolved.

func WithCapabilities added in v0.110.0

func WithCapabilities(capabilities consumer.Capabilities) Option

WithCapabilities overrides the default Capabilities() function for a Consumer. The default is non-mutable data. TODO: Verify if we can change the default to be mutable as we do for processors.

func WithMarshaler added in v0.110.0

func WithMarshaler(marshaler exporterqueue.Marshaler[internal.Request]) Option

WithMarshaler is used to set the request marshaler for the new exporter helper. It must be provided as the first option when creating a new exporter helper.

func WithQueue added in v0.110.0

func WithQueue(config QueueConfig) Option

WithQueue overrides the default QueueConfig for an exporter. The default QueueConfig is to disable queueing. This option cannot be used with the new exporter helpers New[Traces|Metrics|Logs]RequestExporter.

func WithRequestQueue added in v0.110.0

func WithRequestQueue(cfg exporterqueue.Config, queueFactory exporterqueue.Factory[internal.Request]) Option

WithRequestQueue enables queueing for an exporter. This option should be used with the new exporter helpers New[Traces|Metrics|Logs]RequestExporter. Experimental: This API is at the early stage of development and may change without backward compatibility until https://github.com/open-telemetry/opentelemetry-collector/issues/8122 is resolved.

func WithRetry added in v0.110.0

func WithRetry(config configretry.BackOffConfig) Option

WithRetry overrides the default configretry.BackOffConfig for an exporter. The default configretry.BackOffConfig is to disable retries.

func WithShutdown added in v0.110.0

func WithShutdown(shutdown component.ShutdownFunc) Option

WithShutdown overrides the default Shutdown function for an exporter. The default shutdown function does nothing and always returns nil.

func WithStart added in v0.110.0

func WithStart(start component.StartFunc) Option

WithStart overrides the default Start function for an exporter. The default start function does nothing and always returns nil.

func WithTimeout added in v0.110.0

func WithTimeout(timeoutConfig TimeoutConfig) Option

WithTimeout overrides the default TimeoutConfig for an exporter. The default TimeoutConfig is 5 seconds.

func WithUnmarshaler added in v0.110.0

func WithUnmarshaler(unmarshaler exporterqueue.Unmarshaler[internal.Request]) Option

withUnmarshaler is used to set the request unmarshaler for the new exporter helper. It must be provided as the first option when creating a new exporter helper.

type QueueConfig added in v0.110.0

type QueueConfig struct {
	// Enabled indicates whether to not enqueue batches before sending to the consumerSender.
	Enabled bool `mapstructure:"enabled"`
	// NumConsumers is the number of consumers from the queue. Defaults to 10.
	// If batching is enabled, a combined batch cannot contain more requests than the number of consumers.
	// So it's recommended to set higher number of consumers if batching is enabled.
	NumConsumers int `mapstructure:"num_consumers"`
	// QueueSize is the maximum number of batches allowed in queue at a given time.
	QueueSize int `mapstructure:"queue_size"`
	// StorageID if not empty, enables the persistent storage and uses the component specified
	// as a storage extension for the persistent queue
	StorageID *component.ID `mapstructure:"storage"`
}

QueueConfig defines configuration for queueing batches before sending to the consumerSender.

func NewDefaultQueueConfig added in v0.110.0

func NewDefaultQueueConfig() QueueConfig

NewDefaultQueueConfig returns the default config for QueueConfig.

func (*QueueConfig) Validate added in v0.110.0

func (qCfg *QueueConfig) Validate() error

Validate checks if the QueueConfig configuration is valid

type QueueSender added in v0.110.0

type QueueSender struct {
	BaseRequestSender
	// contains filtered or unexported fields
}

func NewQueueSender added in v0.110.0

func NewQueueSender(q exporterqueue.Queue[internal.Request], set exporter.Settings, numConsumers int,
	exportFailureMessage string, obsrep *ObsReport) *QueueSender

func (*QueueSender) Send added in v0.110.0

func (qs *QueueSender) Send(ctx context.Context, req internal.Request) error

send implements the requestSender interface. It puts the request in the queue.

func (*QueueSender) Shutdown added in v0.110.0

func (qs *QueueSender) Shutdown(ctx context.Context) error

Shutdown is invoked during service shutdown.

func (*QueueSender) Start added in v0.110.0

func (qs *QueueSender) Start(ctx context.Context, host component.Host) error

Start is invoked during service startup.

type RequestSender added in v0.110.0

type RequestSender interface {
	component.Component
	Send(context.Context, internal.Request) error
	SetNextSender(nextSender RequestSender)
}

type TimeoutConfig added in v0.110.0

type TimeoutConfig struct {
	// Timeout is the timeout for every attempt to send data to the backend.
	// A zero timeout means no timeout.
	Timeout time.Duration `mapstructure:"timeout"`
}

TimeoutConfig for timeout. The timeout applies to individual attempts to send data to the backend.

func NewDefaultTimeoutConfig added in v0.110.0

func NewDefaultTimeoutConfig() TimeoutConfig

NewDefaultTimeoutConfig returns the default config for TimeoutConfig.

func (*TimeoutConfig) Validate added in v0.110.0

func (ts *TimeoutConfig) Validate() error

type TimeoutSender added in v0.110.0

type TimeoutSender struct {
	BaseRequestSender
	// contains filtered or unexported fields
}

TimeoutSender is a requestSender that adds a `timeout` to every request that passes this sender.

func (*TimeoutSender) Send added in v0.110.0

func (ts *TimeoutSender) Send(ctx context.Context, req internal.Request) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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