Documentation ¶
Overview ¶
Package exporterhelper provides helper functions for exporters.
Index ¶
- func NewLogsExporter(_ context.Context, set exporter.CreateSettings, cfg component.Config, ...) (exporter.Logs, error)
- func NewLogsRequestExporter(_ context.Context, set exporter.CreateSettings, converter RequestFromLogsFunc, ...) (exporter.Logs, error)
- func NewMetricsExporter(_ context.Context, set exporter.CreateSettings, cfg component.Config, ...) (exporter.Metrics, error)
- func NewMetricsRequestExporter(_ context.Context, set exporter.CreateSettings, ...) (exporter.Metrics, error)
- func NewThrottleRetry(err error, delay time.Duration) error
- func NewTracesExporter(_ context.Context, set exporter.CreateSettings, cfg component.Config, ...) (exporter.Traces, error)
- func NewTracesRequestExporter(_ context.Context, set exporter.CreateSettings, ...) (exporter.Traces, error)
- type ObsReport
- func (or *ObsReport) EndLogsOp(ctx context.Context, numLogRecords int, err error)
- func (or *ObsReport) EndMetricsOp(ctx context.Context, numMetricPoints int, err error)
- func (or *ObsReport) EndTracesOp(ctx context.Context, numSpans int, err error)
- func (or *ObsReport) StartLogsOp(ctx context.Context) context.Context
- func (or *ObsReport) StartMetricsOp(ctx context.Context) context.Context
- func (or *ObsReport) StartTracesOp(ctx context.Context) context.Context
- type ObsReportSettings
- type Option
- func WithCapabilities(capabilities consumer.Capabilities) Option
- func WithQueue(config QueueSettings) Option
- func WithRequestQueue(cfg exporterqueue.Config, queueFactory exporterqueue.Factory[Request]) Option
- func WithRetry(config configretry.BackOffConfig) Option
- func WithShutdown(shutdown component.ShutdownFunc) Option
- func WithStart(start component.StartFunc) Option
- func WithTimeout(timeoutSettings TimeoutSettings) Option
- type QueueSettings
- type Request
- type RequestErrorHandler
- type RequestFromLogsFunc
- type RequestFromMetricsFunc
- type RequestFromTracesFunc
- type RequestMarshaler
- type RequestUnmarshaler
- type TimeoutSettings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLogsExporter ¶
func NewLogsExporter( _ context.Context, set exporter.CreateSettings, cfg component.Config, pusher consumer.ConsumeLogsFunc, options ...Option, ) (exporter.Logs, error)
NewLogsExporter creates an exporter.Logs that records observability metrics and wraps every request with a Span.
func NewLogsRequestExporter ¶ added in v0.84.0
func NewLogsRequestExporter( _ context.Context, set exporter.CreateSettings, converter RequestFromLogsFunc, options ...Option, ) (exporter.Logs, error)
NewLogsRequestExporter creates new logs exporter based on custom LogsConverter and RequestSender. 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 NewMetricsExporter ¶
func NewMetricsExporter( _ context.Context, set exporter.CreateSettings, cfg component.Config, pusher consumer.ConsumeMetricsFunc, options ...Option, ) (exporter.Metrics, error)
NewMetricsExporter creates an exporter.Metrics that records observability metrics and wraps every request with a Span.
func NewMetricsRequestExporter ¶ added in v0.84.0
func NewMetricsRequestExporter( _ context.Context, set exporter.CreateSettings, converter RequestFromMetricsFunc, options ...Option, ) (exporter.Metrics, error)
NewMetricsRequestExporter creates a new metrics exporter based on a custom MetricsConverter and RequestSender. 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 NewThrottleRetry ¶
NewThrottleRetry creates a new throttle retry error.
func NewTracesExporter ¶
func NewTracesExporter( _ context.Context, set exporter.CreateSettings, cfg component.Config, pusher consumer.ConsumeTracesFunc, options ...Option, ) (exporter.Traces, error)
NewTracesExporter creates an exporter.Traces that records observability metrics and wraps every request with a Span.
func NewTracesRequestExporter ¶ added in v0.84.0
func NewTracesRequestExporter( _ context.Context, set exporter.CreateSettings, converter RequestFromTracesFunc, options ...Option, ) (exporter.Traces, error)
NewTracesRequestExporter creates a new traces exporter based on a custom TracesConverter and RequestSender. 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.
Types ¶
type ObsReport ¶ added in v0.86.0
type ObsReport struct {
// contains filtered or unexported fields
}
ObsReport is a helper to add observability to an exporter.
func NewObsReport ¶ added in v0.86.0
func NewObsReport(cfg ObsReportSettings) (*ObsReport, error)
NewObsReport creates a new Exporter.
func (*ObsReport) EndLogsOp ¶ added in v0.86.0
EndLogsOp completes the export operation that was started with StartLogsOp.
func (*ObsReport) EndMetricsOp ¶ added in v0.86.0
EndMetricsOp completes the export operation that was started with StartMetricsOp.
func (*ObsReport) EndTracesOp ¶ added in v0.86.0
EndTracesOp completes the export operation that was started with StartTracesOp.
func (*ObsReport) StartLogsOp ¶ added in v0.86.0
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.86.0
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) StartTracesOp ¶ added in v0.86.0
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.86.0
type ObsReportSettings struct { ExporterID component.ID ExporterCreateSettings exporter.CreateSettings }
ObsReportSettings are settings for creating an ObsReport.
type Option ¶
type Option func(*baseExporter)
Option apply changes to baseExporter.
func WithCapabilities ¶
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 WithQueue ¶
func WithQueue(config QueueSettings) Option
WithQueue overrides the default QueueSettings for an exporter. The default QueueSettings is to disable queueing. This option cannot be used with the new exporter helpers New[Traces|Metrics|Logs]RequestExporter.
func WithRequestQueue ¶ added in v0.94.0
func WithRequestQueue(cfg exporterqueue.Config, queueFactory exporterqueue.Factory[Request]) Option
WithRequestQueue enables queueing for an exporter. This option should be used with the new exporter helpers New[Traces|Metrics|Logs]RequestExporter. 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 ¶
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 ¶
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 ¶
WithStart overrides the default Start function for an exporter. The default start function does nothing and always returns nil.
func WithTimeout ¶
func WithTimeout(timeoutSettings TimeoutSettings) Option
WithTimeout overrides the default TimeoutSettings for an exporter. The default TimeoutSettings is 5 seconds.
type QueueSettings ¶
type QueueSettings 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. 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"` }
QueueSettings defines configuration for queueing batches before sending to the consumerSender.
func NewDefaultQueueSettings ¶
func NewDefaultQueueSettings() QueueSettings
NewDefaultQueueSettings returns the default settings for QueueSettings.
func (*QueueSettings) Validate ¶
func (qCfg *QueueSettings) Validate() error
Validate checks if the QueueSettings configuration is valid
type Request ¶ added in v0.84.0
type Request interface { // Export exports the request to an external endpoint. Export(ctx context.Context) error // ItemsCount returns a number of basic items in the request where item is the smallest piece of data that can be // sent. For example, for OTLP exporter, this value represents the number of spans, // metric data points or log records. ItemsCount() int }
Request represents a single request that can be sent to an external endpoint. 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.
type RequestErrorHandler ¶ added in v0.89.0
type RequestErrorHandler interface { Request // OnError returns a new Request may contain the items left to be sent if some items failed to process and can be retried. // Otherwise, it should return the original Request. OnError(error) Request }
RequestErrorHandler is an optional interface that can be implemented by Request to provide a way handle partial temporary failures. For example, if some items failed to process and can be retried, this interface allows to return a new Request that contains the items left to be sent. Otherwise, the original Request should be returned. If not implemented, the original Request will be returned assuming the error is applied to the whole Request. 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.
type RequestFromLogsFunc ¶ added in v0.90.0
RequestFromLogsFunc converts plog.Logs data into a user-defined request. 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.
type RequestFromMetricsFunc ¶ added in v0.90.0
RequestFromMetricsFunc converts pdata.Metrics into a user-defined request. 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.
type RequestFromTracesFunc ¶ added in v0.90.0
RequestFromTracesFunc converts ptrace.Traces into a user-defined Request. 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.
type RequestMarshaler ¶ added in v0.89.0
RequestMarshaler is a function that can marshal a Request into bytes. Deprecated: [v0.94.0] Use exporterqueue.Marshaler[Request] instead.
type RequestUnmarshaler ¶ added in v0.89.0
RequestUnmarshaler is a function that can unmarshal bytes into a Request. Deprecated: [v0.94.0] Use exporterqueue.Unmarshaler[Request] instead.
type TimeoutSettings ¶
type TimeoutSettings 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"` }
TimeoutSettings for timeout. The timeout applies to individual attempts to send data to the backend.
func NewDefaultTimeoutSettings ¶
func NewDefaultTimeoutSettings() TimeoutSettings
NewDefaultTimeoutSettings returns the default settings for TimeoutSettings.
func (*TimeoutSettings) Validate ¶ added in v0.92.0
func (ts *TimeoutSettings) Validate() error