@@ -15,6 +15,7 @@ import (
15
15
"go.opentelemetry.io/collector/consumer"
16
16
"go.opentelemetry.io/collector/exporter"
17
17
"go.opentelemetry.io/collector/exporter/exporterbatcher"
18
+ "go.opentelemetry.io/collector/exporter/exporterhelper/internal/queuebatch"
18
19
"go.opentelemetry.io/collector/exporter/exporterhelper/internal/request"
19
20
"go.opentelemetry.io/collector/exporter/exporterqueue" // BaseExporter contains common fields between different exporter types.
20
21
"go.opentelemetry.io/collector/pipeline"
@@ -27,8 +28,6 @@ type BaseExporter struct {
27
28
component.StartFunc
28
29
component.ShutdownFunc
29
30
30
- encoding exporterqueue.Encoding [request.Request ]
31
-
32
31
Set exporter.Settings
33
32
34
33
// Message for the user to be added with an export failure message.
@@ -46,8 +45,10 @@ type BaseExporter struct {
46
45
47
46
timeoutCfg TimeoutConfig
48
47
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
51
52
}
52
53
53
54
func 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(
96
97
qSet := exporterqueue.Settings [request.Request ]{
97
98
Signal : signal ,
98
99
ExporterSettings : set ,
99
- Encoding : be .encoding ,
100
+ Encoding : be .queueBatchSettings . Encoding ,
100
101
}
101
102
be .QueueSender , err = NewQueueSender (qSet , be .queueCfg , be .batcherCfg , be .ExportFailureMessage , be .firstSender )
102
103
if err != nil {
@@ -197,27 +198,27 @@ func WithRetry(config configretry.BackOffConfig) Option {
197
198
// This option cannot be used with the new exporter helpers New[Traces|Metrics|Logs]RequestExporter.
198
199
func WithQueue (cfg exporterqueue.Config ) Option {
199
200
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" )
202
203
}
203
- return WithRequestQueue (cfg , o .encoding )(o )
204
+ return WithQueueBatch (cfg , o .queueBatchSettings )(o )
204
205
}
205
206
}
206
207
207
- // WithRequestQueue enables queueing for an exporter.
208
+ // WithQueueBatch enables queueing for an exporter.
208
209
// This option should be used with the new exporter helpers New[Traces|Metrics|Logs]RequestExporter.
209
210
// Experimental: This API is at the early stage of development and may change without backward compatibility
210
211
// 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 {
212
213
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
217
214
if ! cfg .Enabled {
218
215
o .ExportFailureMessage += " Try enabling sending_queue to survive temporary failures."
219
216
return nil
220
217
}
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
221
222
o .queueCfg = cfg
222
223
return nil
223
224
}
@@ -245,11 +246,11 @@ func WithBatcher(cfg exporterbatcher.Config) Option {
245
246
}
246
247
}
247
248
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.
249
250
// 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 {
251
252
return func (o * BaseExporter ) error {
252
- o .encoding = encoding
253
+ o .queueBatchSettings = set
253
254
return nil
254
255
}
255
256
}
0 commit comments