Skip to content

Commit

Permalink
Revert changes to config.[Receiver|Processor|Exporter|Extension]Settings
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu committed Nov 1, 2022
1 parent b48e108 commit 0a8f738
Show file tree
Hide file tree
Showing 74 changed files with 641 additions and 600 deletions.
3 changes: 0 additions & 3 deletions .chloggen/deprecateallconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ subtext: |
- config.[New]ReceiverSettings => component.[New]ReceiverConfigSettings
- config.Processor => component.ProcessorConfig
- config.UnmarshalProcessor => component.UnmarshalProcessorConfig
- config.[New]ProcessorSettings => component.[New]ProcessorConfigSettings
- config.Exporter => component.ExporterConfig
- config.UnmarshalExporter => component.UnmarshalExporterConfig
- config.[New]ExporterSettings => component.[New]ExporterConfigSettings
- config.Extension => component.ExtensionConfig
- config.UnmarshalExtension => component.UnmarshalExtensionConfig
- config.[New]ExtensionSettings => component.[New]ExtensionConfigSettings
10 changes: 5 additions & 5 deletions cmd/builder/internal/builder/templates/components_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ import (

"github.com/stretchr/testify/assert"

"go.opentelemetry.io/collector/config/configtest"
"go.opentelemetry.io/collector/component/componenttest"
)

func TestValidateConfigs(t *testing.T) {
factories, err := components()
assert.NoError(t, err)

for _, factory := range factories.Receivers {
assert.NoError(t, configtest.CheckConfigStruct(factory.CreateDefaultConfig()))
assert.NoError(t, componenttest.CheckConfigStruct(factory.CreateDefaultConfig()))
}
for _, factory := range factories.Processors {
assert.NoError(t, configtest.CheckConfigStruct(factory.CreateDefaultConfig()))
assert.NoError(t, componenttest.CheckConfigStruct(factory.CreateDefaultConfig()))
}
for _, factory := range factories.Exporters {
assert.NoError(t, configtest.CheckConfigStruct(factory.CreateDefaultConfig()))
assert.NoError(t, componenttest.CheckConfigStruct(factory.CreateDefaultConfig()))
}
for _, factory := range factories.Extensions {
assert.NoError(t, configtest.CheckConfigStruct(factory.CreateDefaultConfig()))
assert.NoError(t, componenttest.CheckConfigStruct(factory.CreateDefaultConfig()))
}
}
5 changes: 3 additions & 2 deletions component/componenttest/nop_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/consumer/consumertest"
)

Expand All @@ -30,7 +31,7 @@ func NewNopExporterCreateSettings() component.ExporterCreateSettings {
}

type nopExporterConfig struct {
component.ExporterConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
config.ExporterSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
}

// NewNopExporterFactory returns a component.ExporterFactory that constructs nop exporters.
Expand All @@ -39,7 +40,7 @@ func NewNopExporterFactory() component.ExporterFactory {
"nop",
func() component.ExporterConfig {
return &nopExporterConfig{
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID("nop")),
ExporterSettings: config.NewExporterSettings(component.NewID("nop")),
}
},
component.WithTracesExporter(createTracesExporter, component.StabilityLevelStable),
Expand Down
3 changes: 2 additions & 1 deletion component/componenttest/nop_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/stretchr/testify/require"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/pdata/ptrace"
Expand All @@ -32,7 +33,7 @@ func TestNewNopExporterFactory(t *testing.T) {
require.NotNil(t, factory)
assert.Equal(t, component.Type("nop"), factory.Type())
cfg := factory.CreateDefaultConfig()
assert.Equal(t, &nopExporterConfig{ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID("nop"))}, cfg)
assert.Equal(t, &nopExporterConfig{ExporterSettings: config.NewExporterSettings(component.NewID("nop"))}, cfg)

traces, err := factory.CreateTracesExporter(context.Background(), NewNopExporterCreateSettings(), cfg)
require.NoError(t, err)
Expand Down
5 changes: 3 additions & 2 deletions component/componenttest/nop_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
)

// NewNopExtensionCreateSettings returns a new nop settings for Create*Extension functions.
Expand All @@ -29,7 +30,7 @@ func NewNopExtensionCreateSettings() component.ExtensionCreateSettings {
}

type nopExtensionConfig struct {
component.ExtensionConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
config.ExtensionSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
}

// NewNopExtensionFactory returns a component.ExtensionFactory that constructs nop extensions.
Expand All @@ -38,7 +39,7 @@ func NewNopExtensionFactory() component.ExtensionFactory {
"nop",
func() component.ExtensionConfig {
return &nopExtensionConfig{
ExtensionConfigSettings: component.NewExtensionConfigSettings(component.NewID("nop")),
ExtensionSettings: config.NewExtensionSettings(component.NewID("nop")),
}
},
func(context.Context, component.ExtensionCreateSettings, component.ExtensionConfig) (component.Extension, error) {
Expand Down
3 changes: 2 additions & 1 deletion component/componenttest/nop_extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ import (
"github.com/stretchr/testify/require"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
)

func TestNewNopExtensionFactory(t *testing.T) {
factory := NewNopExtensionFactory()
require.NotNil(t, factory)
assert.Equal(t, component.Type("nop"), factory.Type())
cfg := factory.CreateDefaultConfig()
assert.Equal(t, &nopExtensionConfig{ExtensionConfigSettings: component.NewExtensionConfigSettings(component.NewID("nop"))}, cfg)
assert.Equal(t, &nopExtensionConfig{ExtensionSettings: config.NewExtensionSettings(component.NewID("nop"))}, cfg)

traces, err := factory.CreateExtension(context.Background(), NewNopExtensionCreateSettings(), cfg)
require.NoError(t, err)
Expand Down
5 changes: 3 additions & 2 deletions component/componenttest/nop_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/consumer/consumertest"
)
Expand All @@ -31,7 +32,7 @@ func NewNopProcessorCreateSettings() component.ProcessorCreateSettings {
}

type nopProcessorConfig struct {
component.ProcessorConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
config.ProcessorSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
}

// NewNopProcessorFactory returns a component.ProcessorFactory that constructs nop processors.
Expand All @@ -40,7 +41,7 @@ func NewNopProcessorFactory() component.ProcessorFactory {
"nop",
func() component.ProcessorConfig {
return &nopProcessorConfig{
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID("nop")),
ProcessorSettings: config.NewProcessorSettings(component.NewID("nop")),
}
},
component.WithTracesProcessor(createTracesProcessor, component.StabilityLevelStable),
Expand Down
3 changes: 2 additions & 1 deletion component/componenttest/nop_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/stretchr/testify/require"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/pdata/plog"
Expand All @@ -34,7 +35,7 @@ func TestNewNopProcessorFactory(t *testing.T) {
require.NotNil(t, factory)
assert.Equal(t, component.Type("nop"), factory.Type())
cfg := factory.CreateDefaultConfig()
assert.Equal(t, &nopProcessorConfig{ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID("nop"))}, cfg)
assert.Equal(t, &nopProcessorConfig{ProcessorSettings: config.NewProcessorSettings(component.NewID("nop"))}, cfg)

traces, err := factory.CreateTracesProcessor(context.Background(), NewNopProcessorCreateSettings(), cfg, consumertest.NewNop())
require.NoError(t, err)
Expand Down
5 changes: 3 additions & 2 deletions component/componenttest/nop_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/consumer"
)

Expand All @@ -30,7 +31,7 @@ func NewNopReceiverCreateSettings() component.ReceiverCreateSettings {
}

type nopReceiverConfig struct {
component.ReceiverConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
config.ReceiverSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
}

// NewNopReceiverFactory returns a component.ReceiverFactory that constructs nop receivers.
Expand All @@ -39,7 +40,7 @@ func NewNopReceiverFactory() component.ReceiverFactory {
"nop",
func() component.ReceiverConfig {
return &nopReceiverConfig{
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID("nop")),
ReceiverSettings: config.NewReceiverSettings(component.NewID("nop")),
}
},
component.WithTracesReceiver(createTracesReceiver, component.StabilityLevelStable),
Expand Down
3 changes: 2 additions & 1 deletion component/componenttest/nop_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/stretchr/testify/require"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/consumer/consumertest"
)

Expand All @@ -30,7 +31,7 @@ func TestNewNopReceiverFactory(t *testing.T) {
require.NotNil(t, factory)
assert.Equal(t, component.Type("nop"), factory.Type())
cfg := factory.CreateDefaultConfig()
assert.Equal(t, &nopReceiverConfig{ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID("nop"))}, cfg)
assert.Equal(t, &nopReceiverConfig{ReceiverSettings: config.NewReceiverSettings(component.NewID("nop"))}, cfg)

traces, err := factory.CreateTracesReceiver(context.Background(), NewNopReceiverCreateSettings(), cfg, consumertest.NewNop())
require.NoError(t, err)
Expand Down
17 changes: 17 additions & 0 deletions component/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,26 @@ package component // import "go.opentelemetry.io/collector/component"
import (
"context"

"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/consumer"
)

// ExporterConfig is the configuration of a component.Exporter. Specific extensions must implement
// this interface and must embed config.ExporterSettings struct or a struct that extends it.
type ExporterConfig interface {
identifiable
validatable

privateConfigExporter()
}

// UnmarshalExporterConfig helper function to unmarshal an ExporterConfig.
// It checks if the config implements confmap.Unmarshaler and uses that if available,
// otherwise uses Map.UnmarshalExact, erroring if a field is nonexistent.
func UnmarshalExporterConfig(conf *confmap.Conf, cfg ExporterConfig) error {
return unmarshal(conf, cfg)
}

// Exporter exports telemetry data from the collector to a destination.
type Exporter interface {
Component
Expand Down
69 changes: 0 additions & 69 deletions component/exporter_config.go

This file was deleted.

Loading

0 comments on commit 0a8f738

Please sign in to comment.