Skip to content

Commit 89d900b

Browse files
committed
Remove deprecated fields from batch config
Signed-off-by: Bogdan Drutu <[email protected]>
1 parent 6aad9d1 commit 89d900b

File tree

4 files changed

+25
-111
lines changed

4 files changed

+25
-111
lines changed

.chloggen/rm-old-size.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: exporterbatch
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Remove deprecated fields `min_size_items` and `max_size_items` from batch config.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: []
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: [api, user]

exporter/exporterbatcher/config.go

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77
"errors"
88
"fmt"
99
"time"
10-
11-
"go.opentelemetry.io/collector/confmap"
1210
)
1311

1412
// Config defines a configuration for batching requests based on a timeout and a minimum number of items.
@@ -23,11 +21,6 @@ type Config struct {
2321

2422
// SizeConfig sets the size limits for a batch.
2523
SizeConfig `mapstructure:",squash"`
26-
27-
// Deprecated: [v0.121.0] Ignored if SizeConfig is set.
28-
MinSizeConfig `mapstructure:",squash"`
29-
// Deprecated: [v0.121.0] Ignored if SizeConfig is set.
30-
MaxSizeConfig `mapstructure:",squash"`
3124
}
3225

3326
// SizeConfig sets the size limits for a batch.
@@ -40,34 +33,6 @@ type SizeConfig struct {
4033
MaxSize int `mapstructure:"max_size"`
4134
}
4235

43-
// Deprecated: [v0.121.0] use SizeConfig.
44-
type MinSizeConfig struct {
45-
// Deprecated: [v0.121.0] use SizeConfig.MinSize.
46-
MinSizeItems *int `mapstructure:"min_size_items"`
47-
}
48-
49-
// Deprecated: [v0.121.0] use SizeConfig.
50-
type MaxSizeConfig struct {
51-
// Deprecated: [v0.121.0] use SizeConfig.MaxSize.
52-
MaxSizeItems *int `mapstructure:"max_size_items"`
53-
}
54-
55-
func (c *Config) Unmarshal(conf *confmap.Conf) error {
56-
if err := conf.Unmarshal(c); err != nil {
57-
return err
58-
}
59-
60-
if c.MinSizeItems != nil && !conf.IsSet("min_size") {
61-
c.SizeConfig.MinSize = *c.MinSizeItems
62-
}
63-
64-
if c.MaxSizeItems != nil && !conf.IsSet("max_size") {
65-
c.SizeConfig.MaxSize = *c.MaxSizeItems
66-
}
67-
68-
return nil
69-
}
70-
7136
func (c *Config) Validate() error {
7237
if c.FlushTimeout <= 0 {
7338
return errors.New("`flush_timeout` must be greater than zero")

exporter/exporterbatcher/config_test.go

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77
"testing"
88

99
"github.com/stretchr/testify/require"
10-
11-
"go.opentelemetry.io/collector/confmap"
1210
)
1311

1412
func TestValidateConfig(t *testing.T) {
@@ -49,72 +47,3 @@ func TestValidateSizeConfig(t *testing.T) {
4947
}
5048
require.EqualError(t, cfg.Validate(), "`max_size` must be greater than or equal to mix_size")
5149
}
52-
53-
func TestUnmarshalDeprecatedFields(t *testing.T) {
54-
p111 := 111
55-
p222 := 222
56-
tests := []struct {
57-
name string
58-
input map[string]any
59-
expected Config
60-
}{
61-
{
62-
name: "only_deprecated_fields_used",
63-
input: map[string]any{
64-
"enabled": true,
65-
"flush_timeout": 200,
66-
"min_size_items": 111,
67-
"max_size_items": 222,
68-
},
69-
expected: Config{
70-
Enabled: true,
71-
FlushTimeout: 200,
72-
SizeConfig: SizeConfig{
73-
Sizer: SizerTypeItems,
74-
MinSize: 111,
75-
MaxSize: 222,
76-
},
77-
MinSizeConfig: MinSizeConfig{
78-
MinSizeItems: &p111,
79-
},
80-
MaxSizeConfig: MaxSizeConfig{
81-
MaxSizeItems: &p222,
82-
},
83-
},
84-
},
85-
{
86-
name: "both_new_and_deprecated_fields_used",
87-
input: map[string]any{
88-
"enabled": true,
89-
"flush_timeout": 200,
90-
"min_size_items": 111,
91-
"max_size_items": 222,
92-
"min_size": 11,
93-
"max_size": 22,
94-
},
95-
expected: Config{
96-
Enabled: true,
97-
FlushTimeout: 200,
98-
SizeConfig: SizeConfig{
99-
Sizer: SizerTypeItems,
100-
MinSize: 11,
101-
MaxSize: 22,
102-
},
103-
MinSizeConfig: MinSizeConfig{
104-
MinSizeItems: &p111,
105-
},
106-
MaxSizeConfig: MaxSizeConfig{
107-
MaxSizeItems: &p222,
108-
},
109-
},
110-
},
111-
}
112-
for _, test := range tests {
113-
t.Run(test.name, func(t *testing.T) {
114-
cfg := NewDefaultConfig()
115-
require.NoError(t, cfg.Unmarshal(confmap.NewFromStringMap(test.input)))
116-
require.Equal(t, test.expected, cfg)
117-
require.NoError(t, cfg.Validate())
118-
})
119-
}
120-
}

exporter/exporterhelper/internal/base_exporter.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ func NewBaseExporter(set exporter.Settings, signal pipeline.Signal, pusher func(
6363
}
6464
}
6565

66-
//nolint:staticcheck
67-
if be.batcherCfg.MinSizeItems != nil || be.batcherCfg.MaxSizeItems != nil {
68-
set.Logger.Warn("Using of deprecated fields `min_size_items` and `max_size_items`")
69-
}
70-
7166
// Consumer Sender is always initialized.
7267
be.firstSender = newSender(pusher)
7368

0 commit comments

Comments
 (0)