Skip to content

Commit 74ab500

Browse files
committed
[chore] Remove internal duplicate definition of QueueBatchSettings
Signed-off-by: Bogdan Drutu <[email protected]>
1 parent 4b44b64 commit 74ab500

File tree

7 files changed

+38
-44
lines changed

7 files changed

+38
-44
lines changed

exporter/exporterhelper/internal/base_exporter.go

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type BaseExporter struct {
4646
timeoutCfg TimeoutConfig
4747
retryCfg configretry.BackOffConfig
4848

49-
queueBatchSettings QueueBatchSettings[request.Request]
49+
queueBatchSettings queuebatch.Settings[request.Request]
5050
queueCfg queuebatch.Config
5151
}
5252

@@ -88,15 +88,11 @@ func NewBaseExporter(set exporter.Settings, signal pipeline.Signal, pusher sende
8888
}
8989

9090
if be.queueCfg.Enabled {
91-
qSet := queuebatch.Settings[request.Request]{
92-
Signal: signal,
93-
ID: set.ID,
94-
Telemetry: set.TelemetrySettings,
95-
ReferenceCounter: be.queueBatchSettings.ReferenceCounter,
96-
Encoding: be.queueBatchSettings.Encoding,
97-
ItemsSizer: be.queueBatchSettings.ItemsSizer,
98-
BytesSizer: be.queueBatchSettings.BytesSizer,
99-
Partitioner: be.queueBatchSettings.Partitioner,
91+
qSet := queuebatch.AllSettings[request.Request]{
92+
Settings: be.queueBatchSettings,
93+
Signal: signal,
94+
ID: set.ID,
95+
Telemetry: set.TelemetrySettings,
10096
}
10197
be.QueueSender, err = NewQueueSender(qSet, be.queueCfg, be.ExportFailureMessage, be.firstSender)
10298
if err != nil {
@@ -208,14 +204,14 @@ func WithQueue(cfg queuebatch.Config) Option {
208204
// This option should be used with the new exporter helpers New[Traces|Metrics|Logs]RequestExporter.
209205
// Experimental: This API is at the early stage of development and may change without backward compatibility
210206
// until https://github.com/open-telemetry/opentelemetry-collector/issues/8122 is resolved.
211-
func WithQueueBatch(cfg queuebatch.Config, set QueueBatchSettings[request.Request]) Option {
207+
func WithQueueBatch(cfg queuebatch.Config, set queuebatch.Settings[request.Request]) Option {
212208
return func(o *BaseExporter) error {
213209
if !cfg.Enabled {
214210
o.ExportFailureMessage += " Try enabling sending_queue to survive temporary failures."
215211
return nil
216212
}
217213
if cfg.StorageID != nil && set.Encoding == nil {
218-
return errors.New("`QueueBatchSettings.Encoding` must not be nil when persistent queue is enabled")
214+
return errors.New("`Settings.Encoding` must not be nil when persistent queue is enabled")
219215
}
220216
o.queueBatchSettings = set
221217
o.queueCfg = cfg
@@ -233,9 +229,9 @@ func WithCapabilities(capabilities consumer.Capabilities) Option {
233229
}
234230
}
235231

236-
// WithQueueBatchSettings is used to set the QueueBatchSettings for the new request based exporter helper.
232+
// WithQueueBatchSettings is used to set the queuebatch.Settings for the new request based exporter helper.
237233
// It must be provided as the first option when creating a new exporter helper.
238-
func WithQueueBatchSettings(set QueueBatchSettings[request.Request]) Option {
234+
func WithQueueBatchSettings(set queuebatch.Settings[request.Request]) Option {
239235
return func(o *BaseExporter) error {
240236
o.queueBatchSettings = set
241237
return nil

exporter/exporterhelper/internal/base_exporter_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"go.opentelemetry.io/collector/component"
1717
"go.opentelemetry.io/collector/component/componenttest"
1818
"go.opentelemetry.io/collector/config/configretry"
19+
"go.opentelemetry.io/collector/exporter/exporterhelper/internal/queuebatch"
1920
"go.opentelemetry.io/collector/exporter/exporterhelper/internal/request"
2021
"go.opentelemetry.io/collector/exporter/exporterhelper/internal/requesttest"
2122
"go.opentelemetry.io/collector/exporter/exportertest"
@@ -57,7 +58,7 @@ func TestQueueOptionsWithRequestExporter(t *testing.T) {
5758
_, err = NewBaseExporter(exportertest.NewNopSettings(exportertest.NopType), pipeline.SignalMetrics, noopExport,
5859
WithQueueBatchSettings(newFakeQueueBatch()),
5960
WithRetry(configretry.NewDefaultBackOffConfig()),
60-
WithQueueBatch(qCfg, QueueBatchSettings[request.Request]{}))
61+
WithQueueBatch(qCfg, queuebatch.Settings[request.Request]{}))
6162
require.Error(t, err)
6263
}
6364

@@ -140,8 +141,8 @@ func noopExport(context.Context, request.Request) error {
140141
return nil
141142
}
142143

143-
func newFakeQueueBatch() QueueBatchSettings[request.Request] {
144-
return QueueBatchSettings[request.Request]{
144+
func newFakeQueueBatch() queuebatch.Settings[request.Request] {
145+
return queuebatch.Settings[request.Request]{
145146
Encoding: fakeEncoding{},
146147
ItemsSizer: request.NewItemsSizer(),
147148
BytesSizer: requesttest.NewBytesSizer(),

exporter/exporterhelper/internal/queue_sender.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,11 @@ import (
88

99
"go.uber.org/zap"
1010

11-
"go.opentelemetry.io/collector/exporter/exporterhelper/internal/queue"
1211
"go.opentelemetry.io/collector/exporter/exporterhelper/internal/queuebatch"
1312
"go.opentelemetry.io/collector/exporter/exporterhelper/internal/request"
1413
"go.opentelemetry.io/collector/exporter/exporterhelper/internal/sender"
1514
)
1615

17-
// QueueBatchSettings is a subset of the queuebatch.Settings that are needed when used within an Exporter.
18-
type QueueBatchSettings[T any] struct {
19-
ReferenceCounter queue.ReferenceCounter[T]
20-
Encoding queue.Encoding[T]
21-
ItemsSizer request.Sizer[T]
22-
BytesSizer request.Sizer[T]
23-
Partitioner queuebatch.Partitioner[T]
24-
}
25-
2616
// NewDefaultQueueConfig returns the default config for queuebatch.Config.
2717
// By default, the queue stores 1000 requests of telemetry and is non-blocking when full.
2818
func NewDefaultQueueConfig() queuebatch.Config {
@@ -39,7 +29,7 @@ func NewDefaultQueueConfig() queuebatch.Config {
3929
}
4030

4131
func NewQueueSender(
42-
qSet queuebatch.Settings[request.Request],
32+
qSet queuebatch.AllSettings[request.Request],
4333
qCfg queuebatch.Config,
4434
exportFailureMessage string,
4535
next sender.Sender[request.Request],

exporter/exporterhelper/internal/queue_sender_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
func TestNewQueueSenderFailedRequestDropped(t *testing.T) {
27-
qSet := queuebatch.Settings[request.Request]{
27+
qSet := queuebatch.AllSettings[request.Request]{
2828
Signal: pipeline.SignalMetrics,
2929
ID: component.NewID(exportertest.NopType),
3030
Telemetry: componenttest.NewNopTelemetrySettings(),

exporter/exporterhelper/internal/queuebatch/queue_batch.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,22 @@ import (
1414
"go.opentelemetry.io/collector/pipeline"
1515
)
1616

17-
// Settings defines settings for creating a QueueBatch.
17+
// Settings is a subset of the queuebatch.Settings that are needed when used within an Exporter.
1818
type Settings[T any] struct {
19-
Signal pipeline.Signal
20-
ID component.ID
21-
Telemetry component.TelemetrySettings
2219
ReferenceCounter queue.ReferenceCounter[T]
2320
Encoding queue.Encoding[T]
2421
ItemsSizer request.Sizer[T]
2522
BytesSizer request.Sizer[T]
2623
Partitioner Partitioner[T]
27-
MergeCtx func(context.Context, context.Context) context.Context
24+
}
25+
26+
// AllSettings defines settings for creating a QueueBatch.
27+
type AllSettings[T any] struct {
28+
Settings[T]
29+
Signal pipeline.Signal
30+
ID component.ID
31+
Telemetry component.TelemetrySettings
32+
MergeCtx func(context.Context, context.Context) context.Context
2833
}
2934

3035
type QueueBatch struct {
@@ -33,7 +38,7 @@ type QueueBatch struct {
3338
}
3439

3540
func NewQueueBatch(
36-
set Settings[request.Request],
41+
set AllSettings[request.Request],
3742
cfg Config,
3843
next sender.SendFunc[request.Request],
3944
) (*QueueBatch, error) {

exporter/exporterhelper/internal/queuebatch/queue_batch_test.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ import (
2929
"go.opentelemetry.io/collector/pipeline"
3030
)
3131

32-
func newFakeRequestSettings() Settings[request.Request] {
33-
return Settings[request.Request]{
34-
Signal: pipeline.SignalMetrics,
35-
ID: component.NewID(exportertest.NopType),
36-
Telemetry: componenttest.NewNopTelemetrySettings(),
37-
Encoding: newFakeEncoding(&requesttest.FakeRequest{}),
38-
ItemsSizer: request.NewItemsSizer(),
39-
BytesSizer: requesttest.NewBytesSizer(),
32+
func newFakeRequestSettings() AllSettings[request.Request] {
33+
return AllSettings[request.Request]{
34+
Signal: pipeline.SignalMetrics,
35+
ID: component.NewID(exportertest.NopType),
36+
Telemetry: componenttest.NewNopTelemetrySettings(),
37+
Settings: Settings[request.Request]{
38+
Encoding: newFakeEncoding(&requesttest.FakeRequest{}),
39+
ItemsSizer: request.NewItemsSizer(),
40+
BytesSizer: requesttest.NewBytesSizer(),
41+
},
4042
}
4143
}
4244

exporter/exporterhelper/queue_batch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var ErrQueueIsFull = queue.ErrQueueIsFull
3838

3939
// QueueBatchSettings are settings for the QueueBatch component.
4040
// They include things line Encoding to be used with persistent queue, or the available Sizers, etc.
41-
type QueueBatchSettings = internal.QueueBatchSettings[Request]
41+
type QueueBatchSettings = queuebatch.Settings[Request]
4242

4343
// WithQueueBatch enables queueing and batching for an exporter.
4444
// This option should be used with the new exporter helpers New[Traces|Metrics|Logs]RequestExporter.

0 commit comments

Comments
 (0)