80 lines
3.5 KiB
Go
80 lines
3.5 KiB
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package exporterhelper // import "go.opentelemetry.io/collector/exporter/exporterhelper"
|
|
|
|
import (
|
|
"go.opentelemetry.io/collector/component"
|
|
"go.opentelemetry.io/collector/config/configretry"
|
|
"go.opentelemetry.io/collector/consumer"
|
|
"go.opentelemetry.io/collector/exporter/exporterbatcher"
|
|
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
|
|
"go.opentelemetry.io/collector/exporter/exporterqueue"
|
|
)
|
|
|
|
// Option apply changes to BaseExporter.
|
|
type Option = internal.Option
|
|
|
|
// WithStart overrides the default Start function for an exporter.
|
|
// The default start function does nothing and always returns nil.
|
|
func WithStart(start component.StartFunc) Option {
|
|
return internal.WithStart(start)
|
|
}
|
|
|
|
// WithShutdown overrides the default Shutdown function for an exporter.
|
|
// The default shutdown function does nothing and always returns nil.
|
|
func WithShutdown(shutdown component.ShutdownFunc) Option {
|
|
return internal.WithShutdown(shutdown)
|
|
}
|
|
|
|
// WithTimeout overrides the default TimeoutConfig for an exporter.
|
|
// The default TimeoutConfig is 5 seconds.
|
|
func WithTimeout(timeoutConfig TimeoutConfig) Option {
|
|
return internal.WithTimeout(timeoutConfig)
|
|
}
|
|
|
|
// WithRetry overrides the default configretry.BackOffConfig for an exporter.
|
|
// The default configretry.BackOffConfig is to disable retries.
|
|
func WithRetry(config configretry.BackOffConfig) Option {
|
|
return internal.WithRetry(config)
|
|
}
|
|
|
|
// 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 WithQueue(config internal.QueueConfig) Option {
|
|
return internal.WithQueue(config)
|
|
}
|
|
|
|
// 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 WithRequestQueue(cfg exporterqueue.Config, queueFactory exporterqueue.Factory[Request]) Option {
|
|
return internal.WithRequestQueue(cfg, queueFactory)
|
|
}
|
|
|
|
// 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 WithCapabilities(capabilities consumer.Capabilities) Option {
|
|
return internal.WithCapabilities(capabilities)
|
|
}
|
|
|
|
// BatcherOption apply changes to batcher sender.
|
|
type BatcherOption = internal.BatcherOption
|
|
|
|
// WithRequestBatchFuncs sets the functions for merging and splitting batches for an exporter built for custom request types.
|
|
func WithRequestBatchFuncs(mf exporterbatcher.BatchMergeFunc[Request], msf exporterbatcher.BatchMergeSplitFunc[Request]) BatcherOption {
|
|
return internal.WithRequestBatchFuncs(mf, msf)
|
|
}
|
|
|
|
// 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 WithBatcher(cfg exporterbatcher.Config, opts ...BatcherOption) Option {
|
|
return internal.WithBatcher(cfg, opts...)
|
|
}
|