@@ -11,6 +11,7 @@ import (
1111 "go.uber.org/zap"
1212
1313 "go.opentelemetry.io/collector/component"
14+ "go.opentelemetry.io/collector/config/configoptional"
1415 "go.opentelemetry.io/collector/config/configretry"
1516 "go.opentelemetry.io/collector/consumer"
1617 "go.opentelemetry.io/collector/exporter"
@@ -47,7 +48,7 @@ type BaseExporter struct {
4748 retryCfg configretry.BackOffConfig
4849
4950 queueBatchSettings queuebatch.Settings [request.Request ]
50- queueCfg queuebatch.Config
51+ queueCfg configoptional. Optional [ queuebatch.Config ]
5152}
5253
5354func NewBaseExporter (set exporter.Settings , signal pipeline.Signal , pusher sender.SendFunc [request.Request ], options ... Option ) (* BaseExporter , error ) {
@@ -82,19 +83,19 @@ func NewBaseExporter(set exporter.Settings, signal pipeline.Signal, pusher sende
8283 return nil , err
8384 }
8485
85- if be .queueCfg .Batch .HasValue () {
86+ if be .queueCfg .HasValue () && be . queueCfg . Get (). Batch .HasValue () {
8687 // Batcher mutates the data.
8788 be .ConsumerOptions = append (be .ConsumerOptions , consumer .WithCapabilities (consumer.Capabilities {MutatesData : true }))
8889 }
8990
90- if be .queueCfg .Enabled {
91+ if be .queueCfg .HasValue () {
9192 qSet := queuebatch.AllSettings [request.Request ]{
9293 Settings : be .queueBatchSettings ,
9394 Signal : signal ,
9495 ID : set .ID ,
9596 Telemetry : set .TelemetrySettings ,
9697 }
97- be .QueueSender , err = NewQueueSender (qSet , be .queueCfg , be .ExportFailureMessage , be .firstSender )
98+ be .QueueSender , err = NewQueueSender (qSet , * be .queueCfg . Get () , be .ExportFailureMessage , be .firstSender )
9899 if err != nil {
99100 return nil , err
100101 }
@@ -191,7 +192,7 @@ func WithRetry(config configretry.BackOffConfig) Option {
191192// WithQueue overrides the default queuebatch.Config for an exporter.
192193// The default queuebatch.Config is to disable queueing.
193194// This option cannot be used with the new exporter helpers New[Traces|Metrics|Logs]RequestExporter.
194- func WithQueue (cfg queuebatch.Config ) Option {
195+ func WithQueue (cfg configoptional. Optional [ queuebatch.Config ] ) Option {
195196 return func (o * BaseExporter ) error {
196197 if o .queueBatchSettings .Encoding == nil {
197198 return errors .New ("WithQueue option is not available for the new request exporters, use WithQueueBatch instead" )
@@ -204,13 +205,13 @@ func WithQueue(cfg queuebatch.Config) Option {
204205// This option should be used with the new exporter helpers New[Traces|Metrics|Logs]RequestExporter.
205206// Experimental: This API is at the early stage of development and may change without backward compatibility
206207// until https://github.com/open-telemetry/opentelemetry-collector/issues/8122 is resolved.
207- func WithQueueBatch (cfg queuebatch.Config , set queuebatch.Settings [request.Request ]) Option {
208+ func WithQueueBatch (cfg configoptional. Optional [ queuebatch.Config ] , set queuebatch.Settings [request.Request ]) Option {
208209 return func (o * BaseExporter ) error {
209- if ! cfg .Enabled {
210+ if ! cfg .HasValue () {
210211 o .ExportFailureMessage += " Try enabling sending_queue to survive temporary failures."
211212 return nil
212213 }
213- if cfg .StorageID != nil && set .Encoding == nil {
214+ if cfg .Get (). StorageID != nil && set .Encoding == nil {
214215 return errors .New ("`Settings.Encoding` must not be nil when persistent queue is enabled" )
215216 }
216217 o .queueBatchSettings = set
0 commit comments