Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 5 additions & 4 deletions exporter/awss3exporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configcompression"
"go.opentelemetry.io/collector/config/configoptional"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.uber.org/multierr"
)
Expand Down Expand Up @@ -90,10 +91,10 @@ type ResourceAttrsToS3 struct {

// Config contains the main configuration options for the s3 exporter
type Config struct {
QueueSettings exporterhelper.QueueBatchConfig `mapstructure:"sending_queue"`
TimeoutSettings exporterhelper.TimeoutConfig `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
S3Uploader S3UploaderConfig `mapstructure:"s3uploader"`
MarshalerName MarshalerType `mapstructure:"marshaler"`
QueueSettings configoptional.Optional[exporterhelper.QueueBatchConfig] `mapstructure:"sending_queue"`
TimeoutSettings exporterhelper.TimeoutConfig `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
S3Uploader S3UploaderConfig `mapstructure:"s3uploader"`
MarshalerName MarshalerType `mapstructure:"marshaler"`

// Encoding to apply. If present, overrides the marshaler configuration option.
Encoding *component.ID `mapstructure:"encoding"`
Expand Down
43 changes: 16 additions & 27 deletions exporter/awss3exporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configoptional"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.opentelemetry.io/collector/otelcol/otelcoltest"
"go.uber.org/multierr"
Expand All @@ -33,8 +34,7 @@ func TestLoadConfig(t *testing.T) {
e := cfg.Exporters[component.MustNewID("awss3")].(*Config)
encoding := component.MustNewIDWithName("foo", "bar")

queueCfg := exporterhelper.NewDefaultQueueConfig()
queueCfg.Enabled = false
queueCfg := configoptional.None[exporterhelper.QueueBatchConfig]()
timeoutCfg := exporterhelper.NewDefaultTimeoutConfig()

assert.Equal(t, &Config{
Expand Down Expand Up @@ -68,10 +68,10 @@ func TestConfig(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, cfg)

queueCfg := func() exporterhelper.QueueBatchConfig {
queueCfg := func() configoptional.Optional[exporterhelper.QueueBatchConfig] {
queue := exporterhelper.NewDefaultQueueConfig()
queue.NumConsumers = 23
queue.QueueSize = 42
queue.Get().NumConsumers = 23
queue.Get().QueueSize = 42
Comment on lines +71 to +74
Copy link
Contributor Author

@jmacd jmacd Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here. This looks right, to me, but the test is failing in ways that make me uncertain how to fix.

return queue
}()

Expand Down Expand Up @@ -115,8 +115,7 @@ func TestConfigS3StorageClass(t *testing.T) {
require.NotNil(t, cfg)

e := cfg.Exporters[component.MustNewID("awss3")].(*Config)
queueCfg := exporterhelper.NewDefaultQueueConfig()
queueCfg.Enabled = false
queueCfg := configoptional.None[exporterhelper.QueueBatchConfig]()
timeoutCfg := exporterhelper.NewDefaultTimeoutConfig()

assert.Equal(t, &Config{
Expand Down Expand Up @@ -152,8 +151,7 @@ func TestConfigS3ACL(t *testing.T) {
require.NotNil(t, cfg)

e := cfg.Exporters[component.MustNewID("awss3")].(*Config)
queueCfg := exporterhelper.NewDefaultQueueConfig()
queueCfg.Enabled = false
queueCfg := configoptional.None[exporterhelper.QueueBatchConfig]()
timeoutCfg := exporterhelper.NewDefaultTimeoutConfig()

assert.Equal(t, &Config{
Expand Down Expand Up @@ -190,8 +188,7 @@ func TestConfigS3ACLDefined(t *testing.T) {
require.NotNil(t, cfg)

e := cfg.Exporters[component.MustNewID("awss3")].(*Config)
queueCfg := exporterhelper.NewDefaultQueueConfig()
queueCfg.Enabled = false
queueCfg := configoptional.None[exporterhelper.QueueBatchConfig]()
timeoutCfg := exporterhelper.NewDefaultTimeoutConfig()

assert.Equal(t, &Config{
Expand Down Expand Up @@ -226,8 +223,7 @@ func TestConfigForS3CompatibleSystems(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, cfg)

queueCfg := exporterhelper.NewDefaultQueueConfig()
queueCfg.Enabled = false
queueCfg := configoptional.None[exporterhelper.QueueBatchConfig]()
timeoutCfg := exporterhelper.NewDefaultTimeoutConfig()

e := cfg.Exporters[component.MustNewID("awss3")].(*Config)
Expand Down Expand Up @@ -346,8 +342,7 @@ func TestMarshallerName(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, cfg)

queueCfg := exporterhelper.NewDefaultQueueConfig()
queueCfg.Enabled = false
queueCfg := configoptional.None[exporterhelper.QueueBatchConfig]()
timeoutCfg := exporterhelper.NewDefaultTimeoutConfig()

e := cfg.Exporters[component.MustNewID("awss3")].(*Config)
Expand Down Expand Up @@ -399,8 +394,7 @@ func TestCompressionName(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, cfg)

queueCfg := exporterhelper.NewDefaultQueueConfig()
queueCfg.Enabled = false
queueCfg := configoptional.None[exporterhelper.QueueBatchConfig]()
timeoutCfg := exporterhelper.NewDefaultTimeoutConfig()

e := cfg.Exporters[component.MustNewID("awss3")].(*Config)
Expand Down Expand Up @@ -454,8 +448,7 @@ func TestResourceAttrsToS3(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, cfg)

queueCfg := exporterhelper.NewDefaultQueueConfig()
queueCfg.Enabled = false
queueCfg := configoptional.None[exporterhelper.QueueBatchConfig]()
timeoutCfg := exporterhelper.NewDefaultTimeoutConfig()

e := cfg.Exporters[component.MustNewID("awss3")].(*Config)
Expand Down Expand Up @@ -495,8 +488,7 @@ func TestRetry(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, cfg)

queueCfg := exporterhelper.NewDefaultQueueConfig()
queueCfg.Enabled = false
queueCfg := configoptional.None[exporterhelper.QueueBatchConfig]()
timeoutCfg := exporterhelper.NewDefaultTimeoutConfig()

e := cfg.Exporters[component.MustNewID("awss3")].(*Config)
Expand Down Expand Up @@ -534,8 +526,7 @@ func TestConfigS3UniqueKeyFunc(t *testing.T) {
require.NotNil(t, cfg)

e := cfg.Exporters[component.MustNewID("awss3")].(*Config)
queueCfg := exporterhelper.NewDefaultQueueConfig()
queueCfg.Enabled = false
queueCfg := configoptional.None[exporterhelper.QueueBatchConfig]()
timeoutCfg := exporterhelper.NewDefaultTimeoutConfig()

assert.Equal(t, &Config{
Expand Down Expand Up @@ -571,8 +562,7 @@ func TestConfigS3BasePrefix(t *testing.T) {
require.NotNil(t, cfg)

e := cfg.Exporters[component.MustNewID("awss3")].(*Config)
queueCfg := exporterhelper.NewDefaultQueueConfig()
queueCfg.Enabled = false
queueCfg := configoptional.None[exporterhelper.QueueBatchConfig]()
timeoutCfg := exporterhelper.TimeoutConfig{
Timeout: 5 * time.Second,
}
Expand Down Expand Up @@ -610,8 +600,7 @@ func TestConfigS3BasePrefixWithResourceAttrs(t *testing.T) {
require.NotNil(t, cfg)

e := cfg.Exporters[component.MustNewID("awss3")].(*Config)
queueCfg := exporterhelper.NewDefaultQueueConfig()
queueCfg.Enabled = false
queueCfg := configoptional.None[exporterhelper.QueueBatchConfig]()
timeoutCfg := exporterhelper.TimeoutConfig{
Timeout: 5 * time.Second,
}
Expand Down
4 changes: 2 additions & 2 deletions exporter/awss3exporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"errors"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configoptional"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper"
Expand Down Expand Up @@ -46,8 +47,7 @@
}

func createDefaultConfig() component.Config {
queueCfg := exporterhelper.NewDefaultQueueConfig()
queueCfg.Enabled = false
queueCfg := configoptional.None[exporterhelper.QueueBatchConfig]()
timeoutCfg := exporterhelper.NewDefaultTimeoutConfig()

return &Config{
Expand Down Expand Up @@ -80,7 +80,7 @@
config,
s3Exporter.ConsumeLogs,
exporterhelper.WithStart(s3Exporter.start),
exporterhelper.WithQueue(cfg.QueueSettings),

Check failure on line 83 in exporter/awss3exporter/factory.go

View workflow job for this annotation

GitHub Actions / govulncheck (exporter-0)

cannot use cfg.QueueSettings (variable of struct type configoptional.Optional[exporterhelper.QueueBatchConfig]) as exporterhelper.QueueBatchConfig value in argument to exporterhelper.WithQueue
exporterhelper.WithTimeout(cfg.TimeoutSettings),
)
if err != nil {
Expand Down Expand Up @@ -117,7 +117,7 @@
config,
s3Exporter.ConsumeMetrics,
exporterhelper.WithStart(s3Exporter.start),
exporterhelper.WithQueue(cfg.QueueSettings),

Check failure on line 120 in exporter/awss3exporter/factory.go

View workflow job for this annotation

GitHub Actions / govulncheck (exporter-0)

cannot use cfg.QueueSettings (variable of struct type configoptional.Optional[exporterhelper.QueueBatchConfig]) as exporterhelper.QueueBatchConfig value in argument to exporterhelper.WithQueue
exporterhelper.WithTimeout(cfg.TimeoutSettings),
)
if err != nil {
Expand Down Expand Up @@ -155,7 +155,7 @@
config,
s3Exporter.ConsumeTraces,
exporterhelper.WithStart(s3Exporter.start),
exporterhelper.WithQueue(cfg.QueueSettings),

Check failure on line 158 in exporter/awss3exporter/factory.go

View workflow job for this annotation

GitHub Actions / govulncheck (exporter-0)

cannot use cfg.QueueSettings (variable of struct type configoptional.Optional[exporterhelper.QueueBatchConfig]) as exporterhelper.QueueBatchConfig value in argument to exporterhelper.WithQueue
exporterhelper.WithTimeout(cfg.TimeoutSettings),
)
if err != nil {
Expand Down
Loading