Skip to content

Commit 649d587

Browse files
bogdandrutuchengchuanpeng
authored andcommitted
Remove deprecated func BuildWithSplitFunc from stanza/fileconsumer (open-telemetry#37723)
Signed-off-by: Bogdan Drutu <[email protected]>
1 parent be59d39 commit 649d587

File tree

4 files changed

+27
-86
lines changed

4 files changed

+27
-86
lines changed

.chloggen/rm-dep-func.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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. filelogreceiver)
7+
component: pkg/stanza
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 func BuildWithSplitFunc from stanza/fileconsumer
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [37723]
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+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [api]

pkg/stanza/decode/decode.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
)
1717

1818
type Decoder struct {
19-
encoding encoding.Encoding
2019
decoder *encoding.Decoder
2120
decodeBuffer []byte
2221
}
@@ -25,7 +24,6 @@ type Decoder struct {
2524
// Decoder is not thread-safe and must not be used in multiple goroutines.
2625
func New(enc encoding.Encoding) *Decoder {
2726
return &Decoder{
28-
encoding: enc,
2927
decoder: enc.NewDecoder(),
3028
decodeBuffer: make([]byte, 1<<12),
3129
}

pkg/stanza/fileconsumer/config.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@ type HeaderConfig struct {
9595
MetadataOperators []operator.Config `mapstructure:"metadata_operators"`
9696
}
9797

98-
// Deprecated [v0.97.0] Use Build and WithSplitFunc option instead
99-
func (c Config) BuildWithSplitFunc(set component.TelemetrySettings, emit emit.Callback, splitFunc bufio.SplitFunc) (*Manager, error) {
100-
return c.Build(set, emit, WithSplitFunc(splitFunc))
101-
}
102-
10398
func (c Config) Build(set component.TelemetrySettings, emit emit.Callback, opts ...Option) (*Manager, error) {
10499
if err := c.validate(); err != nil {
105100
return nil, err

pkg/stanza/fileconsumer/config_test.go

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -658,85 +658,6 @@ func TestBuild(t *testing.T) {
658658
}
659659
}
660660

661-
func TestBuildWithSplitFunc(t *testing.T) {
662-
t.Parallel()
663-
664-
basicConfig := func() *Config {
665-
cfg := NewConfig()
666-
cfg.Include = []string{"/var/log/testpath.*"}
667-
cfg.Exclude = []string{"/var/log/testpath.ex*"}
668-
cfg.PollInterval = 10 * time.Millisecond
669-
return cfg
670-
}
671-
672-
cases := []struct {
673-
name string
674-
modifyBaseConfig func(*Config)
675-
errorRequirement require.ErrorAssertionFunc
676-
validate func(*testing.T, *Manager)
677-
}{
678-
{
679-
"Basic",
680-
func(_ *Config) {},
681-
require.NoError,
682-
func(t *testing.T, m *Manager) {
683-
require.Equal(t, 10*time.Millisecond, m.pollInterval)
684-
},
685-
},
686-
{
687-
"BadIncludeGlob",
688-
func(cfg *Config) {
689-
cfg.Include = []string{"["}
690-
},
691-
require.Error,
692-
nil,
693-
},
694-
{
695-
"BadExcludeGlob",
696-
func(cfg *Config) {
697-
cfg.Include = []string{"["}
698-
},
699-
require.Error,
700-
nil,
701-
},
702-
{
703-
"InvalidEncoding",
704-
func(cfg *Config) {
705-
cfg.Encoding = "UTF-3233"
706-
},
707-
require.Error,
708-
nil,
709-
},
710-
}
711-
712-
for _, tc := range cases {
713-
t.Run(tc.name, func(t *testing.T) {
714-
t.Parallel()
715-
cfg := basicConfig()
716-
tc.modifyBaseConfig(cfg)
717-
718-
splitNone := func(data []byte, atEOF bool) (advance int, token []byte, err error) {
719-
if !atEOF {
720-
return 0, nil, nil
721-
}
722-
if len(data) == 0 {
723-
return 0, nil, nil
724-
}
725-
return len(data), data, nil
726-
}
727-
728-
set := componenttest.NewNopTelemetrySettings()
729-
input, err := cfg.BuildWithSplitFunc(set, emittest.Nop, splitNone)
730-
tc.errorRequirement(t, err)
731-
if err != nil {
732-
return
733-
}
734-
735-
tc.validate(t, input)
736-
})
737-
}
738-
}
739-
740661
func TestBuildWithHeader(t *testing.T) {
741662
basicConfig := func() *Config {
742663
cfg := NewConfig()

0 commit comments

Comments
 (0)