Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pkg/stanza] Remove helper.Duration #13439

Merged
merged 1 commit into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions pkg/stanza/docs/types/duration.md

This file was deleted.

6 changes: 3 additions & 3 deletions pkg/stanza/fileconsumer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewConfig() *Config {
IncludeFilePath: false,
IncludeFileNameResolved: false,
IncludeFilePathResolved: false,
PollInterval: helper.Duration{Duration: 200 * time.Millisecond},
PollInterval: 200 * time.Millisecond,
Splitter: helper.NewSplitterConfig(),
StartAt: "end",
FingerprintSize: DefaultFingerprintSize,
Expand All @@ -52,7 +52,7 @@ type Config struct {
IncludeFilePath bool `mapstructure:"include_file_path,omitempty" json:"include_file_path,omitempty" yaml:"include_file_path,omitempty"`
IncludeFileNameResolved bool `mapstructure:"include_file_name_resolved,omitempty" json:"include_file_name_resolved,omitempty" yaml:"include_file_name_resolved,omitempty"`
IncludeFilePathResolved bool `mapstructure:"include_file_path_resolved,omitempty" json:"include_file_path_resolved,omitempty" yaml:"include_file_path_resolved,omitempty"`
PollInterval helper.Duration `mapstructure:"poll_interval,omitempty" json:"poll_interval,omitempty" yaml:"poll_interval,omitempty"`
PollInterval time.Duration `mapstructure:"poll_interval,omitempty" json:"poll_interval,omitempty" yaml:"poll_interval,omitempty"`
StartAt string `mapstructure:"start_at,omitempty" json:"start_at,omitempty" yaml:"start_at,omitempty"`
FingerprintSize helper.ByteSize `mapstructure:"fingerprint_size,omitempty" json:"fingerprint_size,omitempty" yaml:"fingerprint_size,omitempty"`
MaxLogSize helper.ByteSize `mapstructure:"max_log_size,omitempty" json:"max_log_size,omitempty" yaml:"max_log_size,omitempty"`
Expand Down Expand Up @@ -131,7 +131,7 @@ func (c Config) Build(logger *zap.SugaredLogger, emit EmitFunc) (*Manager, error
},
finder: c.Finder,
roller: newRoller(),
pollInterval: c.PollInterval.Raw(),
pollInterval: c.PollInterval,
maxBatchFiles: c.MaxConcurrentFiles / 2,
knownFiles: make([]*Reader, 0, 10),
seenPaths: make(map[string]struct{}, 100),
Expand Down
30 changes: 13 additions & 17 deletions pkg/stanza/fileconsumer/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func TestUnmarshal(t *testing.T) {
ExpectErr: false,
Expect: func() *Config {
cfg := NewConfig()
cfg.PollInterval = helper.NewDuration(time.Second)
cfg.PollInterval = time.Second
return cfg
}(),
},
Expand All @@ -186,7 +186,7 @@ func TestUnmarshal(t *testing.T) {
ExpectErr: false,
Expect: func() *Config {
cfg := NewConfig()
cfg.PollInterval = helper.NewDuration(time.Second)
cfg.PollInterval = time.Second
return cfg
}(),
},
Expand All @@ -195,7 +195,7 @@ func TestUnmarshal(t *testing.T) {
ExpectErr: false,
Expect: func() *Config {
cfg := NewConfig()
cfg.PollInterval = helper.NewDuration(time.Millisecond)
cfg.PollInterval = time.Millisecond
return cfg
}(),
},
Expand All @@ -204,7 +204,7 @@ func TestUnmarshal(t *testing.T) {
ExpectErr: false,
Expect: func() *Config {
cfg := NewConfig()
cfg.PollInterval = helper.NewDuration(time.Second)
cfg.PollInterval = time.Second
return cfg
}(),
},
Expand Down Expand Up @@ -399,7 +399,7 @@ func TestBuild(t *testing.T) {
cfg := NewConfig()
cfg.Include = []string{"/var/log/testpath.*"}
cfg.Exclude = []string{"/var/log/testpath.ex*"}
cfg.PollInterval = helper.Duration{Duration: 10 * time.Millisecond}
cfg.PollInterval = 10 * time.Millisecond
return cfg
}

Expand Down Expand Up @@ -562,12 +562,12 @@ func TestMapStructureDecodeConfigWithHook(t *testing.T) {
"resource": map[string]interface{}{},
"include": expect.Include,
"exclude": expect.Exclude,
"poll_interval": 0.2,
"poll_interval": 200 * time.Millisecond,
"multiline": map[string]interface{}{
"line_start_pattern": expect.Splitter.Multiline.LineStartPattern,
"line_end_pattern": expect.Splitter.Multiline.LineEndPattern,
},
"force_flush_period": 0.5,
"force_flush_period": 500 * time.Millisecond,
"include_file_name": true,
"include_file_path": false,
"start_at": "end",
Expand All @@ -589,13 +589,11 @@ func TestMapStructureDecodeConfigWithHook(t *testing.T) {
func TestMapStructureDecodeConfig(t *testing.T) {
expect := NewTestConfig()
cfgMap := map[string]interface{}{
"attributes": map[string]interface{}{},
"resource": map[string]interface{}{},
"include": expect.Include,
"exclude": expect.Exclude,
"poll_interval": map[string]interface{}{
"Duration": 200 * 1000 * 1000,
},
"attributes": map[string]interface{}{},
"resource": map[string]interface{}{},
"include": expect.Include,
"exclude": expect.Exclude,
"poll_interval": 200 * time.Millisecond,
"multiline": map[string]interface{}{
"line_start_pattern": expect.Splitter.Multiline.LineStartPattern,
"line_end_pattern": expect.Splitter.Multiline.LineEndPattern,
Expand All @@ -607,9 +605,7 @@ func TestMapStructureDecodeConfig(t *testing.T) {
"max_log_size": 1024 * 1024,
"max_concurrent_files": 1024,
"encoding": "utf16",
"force_flush_period": map[string]interface{}{
"Duration": 500 * 1000 * 1000,
},
"force_flush_period": 500 * time.Millisecond,
}

var actual Config
Expand Down
2 changes: 1 addition & 1 deletion pkg/stanza/fileconsumer/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ func TestNoNewline(t *testing.T) {
cfg := NewConfig().includeDir(tempDir)
cfg.StartAt = "beginning"
cfg.Splitter = helper.NewSplitterConfig()
cfg.Splitter.Flusher.Period.Duration = time.Nanosecond
cfg.Splitter.Flusher.Period = time.Nanosecond
operator, emitCalls := buildTestManager(t, cfg)

temp := openTemp(t, tempDir)
Expand Down
3 changes: 1 addition & 2 deletions pkg/stanza/fileconsumer/rotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (

"github.com/stretchr/testify/require"

"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/helper"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/testutil"
)

Expand Down Expand Up @@ -262,7 +261,7 @@ func (rt rotationTest) run(tc rotationTest, copyTruncate, sequential bool) func(
tempDir := t.TempDir()
cfg := NewConfig().includeDir(tempDir)
cfg.StartAt = "beginning"
cfg.PollInterval = helper.NewDuration(tc.pollInterval)
cfg.PollInterval = tc.pollInterval
emitCalls := make(chan *emitParams, tc.totalLines)
operator := buildTestManagerWithEmit(t, cfg, emitCalls)

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
poll_interval: 1
poll_interval: 1000000000
95 changes: 0 additions & 95 deletions pkg/stanza/operator/helper/duration.go

This file was deleted.

Loading