@@ -15,6 +15,7 @@ import (
1515 "go.opentelemetry.io/collector/consumer"
1616 "go.opentelemetry.io/collector/exporter"
1717 "go.opentelemetry.io/collector/exporter/exporterbatcher"
18+ "go.opentelemetry.io/collector/exporter/exporterhelper/internal/queuebatch"
1819 "go.opentelemetry.io/collector/exporter/exporterhelper/internal/request"
1920 "go.opentelemetry.io/collector/exporter/exporterqueue" // BaseExporter contains common fields between different exporter types.
2021 "go.opentelemetry.io/collector/pipeline"
@@ -27,8 +28,6 @@ type BaseExporter struct {
2728 component.StartFunc
2829 component.ShutdownFunc
2930
30- encoding exporterqueue.Encoding [request.Request ]
31-
3231 Set exporter.Settings
3332
3433 // Message for the user to be added with an export failure message.
@@ -46,8 +45,10 @@ type BaseExporter struct {
4645
4746 timeoutCfg TimeoutConfig
4847 retryCfg configretry.BackOffConfig
49- queueCfg exporterqueue.Config
50- batcherCfg exporterbatcher.Config
48+
49+ queueBatchSettings queuebatch.Settings [request.Request ]
50+ queueCfg exporterqueue.Config
51+ batcherCfg exporterbatcher.Config
5152}
5253
5354func NewBaseExporter (set exporter.Settings , signal pipeline.Signal , pusher func (context.Context , request.Request ) error , options ... Option ) (* BaseExporter , error ) {
@@ -96,7 +97,7 @@ func NewBaseExporter(set exporter.Settings, signal pipeline.Signal, pusher func(
9697 qSet := exporterqueue.Settings [request.Request ]{
9798 Signal : signal ,
9899 ExporterSettings : set ,
99- Encoding : be .encoding ,
100+ Encoding : be .queueBatchSettings . Encoding ,
100101 }
101102 be .QueueSender , err = NewQueueSender (qSet , be .queueCfg , be .batcherCfg , be .ExportFailureMessage , be .firstSender )
102103 if err != nil {
@@ -197,27 +198,27 @@ func WithRetry(config configretry.BackOffConfig) Option {
197198// This option cannot be used with the new exporter helpers New[Traces|Metrics|Logs]RequestExporter.
198199func WithQueue (cfg exporterqueue.Config ) Option {
199200 return func (o * BaseExporter ) error {
200- if o .encoding == nil {
201- return errors .New ("WithQueue option is not available for the new request exporters, use WithRequestQueue instead" )
201+ if o .queueBatchSettings . Encoding == nil {
202+ return errors .New ("WithQueue option is not available for the new request exporters, use WithQueueBatch instead" )
202203 }
203- return WithRequestQueue (cfg , o .encoding )(o )
204+ return WithQueueBatch (cfg , o .queueBatchSettings )(o )
204205 }
205206}
206207
207- // WithRequestQueue enables queueing for an exporter.
208+ // WithQueueBatch enables queueing for an exporter.
208209// This option should be used with the new exporter helpers New[Traces|Metrics|Logs]RequestExporter.
209210// Experimental: This API is at the early stage of development and may change without backward compatibility
210211// until https://github.com/open-telemetry/opentelemetry-collector/issues/8122 is resolved.
211- func WithRequestQueue (cfg exporterqueue.Config , encoding exporterqueue. Encoding [request.Request ]) Option {
212+ func WithQueueBatch (cfg exporterqueue.Config , set queuebatch. Settings [request.Request ]) Option {
212213 return func (o * BaseExporter ) error {
213- if cfg .Enabled && cfg .StorageID != nil && encoding == nil {
214- return errors .New ("`encoding` must not be nil when persistent queue is enabled" )
215- }
216- o .encoding = encoding
217214 if ! cfg .Enabled {
218215 o .ExportFailureMessage += " Try enabling sending_queue to survive temporary failures."
219216 return nil
220217 }
218+ if cfg .StorageID != nil && set .Encoding == nil {
219+ return errors .New ("`QueueBatchSettings.Encoding` must not be nil when persistent queue is enabled" )
220+ }
221+ o .queueBatchSettings = set
221222 o .queueCfg = cfg
222223 return nil
223224 }
@@ -245,11 +246,11 @@ func WithBatcher(cfg exporterbatcher.Config) Option {
245246 }
246247}
247248
248- // WithEncoding is used to set the request encoding for the new exporter helper.
249+ // WithQueueBatchSettings is used to set the queuebatch.Settings for the new request based exporter helper.
249250// It must be provided as the first option when creating a new exporter helper.
250- func WithEncoding ( encoding exporterqueue. Encoding [request.Request ]) Option {
251+ func WithQueueBatchSettings ( set queuebatch. Settings [request.Request ]) Option {
251252 return func (o * BaseExporter ) error {
252- o .encoding = encoding
253+ o .queueBatchSettings = set
253254 return nil
254255 }
255256}
0 commit comments