Skip to content

Commit

Permalink
Move configmodels to config (open-telemetry#2808)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Mar 26, 2021
1 parent 4daf2a1 commit e7c74eb
Show file tree
Hide file tree
Showing 189 changed files with 925 additions and 933 deletions.
4 changes: 2 additions & 2 deletions cmd/mdatagen/metrics.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
package {{ .Package }}

import (
"go.opentelemetry.io/collector/config/configmodels"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/consumer/pdata"
)

// Type is the component type name.
const Type configmodels.Type = "{{ .Name }}"
const Type config.Type = "{{ .Name }}"

// MetricIntf is an interface to generically interact with generated metric.
type MetricIntf interface {
Expand Down
6 changes: 3 additions & 3 deletions cmd/schemagen/schemagen/cli_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package schemagen

import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configmodels"
"go.opentelemetry.io/collector/config"
)

// createAllSchemaFiles creates config yaml schema files for all registered components
Expand All @@ -27,8 +27,8 @@ func createAllSchemaFiles(components component.Factories, env env) {
}
}

func getAllConfigs(components component.Factories) []configmodels.NamedEntity {
var cfgs []configmodels.NamedEntity
func getAllConfigs(components component.Factories) []config.NamedEntity {
var cfgs []config.NamedEntity
for _, f := range components.Receivers {
cfgs = append(cfgs, f.CreateDefaultConfig())
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/schemagen/schemagen/cli_single.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"os"

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

// createSingleSchemaFile creates a config schema yaml file for a single component
Expand All @@ -32,8 +32,8 @@ func createSingleSchemaFile(components component.Factories, componentType, compo
createSchemaFile(cfg, env)
}

func getConfig(components component.Factories, componentType, componentName string) (configmodels.NamedEntity, error) {
t := configmodels.Type(componentName)
func getConfig(components component.Factories, componentType, componentName string) (config.NamedEntity, error) {
t := config.Type(componentName)
switch componentType {
case "receiver":
c := components.Receivers[t]
Expand Down
4 changes: 2 additions & 2 deletions component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"github.com/spf13/viper"

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

// Component is either a receiver, exporter, processor or extension.
Expand Down Expand Up @@ -76,7 +76,7 @@ const (
// Factory interface must be implemented by all component factories.
type Factory interface {
// Type gets the type of the component created by this factory.
Type() configmodels.Type
Type() config.Type
}

// ConfigUnmarshaler interface is an optional interface that if implemented by a Factory,
Expand Down
14 changes: 7 additions & 7 deletions component/componenttest/nop_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenthelper"
"go.opentelemetry.io/collector/config/configmodels"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/consumer/consumertest"
)
Expand All @@ -35,13 +35,13 @@ func NewNopExporterFactory() component.ExporterFactory {
}

// Type gets the type of the Exporter config created by this factory.
func (f *nopExporterFactory) Type() configmodels.Type {
func (f *nopExporterFactory) Type() config.Type {
return "nop"
}

// CreateDefaultConfig creates the default configuration for the Exporter.
func (f *nopExporterFactory) CreateDefaultConfig() configmodels.Exporter {
return &configmodels.ExporterSettings{
func (f *nopExporterFactory) CreateDefaultConfig() config.Exporter {
return &config.ExporterSettings{
TypeVal: f.Type(),
}
}
Expand All @@ -50,7 +50,7 @@ func (f *nopExporterFactory) CreateDefaultConfig() configmodels.Exporter {
func (f *nopExporterFactory) CreateTracesExporter(
_ context.Context,
_ component.ExporterCreateParams,
_ configmodels.Exporter,
_ config.Exporter,
) (component.TracesExporter, error) {
return nopExporterInstance, nil
}
Expand All @@ -59,7 +59,7 @@ func (f *nopExporterFactory) CreateTracesExporter(
func (f *nopExporterFactory) CreateMetricsExporter(
_ context.Context,
_ component.ExporterCreateParams,
_ configmodels.Exporter,
_ config.Exporter,
) (component.MetricsExporter, error) {
return nopExporterInstance, nil
}
Expand All @@ -68,7 +68,7 @@ func (f *nopExporterFactory) CreateMetricsExporter(
func (f *nopExporterFactory) CreateLogsExporter(
_ context.Context,
_ component.ExporterCreateParams,
_ configmodels.Exporter,
_ config.Exporter,
) (component.LogsExporter, error) {
return nopExporterInstance, nil
}
Expand Down
6 changes: 3 additions & 3 deletions component/componenttest/nop_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ import (
"github.com/stretchr/testify/require"

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

func TestNewNopExporterFactory(t *testing.T) {
factory := NewNopExporterFactory()
require.NotNil(t, factory)
assert.Equal(t, configmodels.Type("nop"), factory.Type())
assert.Equal(t, config.Type("nop"), factory.Type())
cfg := factory.CreateDefaultConfig()
assert.Equal(t, &configmodels.ExporterSettings{TypeVal: factory.Type()}, cfg)
assert.Equal(t, &config.ExporterSettings{TypeVal: factory.Type()}, cfg)

traces, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateParams{}, cfg)
require.NoError(t, err)
Expand Down
10 changes: 5 additions & 5 deletions component/componenttest/nop_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

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

// nopExtensionFactory is factory for nopExtension.
Expand All @@ -33,13 +33,13 @@ func NewNopExtensionFactory() component.ExtensionFactory {
}

// Type gets the type of the Extension config created by this factory.
func (f *nopExtensionFactory) Type() configmodels.Type {
func (f *nopExtensionFactory) Type() config.Type {
return "nop"
}

// CreateDefaultConfig creates the default configuration for the Extension.
func (f *nopExtensionFactory) CreateDefaultConfig() configmodels.Extension {
return &configmodels.ExtensionSettings{
func (f *nopExtensionFactory) CreateDefaultConfig() config.Extension {
return &config.ExtensionSettings{
TypeVal: f.Type(),
}
}
Expand All @@ -48,7 +48,7 @@ func (f *nopExtensionFactory) CreateDefaultConfig() configmodels.Extension {
func (f *nopExtensionFactory) CreateExtension(
_ context.Context,
_ component.ExtensionCreateParams,
_ configmodels.Extension,
_ config.Extension,
) (component.Extension, error) {
return nopExtensionInstance, nil
}
Expand Down
6 changes: 3 additions & 3 deletions component/componenttest/nop_extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ import (
"github.com/stretchr/testify/require"

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

func TestNewNopExtensionFactory(t *testing.T) {
factory := NewNopExtensionFactory()
require.NotNil(t, factory)
assert.Equal(t, configmodels.Type("nop"), factory.Type())
assert.Equal(t, config.Type("nop"), factory.Type())
cfg := factory.CreateDefaultConfig()
assert.Equal(t, &configmodels.ExtensionSettings{TypeVal: factory.Type()}, cfg)
assert.Equal(t, &config.ExtensionSettings{TypeVal: factory.Type()}, cfg)

traces, err := factory.CreateExtension(context.Background(), component.ExtensionCreateParams{}, cfg)
require.NoError(t, err)
Expand Down
8 changes: 4 additions & 4 deletions component/componenttest/nop_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package componenttest

import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configmodels"
"go.opentelemetry.io/collector/config"
)

// nopHost mocks a receiver.ReceiverHost for test purposes.
Expand All @@ -31,14 +31,14 @@ func NewNopHost() component.Host {

func (nh *nopHost) ReportFatalError(_ error) {}

func (nh *nopHost) GetFactory(_ component.Kind, _ configmodels.Type) component.Factory {
func (nh *nopHost) GetFactory(_ component.Kind, _ config.Type) component.Factory {
return nil
}

func (nh *nopHost) GetExtensions() map[configmodels.NamedEntity]component.Extension {
func (nh *nopHost) GetExtensions() map[config.NamedEntity]component.Extension {
return nil
}

func (nh *nopHost) GetExporters() map[configmodels.DataType]map[configmodels.NamedEntity]component.Exporter {
func (nh *nopHost) GetExporters() map[config.DataType]map[config.NamedEntity]component.Exporter {
return nil
}
14 changes: 7 additions & 7 deletions component/componenttest/nop_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenthelper"
"go.opentelemetry.io/collector/config/configmodels"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/consumer/consumertest"
)
Expand All @@ -35,13 +35,13 @@ func NewNopProcessorFactory() component.ProcessorFactory {
}

// Type gets the type of the Processor config created by this factory.
func (f *nopProcessorFactory) Type() configmodels.Type {
func (f *nopProcessorFactory) Type() config.Type {
return "nop"
}

// CreateDefaultConfig creates the default configuration for the Processor.
func (f *nopProcessorFactory) CreateDefaultConfig() configmodels.Processor {
return &configmodels.ProcessorSettings{
func (f *nopProcessorFactory) CreateDefaultConfig() config.Processor {
return &config.ProcessorSettings{
TypeVal: f.Type(),
}
}
Expand All @@ -50,7 +50,7 @@ func (f *nopProcessorFactory) CreateDefaultConfig() configmodels.Processor {
func (f *nopProcessorFactory) CreateTracesProcessor(
_ context.Context,
_ component.ProcessorCreateParams,
_ configmodels.Processor,
_ config.Processor,
_ consumer.Traces,
) (component.TracesProcessor, error) {
return nopProcessorInstance, nil
Expand All @@ -60,7 +60,7 @@ func (f *nopProcessorFactory) CreateTracesProcessor(
func (f *nopProcessorFactory) CreateMetricsProcessor(
_ context.Context,
_ component.ProcessorCreateParams,
_ configmodels.Processor,
_ config.Processor,
_ consumer.Metrics,
) (component.MetricsProcessor, error) {
return nopProcessorInstance, nil
Expand All @@ -70,7 +70,7 @@ func (f *nopProcessorFactory) CreateMetricsProcessor(
func (f *nopProcessorFactory) CreateLogsProcessor(
_ context.Context,
_ component.ProcessorCreateParams,
_ configmodels.Processor,
_ config.Processor,
_ consumer.Logs,
) (component.LogsProcessor, error) {
return nopProcessorInstance, nil
Expand Down
6 changes: 3 additions & 3 deletions component/componenttest/nop_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ import (
"github.com/stretchr/testify/require"

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

func TestNewNopProcessorFactory(t *testing.T) {
factory := NewNopProcessorFactory()
require.NotNil(t, factory)
assert.Equal(t, configmodels.Type("nop"), factory.Type())
assert.Equal(t, config.Type("nop"), factory.Type())
cfg := factory.CreateDefaultConfig()
assert.Equal(t, &configmodels.ProcessorSettings{TypeVal: factory.Type()}, cfg)
assert.Equal(t, &config.ProcessorSettings{TypeVal: factory.Type()}, cfg)

traces, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateParams{}, cfg, consumertest.NewTracesNop())
require.NoError(t, err)
Expand Down
14 changes: 7 additions & 7 deletions component/componenttest/nop_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

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

Expand All @@ -34,13 +34,13 @@ func NewNopReceiverFactory() component.ReceiverFactory {
}

// Type gets the type of the Receiver config created by this factory.
func (f *nopReceiverFactory) Type() configmodels.Type {
func (f *nopReceiverFactory) Type() config.Type {
return "nop"
}

// CreateDefaultConfig creates the default configuration for the Receiver.
func (f *nopReceiverFactory) CreateDefaultConfig() configmodels.Receiver {
return &configmodels.ReceiverSettings{
func (f *nopReceiverFactory) CreateDefaultConfig() config.Receiver {
return &config.ReceiverSettings{
TypeVal: f.Type(),
}
}
Expand All @@ -49,7 +49,7 @@ func (f *nopReceiverFactory) CreateDefaultConfig() configmodels.Receiver {
func (f *nopReceiverFactory) CreateTracesReceiver(
_ context.Context,
_ component.ReceiverCreateParams,
_ configmodels.Receiver,
_ config.Receiver,
_ consumer.Traces,
) (component.TracesReceiver, error) {
return nopReceiverInstance, nil
Expand All @@ -59,7 +59,7 @@ func (f *nopReceiverFactory) CreateTracesReceiver(
func (f *nopReceiverFactory) CreateMetricsReceiver(
_ context.Context,
_ component.ReceiverCreateParams,
_ configmodels.Receiver,
_ config.Receiver,
_ consumer.Metrics,
) (component.MetricsReceiver, error) {
return nopReceiverInstance, nil
Expand All @@ -69,7 +69,7 @@ func (f *nopReceiverFactory) CreateMetricsReceiver(
func (f *nopReceiverFactory) CreateLogsReceiver(
_ context.Context,
_ component.ReceiverCreateParams,
_ configmodels.Receiver,
_ config.Receiver,
_ consumer.Logs,
) (component.LogsReceiver, error) {
return nopReceiverInstance, nil
Expand Down
6 changes: 3 additions & 3 deletions component/componenttest/nop_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ import (
"github.com/stretchr/testify/require"

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

func TestNewNopReceiverFactory(t *testing.T) {
factory := NewNopReceiverFactory()
require.NotNil(t, factory)
assert.Equal(t, configmodels.Type("nop"), factory.Type())
assert.Equal(t, config.Type("nop"), factory.Type())
cfg := factory.CreateDefaultConfig()
assert.Equal(t, &configmodels.ReceiverSettings{TypeVal: factory.Type()}, cfg)
assert.Equal(t, &config.ReceiverSettings{TypeVal: factory.Type()}, cfg)

traces, err := factory.CreateTracesReceiver(context.Background(), component.ReceiverCreateParams{}, cfg, consumertest.NewTracesNop())
require.NoError(t, err)
Expand Down
6 changes: 3 additions & 3 deletions component/componenttest/shutdown_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import (
"go.uber.org/zap"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configerror"
"go.opentelemetry.io/collector/config/configmodels"
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/internal/testdata"
)

func verifyTraceProcessorDoesntProduceAfterShutdown(t *testing.T, factory component.ProcessorFactory, cfg configmodels.Processor) {
func verifyTraceProcessorDoesntProduceAfterShutdown(t *testing.T, factory component.ProcessorFactory, cfg config.Processor) {
// Create a processor and output its produce to a sink.
nextSink := new(consumertest.TracesSink)
processor, err := factory.CreateTracesProcessor(
Expand Down Expand Up @@ -62,7 +62,7 @@ func verifyTraceProcessorDoesntProduceAfterShutdown(t *testing.T, factory compon
assert.EqualValues(t, generatedCount, nextSink.SpansCount())
}

func VerifyProcessorShutdown(t *testing.T, factory component.ProcessorFactory, cfg configmodels.Processor) {
func VerifyProcessorShutdown(t *testing.T, factory component.ProcessorFactory, cfg config.Processor) {
verifyTraceProcessorDoesntProduceAfterShutdown(t, factory, cfg)
// TODO: add metrics and logs verification.
// TODO: add other shutdown verifications.
Expand Down
Loading

0 comments on commit e7c74eb

Please sign in to comment.