From f6ee81bb537c1f87be970797ccb4d647ff99d1b0 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Fri, 26 Jan 2024 16:59:24 +0100 Subject: [PATCH 01/13] [component] Add MustType constructor for component.Type --- component/componenttest/nop_host_test.go | 2 +- .../otelprometheuschecker_test.go | 8 +- component/config.go | 42 + component/config_test.go | 220 +++ component/identifiable.go | 21 +- component/identifiable_test.go | 9 +- config/configauth/configauth_test.go | 14 +- config/configgrpc/configgrpc_test.go | 41 +- config/confighttp/confighttp_test.go | 51 +- connector/connector_test.go | 65 +- connector/connectortest/connector.go | 8 +- connector/connectortest/connector_test.go | 4 +- connector/logs_router_test.go | 8 +- connector/metrics_router_test.go | 8 +- connector/traces_router_test.go | 8 +- exporter/debugexporter/factory.go | 7 +- exporter/exporter_test.go | 42 +- exporter/exporterhelper/common_test.go | 15 +- .../internal/persistent_queue.go | 2 +- .../internal/persistent_queue_test.go | 10 +- exporter/exporterhelper/logs_test.go | 6 +- exporter/exporterhelper/metrics_test.go | 6 +- exporter/exporterhelper/obsexporter_test.go | 2 +- exporter/exporterhelper/obsreport_test.go | 2 +- exporter/exporterhelper/queue_sender_test.go | 26 +- exporter/exporterhelper/retry_sender_test.go | 12 +- exporter/exporterhelper/traces_test.go | 6 +- .../exportertest/contract_checker_test.go | 4 +- exporter/exportertest/nop_exporter.go | 8 +- exporter/exportertest/nop_exporter_test.go | 4 +- exporter/loggingexporter/factory.go | 7 +- exporter/otlpexporter/config_test.go | 2 +- extension/extension_test.go | 30 +- extension/extensiontest/nop_extension.go | 8 +- extension/extensiontest/nop_extension_test.go | 4 +- .../extensiontest/statuswatcher_extension.go | 2 +- .../statuswatcher_extension_test.go | 2 +- internal/memorylimiter/memorylimiter_test.go | 2 +- .../sharedcomponent/sharedcomponent_test.go | 2 +- otelcol/command_components_test.go | 12 +- otelcol/config_test.go | 76 +- .../configunmarshaler/configs_test.go | 16 +- otelcol/otelcoltest/config_test.go | 28 +- otelcol/otelcoltest/nop_factories_test.go | 22 +- processor/batchprocessor/metrics_test.go | 2 +- .../memorylimiter_test.go | 2 +- processor/processor_test.go | 42 +- processor/processorhelper/obsreport_test.go | 2 +- processor/processortest/nop_processor.go | 8 +- processor/processortest/nop_processor_test.go | 4 +- .../processortest/unhealthy_processor.go | 2 +- .../processortest/unhealthy_processor_test.go | 2 +- .../otlpreceiver/internal/logs/otlp_test.go | 2 +- .../internal/metrics/otlp_test.go | 2 +- .../otlpreceiver/internal/trace/otlp_test.go | 2 +- receiver/otlpreceiver/otlp_test.go | 2 +- receiver/receiver_test.go | 42 +- receiver/receiverhelper/obsreport_test.go | 2 +- .../receivertest/contract_checker_test.go | 2 +- receiver/receivertest/nop_receiver.go | 8 +- receiver/receivertest/nop_receiver_test.go | 6 +- receiver/scraperhelper/obsreport.go | 2 +- receiver/scraperhelper/obsreport_test.go | 4 +- receiver/scraperhelper/scraper.go | 2 +- .../scraperhelper/scrapercontroller_test.go | 8 +- receiver/scraperhelper/settings_test.go | 3 +- service/config_test.go | 20 +- service/extensions/extensions_test.go | 57 +- service/internal/components/loggers.go | 8 +- service/internal/graph/graph_test.go | 1433 +++++++++-------- service/internal/graph/nodes.go | 6 +- service/internal/graph/zpages.go | 2 +- .../testcomponents/example_connector.go | 4 +- .../testcomponents/example_exporter.go | 9 +- .../testcomponents/example_processor.go | 2 +- .../testcomponents/example_receiver.go | 2 +- .../internal/testcomponents/example_router.go | 2 +- .../testcomponents/example_router_test.go | 12 +- service/pipelines/config_test.go | 22 +- service/service_test.go | 73 +- 80 files changed, 1488 insertions(+), 1189 deletions(-) diff --git a/component/componenttest/nop_host_test.go b/component/componenttest/nop_host_test.go index 1bcb92d1744..fa03c31e217 100644 --- a/component/componenttest/nop_host_test.go +++ b/component/componenttest/nop_host_test.go @@ -21,5 +21,5 @@ func TestNewNopHost(t *testing.T) { nh.ReportFatalError(errors.New("TestError")) assert.Nil(t, nh.GetExporters()) // nolint: staticcheck assert.Nil(t, nh.GetExtensions()) - assert.Nil(t, nh.GetFactory(component.KindReceiver, "test")) + assert.Nil(t, nh.GetFactory(component.KindReceiver, component.MustType("test"))) } diff --git a/component/componenttest/otelprometheuschecker_test.go b/component/componenttest/otelprometheuschecker_test.go index 159122547bc..ff95747dc9d 100644 --- a/component/componenttest/otelprometheuschecker_test.go +++ b/component/componenttest/otelprometheuschecker_test.go @@ -36,10 +36,10 @@ func TestPromChecker(t *testing.T) { pc, err := newStubPromChecker() require.NoError(t, err) - scraper := component.NewID("fakeScraper") - receiver := component.NewID("fakeReceiver") - processor := component.NewID("fakeProcessor") - exporter := component.NewID("fakeExporter") + scraper := component.NewID(component.MustType("fakeScraper")) + receiver := component.NewID(component.MustType("fakeReceiver")) + processor := component.NewID(component.MustType("fakeProcessor")) + exporter := component.NewID(component.MustType("fakeExporter")) transport := "fakeTransport" assert.NoError(t, diff --git a/component/config.go b/component/config.go index f34f04b8db7..6bccbab61fb 100644 --- a/component/config.go +++ b/component/config.go @@ -4,7 +4,9 @@ package component // import "go.opentelemetry.io/collector/component" import ( + "fmt" "reflect" + "regexp" "go.uber.org/multierr" @@ -110,6 +112,46 @@ func callValidateIfPossible(v reflect.Value) error { // Type is the component type as it is used in the config. type Type string +var _ fmt.Stringer = (Type)("") + +// String returns the string representation of the type. +func (t Type) String() string { + return string(t) +} + +// typeRegexp is used to validate the type of a component. +// A type must start with an ASCII alphabetic character and +// can only contain ASCII alphanumeric characters and '_'. +var typeRegexp = regexp.MustCompile(`^[a-zA-Z][0-9a-zA-Z_]*$`) + +// newType creates a type. It returns an error if the type is invalid. +// A type must +// - have at least one character, +// - start with an ASCII alphabetic character and +// - can only contain ASCII alphanumeric characters, '-' and '_'. +func newType(ty string) (Type, error) { + if len(ty) == 0 { + return Type(""), fmt.Errorf("id must not be empty") + } + if !typeRegexp.MatchString(ty) { + return Type(""), fmt.Errorf("invalid character(s) in type") + } + return Type(ty), nil +} + +// MustType creates a type. It panics if the type is invalid. +// A type must +// - have at least one character, +// - start with an ASCII alphabetic character and +// - can only contain ASCII alphanumeric characters, '-' and '_'. +func MustType(strType string) Type { + ty, err := newType(strType) + if err != nil { + panic(err) + } + return ty +} + // DataType is a special Type that represents the data types supported by the collector. We currently support // collecting metrics, traces and logs, this can expand in the future. type DataType = Type diff --git a/component/config_test.go b/component/config_test.go index b42328678ea..c93312eba57 100644 --- a/component/config_test.go +++ b/component/config_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) type configChildStruct struct { @@ -194,3 +195,222 @@ func TestValidateConfig(t *testing.T) { }) } } + +func TestNewType(t *testing.T) { + tests := []struct { + name string + shouldErr bool + }{ + {name: "active_directory_ds"}, + {name: "aerospike"}, + {name: "alertmanager"}, + {name: "alibabacloud_logservice"}, + {name: "apache"}, + {name: "apachespark"}, + {name: "asapclient"}, + {name: "attributes"}, + {name: "awscloudwatch"}, + {name: "awscloudwatchlogs"}, + {name: "awscloudwatchmetrics"}, + {name: "awscontainerinsightreceiver"}, + {name: "awsecscontainermetrics"}, + {name: "awsemf"}, + {name: "awsfirehose"}, + {name: "awskinesis"}, + {name: "awsproxy"}, + {name: "awss3"}, + {name: "awsxray"}, + {name: "azureblob"}, + {name: "azuredataexplorer"}, + {name: "azureeventhub"}, + {name: "azuremonitor"}, + {name: "basicauth"}, + {name: "batch"}, + {name: "bearertokenauth"}, + {name: "bigip"}, + {name: "carbon"}, + {name: "cassandra"}, + {name: "chrony"}, + {name: "clickhouse"}, + {name: "cloudflare"}, + {name: "cloudfoundry"}, + {name: "collectd"}, + {name: "configschema"}, + {name: "coralogix"}, + {name: "couchdb"}, + {name: "count"}, + {name: "cumulativetodelta"}, + {name: "datadog"}, + {name: "dataset"}, + {name: "db_storage"}, + {name: "debug"}, + {name: "deltatorate"}, + {name: "demo"}, + {name: "docker_observer"}, + {name: "docker_stats"}, + {name: "dynatrace"}, + {name: "ecs_observer"}, + {name: "ecs_task_observer"}, + {name: "elasticsearch"}, + {name: "exceptions"}, + {name: "experimental_metricsgeneration"}, + {name: "expvar"}, + {name: "f5cloud"}, + {name: "failover"}, + {name: "file"}, + {name: "filelog"}, + {name: "filestats"}, + {name: "file_storage"}, + {name: "filter"}, + {name: "flinkmetrics"}, + {name: "fluentforward"}, + {name: "forward"}, + {name: "githubgen"}, + {name: "gitprovider"}, + {name: "golden"}, + {name: "googlecloud"}, + {name: "googlecloudpubsub"}, + {name: "googlecloudspanner"}, + {name: "googlemanagedprometheus"}, + {name: "groupbyattrs"}, + {name: "groupbytrace"}, + {name: "haproxy"}, + {name: "headers_setter"}, + {name: "health_check"}, + {name: "honeycombmarker"}, + {name: "hostmetrics"}, + {name: "host_observer"}, + {name: "httpcheck"}, + {name: "http_forwarder"}, + {name: "iis"}, + {name: "influxdb"}, + {name: "instana"}, + {name: "interval"}, + {name: "jaeger"}, + {name: "jaeger_encoding"}, + {name: "jaegerremotesampling"}, + {name: "jmx"}, + {name: "journald"}, + {name: "json_log_encoding"}, + {name: "k8sattributes"}, + {name: "k8s_cluster"}, + {name: "k8s_events"}, + {name: "k8sobjects"}, + {name: "k8s_observer"}, + {name: "kafka"}, + {name: "kafkametrics"}, + {name: "kinetica"}, + {name: "kubeletstats"}, + {name: "loadbalancing"}, + {name: "logging"}, + {name: "logicmonitor"}, + {name: "logstransform"}, + {name: "logzio"}, + {name: "loki"}, + {name: "mdatagen"}, + {name: "memcached"}, + {name: "memory_ballast"}, + {name: "memory_limiter"}, + {name: "metricstransform"}, + {name: "mezmo"}, + {name: "mongodb"}, + {name: "mongodbatlas"}, + {name: "mysql"}, + {name: "namedpipe"}, + {name: "nginx"}, + {name: "nsxt"}, + {name: "oauth2client"}, + {name: "oidc"}, + {name: "opamp"}, + {name: "opampsupervisor"}, + {name: "opencensus"}, + {name: "opensearch"}, + {name: "oracledb"}, + {name: "osquery"}, + {name: "otelarrow"}, + {name: "otelcontribcol"}, + {name: "oteltestbedcol"}, + {name: "otlp"}, + {name: "otlp_encoding"}, + {name: "otlphttp"}, + {name: "otlpjsonfile"}, + {name: "ottl"}, + {name: "podman_stats"}, + {name: "postgresql"}, + {name: "pprof"}, + {name: "probabilistic_sampler"}, + {name: "prometheus"}, + {name: "prometheusremotewrite"}, + {name: "prometheus_simple"}, + {name: "pulsar"}, + {name: "purefa"}, + {name: "purefb"}, + {name: "rabbitmq"}, + {name: "receiver_creator"}, + {name: "redaction"}, + {name: "redis"}, + {name: "remotetap"}, + {name: "resource"}, + {name: "resourcedetection"}, + {name: "riak"}, + {name: "routing"}, + {name: "saphana"}, + {name: "sapm"}, + {name: "schema"}, + {name: "sentry"}, + {name: "servicegraph"}, + {name: "signalfx"}, + {name: "sigv4auth"}, + {name: "skywalking"}, + {name: "snmp"}, + {name: "snowflake"}, + {name: "solace"}, + {name: "solarwindsapmsettings"}, + {name: "span"}, + {name: "spanmetrics"}, + {name: "splunkenterprise"}, + {name: "splunk_hec"}, + {name: "sqlquery"}, + {name: "sqlserver"}, + {name: "sshcheck"}, + {name: "statsd"}, + {name: "sumologic"}, + {name: "syslog"}, + {name: "tail_sampling"}, + {name: "tcplog"}, + {name: "telemetrygen"}, + {name: "tencentcloud_logservice"}, + {name: "text_encoding"}, + {name: "transform"}, + {name: "udplog"}, + {name: "vcenter"}, + {name: "wavefront"}, + {name: "webhookevent"}, + {name: "windowseventlog"}, + {name: "windowsperfcounters"}, + {name: "zipkin"}, + {name: "zipkin_encoding"}, + {name: "zookeeper"}, + {name: "zpages"}, + + {name: "", shouldErr: true}, + {name: "contains spaces", shouldErr: true}, + {name: "contains-dashes", shouldErr: true}, + {name: "0startswithnumber", shouldErr: true}, + {name: "contains/slash", shouldErr: true}, + {name: "contains:colon", shouldErr: true}, + {name: "contains#hash", shouldErr: true}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ty, err := newType(tt.name) + if tt.shouldErr { + assert.Error(t, err) + } else { + require.NoError(t, err) + assert.Equal(t, tt.name, ty.String()) + } + }) + } +} diff --git a/component/identifiable.go b/component/identifiable.go index 331c348fe59..f57aa10c1af 100644 --- a/component/identifiable.go +++ b/component/identifiable.go @@ -51,34 +51,41 @@ func (id ID) MarshalText() (text []byte, err error) { func (id *ID) UnmarshalText(text []byte) error { idStr := string(text) items := strings.SplitN(idStr, typeAndNameSeparator, 2) + var typeStr, nameStr string if len(items) >= 1 { - id.typeVal = Type(strings.TrimSpace(items[0])) + typeStr = strings.TrimSpace(items[0]) } - if len(items) == 1 && id.typeVal == "" { + if len(items) == 1 && typeStr == "" { return errors.New("id must not be empty") } - if id.typeVal == "" { + if typeStr == "" { return fmt.Errorf("in %q id: the part before %s should not be empty", idStr, typeAndNameSeparator) } if len(items) > 1 { // "name" part is present. - id.nameVal = strings.TrimSpace(items[1]) - if id.nameVal == "" { + nameStr = strings.TrimSpace(items[1]) + if nameStr == "" { return fmt.Errorf("in %q id: the part after %s should not be empty", idStr, typeAndNameSeparator) } } + var err error + if id.typeVal, err = newType(typeStr); err != nil { + return fmt.Errorf("in %q id: %w", idStr, err) + } + id.nameVal = nameStr + return nil } // String returns the ID string representation as "type[/name]" format. func (id ID) String() string { if id.nameVal == "" { - return string(id.typeVal) + return id.typeVal.String() } - return string(id.typeVal) + typeAndNameSeparator + id.nameVal + return id.typeVal.String() + typeAndNameSeparator + id.nameVal } diff --git a/component/identifiable_test.go b/component/identifiable_test.go index 6b55375adc3..e7786cf2bcf 100644 --- a/component/identifiable_test.go +++ b/component/identifiable_test.go @@ -10,13 +10,14 @@ import ( ) func TestMarshalText(t *testing.T) { - id := NewIDWithName("test", "name") + id := NewIDWithName(MustType("test"), "name") got, err := id.MarshalText() assert.NoError(t, err) assert.Equal(t, id.String(), string(got)) } func TestUnmarshalText(t *testing.T) { + validType := MustType("valid_type") var testCases = []struct { idStr string expectedErr bool @@ -24,15 +25,15 @@ func TestUnmarshalText(t *testing.T) { }{ { idStr: "valid_type", - expectedID: ID{typeVal: "valid_type", nameVal: ""}, + expectedID: ID{typeVal: validType, nameVal: ""}, }, { idStr: "valid_type/valid_name", - expectedID: ID{typeVal: "valid_type", nameVal: "valid_name"}, + expectedID: ID{typeVal: validType, nameVal: "valid_name"}, }, { idStr: " valid_type / valid_name ", - expectedID: ID{typeVal: "valid_type", nameVal: "valid_name"}, + expectedID: ID{typeVal: validType, nameVal: "valid_name"}, }, { idStr: "/valid_name", diff --git a/config/configauth/configauth_test.go b/config/configauth/configauth_test.go index 19497c2e7c5..0c85f6d25de 100644 --- a/config/configauth/configauth_test.go +++ b/config/configauth/configauth_test.go @@ -13,6 +13,8 @@ import ( "go.opentelemetry.io/collector/extension/auth" ) +var mockID = component.NewID(component.MustType("mock")) + func TestGetServer(t *testing.T) { testCases := []struct { desc string @@ -34,10 +36,10 @@ func TestGetServer(t *testing.T) { t.Run(tC.desc, func(t *testing.T) { // prepare cfg := &Authentication{ - AuthenticatorID: component.NewID("mock"), + AuthenticatorID: mockID, } ext := map[component.ID]component.Component{ - component.NewID("mock"): tC.authenticator, + mockID: tC.authenticator, } authenticator, err := cfg.GetServerAuthenticator(ext) @@ -56,7 +58,7 @@ func TestGetServer(t *testing.T) { func TestGetServerFails(t *testing.T) { cfg := &Authentication{ - AuthenticatorID: component.NewID("does-not-exist"), + AuthenticatorID: component.NewID(component.MustType("does_not_exist")), } authenticator, err := cfg.GetServerAuthenticator(map[component.ID]component.Component{}) @@ -85,10 +87,10 @@ func TestGetClient(t *testing.T) { t.Run(tC.desc, func(t *testing.T) { // prepare cfg := &Authentication{ - AuthenticatorID: component.NewID("mock"), + AuthenticatorID: mockID, } ext := map[component.ID]component.Component{ - component.NewID("mock"): tC.authenticator, + mockID: tC.authenticator, } authenticator, err := cfg.GetClientAuthenticator(ext) @@ -107,7 +109,7 @@ func TestGetClient(t *testing.T) { func TestGetClientFails(t *testing.T) { cfg := &Authentication{ - AuthenticatorID: component.NewID("does-not-exist"), + AuthenticatorID: component.NewID(component.MustType("does_not_exist")), } authenticator, err := cfg.GetClientAuthenticator(map[component.ID]component.Component{}) assert.ErrorIs(t, err, errAuthenticatorNotFound) diff --git a/config/configgrpc/configgrpc_test.go b/config/configgrpc/configgrpc_test.go index a3c6b089b93..7cdd5552655 100644 --- a/config/configgrpc/configgrpc_test.go +++ b/config/configgrpc/configgrpc_test.go @@ -50,8 +50,15 @@ func init() { balancer.Register(testBalancerBuilder{}) } +var ( + componentID = component.NewID(component.MustType("component")) + testAuthID = component.NewID(component.MustType("testauth")) + mockID = component.NewID(component.MustType("mock")) + doesntExistID = component.NewID(component.MustType("doesntexist")) +) + func TestDefaultGrpcClientSettings(t *testing.T) { - tt, err := componenttest.SetupTelemetry(component.NewID("component")) + tt, err := componenttest.SetupTelemetry(componentID) require.NoError(t, err) t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) @@ -66,7 +73,7 @@ func TestDefaultGrpcClientSettings(t *testing.T) { } func TestAllGrpcClientSettings(t *testing.T) { - tt, err := componenttest.SetupTelemetry(component.NewID("component")) + tt, err := componenttest.SetupTelemetry(componentID) require.NoError(t, err) t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) @@ -96,11 +103,11 @@ func TestAllGrpcClientSettings(t *testing.T) { WaitForReady: true, BalancerName: "round_robin", Authority: "pseudo-authority", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("testauth")}, + Auth: &configauth.Authentication{AuthenticatorID: testAuthID}, }, host: &mockHost{ ext: map[component.ID]component.Component{ - component.NewID("testauth"): &authtest.MockClient{}, + testAuthID: &authtest.MockClient{}, }, }, }, @@ -125,11 +132,11 @@ func TestAllGrpcClientSettings(t *testing.T) { WaitForReady: true, BalancerName: "round_robin", Authority: "pseudo-authority", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("testauth")}, + Auth: &configauth.Authentication{AuthenticatorID: testAuthID}, }, host: &mockHost{ ext: map[component.ID]component.Component{ - component.NewID("testauth"): &authtest.MockClient{}, + testAuthID: &authtest.MockClient{}, }, }, }, @@ -154,11 +161,11 @@ func TestAllGrpcClientSettings(t *testing.T) { WaitForReady: true, BalancerName: "configgrpc_balancer_test", Authority: "pseudo-authority", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("testauth")}, + Auth: &configauth.Authentication{AuthenticatorID: testAuthID}, }, host: &mockHost{ ext: map[component.ID]component.Component{ - component.NewID("testauth"): &authtest.MockClient{}, + testAuthID: &authtest.MockClient{}, }, }, }, @@ -223,11 +230,11 @@ func TestGrpcServerAuthSettings(t *testing.T) { }, } gss.Auth = &configauth.Authentication{ - AuthenticatorID: component.NewID("mock"), + AuthenticatorID: mockID, } host := &mockHost{ ext: map[component.ID]component.Component{ - component.NewID("mock"): auth.NewServer(), + mockID: auth.NewServer(), }, } srv, err := gss.ToServer(host, componenttest.NewNopTelemetrySettings()) @@ -236,7 +243,7 @@ func TestGrpcServerAuthSettings(t *testing.T) { } func TestGRPCClientSettingsError(t *testing.T) { - tt, err := componenttest.SetupTelemetry(component.NewID("component")) + tt, err := componenttest.SetupTelemetry(componentID) require.NoError(t, err) t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) @@ -303,7 +310,7 @@ func TestGRPCClientSettingsError(t *testing.T) { err: "failed to resolve authenticator \"doesntexist\": authenticator not found", settings: GRPCClientSettings{ Endpoint: "localhost:1234", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("doesntexist")}, + Auth: &configauth.Authentication{AuthenticatorID: doesntExistID}, }, host: &mockHost{ext: map[component.ID]component.Component{}}, }, @@ -311,7 +318,7 @@ func TestGRPCClientSettingsError(t *testing.T) { err: "no extensions configuration available", settings: GRPCClientSettings{ Endpoint: "localhost:1234", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("doesntexist")}, + Auth: &configauth.Authentication{AuthenticatorID: doesntExistID}, }, host: &mockHost{}, }, @@ -359,7 +366,7 @@ func TestGRPCClientSettingsError(t *testing.T) { } func TestUseSecure(t *testing.T) { - tt, err := componenttest.SetupTelemetry(component.NewID("component")) + tt, err := componenttest.SetupTelemetry(componentID) require.NoError(t, err) t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) @@ -498,7 +505,7 @@ func TestGRPCServerSettings_ToListener_Error(t *testing.T) { } func TestHttpReception(t *testing.T) { - tt, err := componenttest.SetupTelemetry(component.NewID("component")) + tt, err := componenttest.SetupTelemetry(componentID) require.NoError(t, err) t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) @@ -650,7 +657,7 @@ func TestReceiveOnUnixDomainSocket(t *testing.T) { if runtime.GOOS == "windows" { t.Skip("skipping test on windows") } - tt, err := componenttest.SetupTelemetry(component.NewID("component")) + tt, err := componenttest.SetupTelemetry(componentID) require.NoError(t, err) t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) @@ -879,7 +886,7 @@ func TestClientInfoInterceptors(t *testing.T) { }, } - tt, err := componenttest.SetupTelemetry(component.NewID("component")) + tt, err := componenttest.SetupTelemetry(componentID) require.NoError(t, err) defer func() { require.NoError(t, tt.Shutdown(context.Background())) diff --git a/config/confighttp/confighttp_test.go b/config/confighttp/confighttp_test.go index a44406f372e..68f7d7f24f2 100644 --- a/config/confighttp/confighttp_test.go +++ b/config/confighttp/confighttp_test.go @@ -42,10 +42,17 @@ func (c *customRoundTripper) RoundTrip(_ *http.Request) (*http.Response, error) return nil, nil } +var ( + testAuthID = component.NewID(component.MustType("testauth")) + mockID = component.NewID(component.MustType("mock")) + dummyID = component.NewID(component.MustType("dummy")) + nonExistingID = component.NewID(component.MustType("nonexisting")) +) + func TestAllHTTPClientSettings(t *testing.T) { host := &mockHost{ ext: map[component.ID]component.Component{ - component.NewID("testauth"): &authtest.MockClient{ResultRoundTripper: &customRoundTripper{}}, + testAuthID: &authtest.MockClient{ResultRoundTripper: &customRoundTripper{}}, }, } @@ -187,7 +194,7 @@ func TestAllHTTPClientSettings(t *testing.T) { func TestPartialHTTPClientSettings(t *testing.T) { host := &mockHost{ ext: map[component.ID]component.Component{ - component.NewID("testauth"): &authtest.MockClient{ResultRoundTripper: &customRoundTripper{}}, + testAuthID: &authtest.MockClient{ResultRoundTripper: &customRoundTripper{}}, }, } @@ -329,7 +336,7 @@ func TestHTTPClientSettingsError(t *testing.T) { err: "failed to resolve authenticator \"dummy\": authenticator not found", settings: HTTPClientSettings{ Endpoint: "https://localhost:1234/v1/traces", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("dummy")}, + Auth: &configauth.Authentication{AuthenticatorID: dummyID}, }, }, } @@ -357,7 +364,7 @@ func TestHTTPClientSettingWithAuthConfig(t *testing.T) { shouldErr: false, host: &mockHost{ ext: map[component.ID]component.Component{ - component.NewID("mock"): &authtest.MockClient{ + mockID: &authtest.MockClient{ ResultRoundTripper: &customRoundTripper{}, }, }, @@ -367,12 +374,12 @@ func TestHTTPClientSettingWithAuthConfig(t *testing.T) { name: "with_auth_configuration_and_no_extension", settings: HTTPClientSettings{ Endpoint: "localhost:1234", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("dummy")}, + Auth: &configauth.Authentication{AuthenticatorID: dummyID}, }, shouldErr: true, host: &mockHost{ ext: map[component.ID]component.Component{ - component.NewID("mock"): &authtest.MockClient{ResultRoundTripper: &customRoundTripper{}}, + mockID: &authtest.MockClient{ResultRoundTripper: &customRoundTripper{}}, }, }, }, @@ -380,7 +387,7 @@ func TestHTTPClientSettingWithAuthConfig(t *testing.T) { name: "with_auth_configuration_and_no_extension_map", settings: HTTPClientSettings{ Endpoint: "localhost:1234", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("dummy")}, + Auth: &configauth.Authentication{AuthenticatorID: dummyID}, }, shouldErr: true, host: componenttest.NewNopHost(), @@ -389,12 +396,12 @@ func TestHTTPClientSettingWithAuthConfig(t *testing.T) { name: "with_auth_configuration_has_extension", settings: HTTPClientSettings{ Endpoint: "localhost:1234", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("mock")}, + Auth: &configauth.Authentication{AuthenticatorID: mockID}, }, shouldErr: false, host: &mockHost{ ext: map[component.ID]component.Component{ - component.NewID("mock"): &authtest.MockClient{ResultRoundTripper: &customRoundTripper{}}, + mockID: &authtest.MockClient{ResultRoundTripper: &customRoundTripper{}}, }, }, }, @@ -402,13 +409,13 @@ func TestHTTPClientSettingWithAuthConfig(t *testing.T) { name: "with_auth_configuration_has_extension_and_headers", settings: HTTPClientSettings{ Endpoint: "localhost:1234", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("mock")}, + Auth: &configauth.Authentication{AuthenticatorID: mockID}, Headers: map[string]configopaque.String{"foo": "bar"}, }, shouldErr: false, host: &mockHost{ ext: map[component.ID]component.Component{ - component.NewID("mock"): &authtest.MockClient{ResultRoundTripper: &customRoundTripper{}}, + mockID: &authtest.MockClient{ResultRoundTripper: &customRoundTripper{}}, }, }, }, @@ -416,13 +423,13 @@ func TestHTTPClientSettingWithAuthConfig(t *testing.T) { name: "with_auth_configuration_has_extension_and_compression", settings: HTTPClientSettings{ Endpoint: "localhost:1234", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("mock")}, + Auth: &configauth.Authentication{AuthenticatorID: mockID}, Compression: configcompression.Gzip, }, shouldErr: false, host: &mockHost{ ext: map[component.ID]component.Component{ - component.NewID("mock"): &authtest.MockClient{ResultRoundTripper: &customRoundTripper{}}, + mockID: &authtest.MockClient{ResultRoundTripper: &customRoundTripper{}}, }, }, }, @@ -430,12 +437,12 @@ func TestHTTPClientSettingWithAuthConfig(t *testing.T) { name: "with_auth_configuration_has_err_extension", settings: HTTPClientSettings{ Endpoint: "localhost:1234", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("mock")}, + Auth: &configauth.Authentication{AuthenticatorID: mockID}, }, shouldErr: true, host: &mockHost{ ext: map[component.ID]component.Component{ - component.NewID("mock"): &authtest.MockClient{ + mockID: &authtest.MockClient{ ResultRoundTripper: &customRoundTripper{}, MustError: true}, }, }, @@ -862,13 +869,13 @@ func TestHttpCorsWithSettings(t *testing.T) { AllowedOrigins: []string{"*"}, }, Auth: &configauth.Authentication{ - AuthenticatorID: component.NewID("mock"), + AuthenticatorID: mockID, }, } host := &mockHost{ ext: map[component.ID]component.Component{ - component.NewID("mock"): auth.NewServer( + mockID: auth.NewServer( auth.WithServerAuthenticate(func(ctx context.Context, headers map[string][]string) (context.Context, error) { return ctx, errors.New("Settings failed") }), @@ -1128,13 +1135,13 @@ func TestServerAuth(t *testing.T) { hss := HTTPServerSettings{ Endpoint: "localhost:0", Auth: &configauth.Authentication{ - AuthenticatorID: component.NewID("mock"), + AuthenticatorID: mockID, }, } host := &mockHost{ ext: map[component.ID]component.Component{ - component.NewID("mock"): auth.NewServer( + mockID: auth.NewServer( auth.WithServerAuthenticate(func(ctx context.Context, headers map[string][]string) (context.Context, error) { authCalled = true return ctx, nil @@ -1162,7 +1169,7 @@ func TestServerAuth(t *testing.T) { func TestInvalidServerAuth(t *testing.T) { hss := HTTPServerSettings{ Auth: &configauth.Authentication{ - AuthenticatorID: component.NewID("non-existing"), + AuthenticatorID: nonExistingID, }, } @@ -1176,12 +1183,12 @@ func TestFailedServerAuth(t *testing.T) { hss := HTTPServerSettings{ Endpoint: "localhost:0", Auth: &configauth.Authentication{ - AuthenticatorID: component.NewID("mock"), + AuthenticatorID: mockID, }, } host := &mockHost{ ext: map[component.ID]component.Component{ - component.NewID("mock"): auth.NewServer( + mockID: auth.NewServer( auth.WithServerAuthenticate(func(ctx context.Context, headers map[string][]string) (context.Context, error) { return ctx, errors.New("Settings failed") }), diff --git a/connector/connector_test.go b/connector/connector_test.go index a2dc1305dfb..86a337c3934 100644 --- a/connector/connector_test.go +++ b/connector/connector_test.go @@ -17,15 +17,17 @@ import ( "go.opentelemetry.io/collector/consumer/consumertest" ) +var ( + testType = component.MustType("test") + testID = component.NewIDWithName(component.MustType("type"), "name") +) + func TestNewFactoryNoOptions(t *testing.T) { - const typeStr = "test" defaultCfg := struct{}{} - factory := NewFactory(typeStr, func() component.Config { return &defaultCfg }) - assert.EqualValues(t, typeStr, factory.Type()) + factory := NewFactory(testType, func() component.Config { return &defaultCfg }) + assert.EqualValues(t, testType, factory.Type()) assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) - testID := component.NewIDWithName("type", "name") - _, err := factory.CreateTracesToTraces(context.Background(), CreateSettings{ID: testID}, &defaultCfg, nil) assert.Equal(t, err, errDataTypes(testID, component.DataTypeTraces, component.DataTypeTraces)) _, err = factory.CreateTracesToMetrics(context.Background(), CreateSettings{ID: testID}, &defaultCfg, nil) @@ -49,17 +51,14 @@ func TestNewFactoryNoOptions(t *testing.T) { } func TestNewFactoryWithSameTypes(t *testing.T) { - const typeStr = "test" defaultCfg := struct{}{} - factory := NewFactory(typeStr, func() component.Config { return &defaultCfg }, + factory := NewFactory(testType, func() component.Config { return &defaultCfg }, WithTracesToTraces(createTracesToTraces, component.StabilityLevelAlpha), WithMetricsToMetrics(createMetricsToMetrics, component.StabilityLevelBeta), WithLogsToLogs(createLogsToLogs, component.StabilityLevelUnmaintained)) - assert.EqualValues(t, typeStr, factory.Type()) + assert.EqualValues(t, testType, factory.Type()) assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) - testID := component.NewIDWithName("type", "name") - assert.Equal(t, component.StabilityLevelAlpha, factory.TracesToTracesStability()) _, err := factory.CreateTracesToTraces(context.Background(), CreateSettings{ID: testID}, &defaultCfg, nil) assert.NoError(t, err) @@ -89,20 +88,17 @@ func TestNewFactoryWithSameTypes(t *testing.T) { } func TestNewFactoryWithTranslateTypes(t *testing.T) { - const typeStr = "test" defaultCfg := struct{}{} - factory := NewFactory(typeStr, func() component.Config { return &defaultCfg }, + factory := NewFactory(testType, func() component.Config { return &defaultCfg }, WithTracesToMetrics(createTracesToMetrics, component.StabilityLevelDevelopment), WithTracesToLogs(createTracesToLogs, component.StabilityLevelAlpha), WithMetricsToTraces(createMetricsToTraces, component.StabilityLevelBeta), WithMetricsToLogs(createMetricsToLogs, component.StabilityLevelStable), WithLogsToTraces(createLogsToTraces, component.StabilityLevelDeprecated), WithLogsToMetrics(createLogsToMetrics, component.StabilityLevelUnmaintained)) - assert.EqualValues(t, typeStr, factory.Type()) + assert.EqualValues(t, testType, factory.Type()) assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) - testID := component.NewIDWithName("type", "name") - _, err := factory.CreateTracesToTraces(context.Background(), CreateSettings{ID: testID}, &defaultCfg, nil) assert.Equal(t, err, errDataTypes(testID, component.DataTypeTraces, component.DataTypeTraces)) _, err = factory.CreateMetricsToMetrics(context.Background(), CreateSettings{ID: testID}, &defaultCfg, nil) @@ -136,9 +132,8 @@ func TestNewFactoryWithTranslateTypes(t *testing.T) { } func TestNewFactoryWithAllTypes(t *testing.T) { - const typeStr = "test" defaultCfg := struct{}{} - factory := NewFactory(typeStr, func() component.Config { return &defaultCfg }, + factory := NewFactory(testType, func() component.Config { return &defaultCfg }, WithTracesToTraces(createTracesToTraces, component.StabilityLevelAlpha), WithTracesToMetrics(createTracesToMetrics, component.StabilityLevelDevelopment), WithTracesToLogs(createTracesToLogs, component.StabilityLevelAlpha), @@ -148,7 +143,7 @@ func TestNewFactoryWithAllTypes(t *testing.T) { WithLogsToTraces(createLogsToTraces, component.StabilityLevelDeprecated), WithLogsToMetrics(createLogsToMetrics, component.StabilityLevelUnmaintained), WithLogsToLogs(createLogsToLogs, component.StabilityLevelUnmaintained)) - assert.EqualValues(t, typeStr, factory.Type()) + assert.EqualValues(t, testType, factory.Type()) assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) assert.Equal(t, component.StabilityLevelAlpha, factory.TracesToTracesStability()) @@ -189,8 +184,8 @@ func TestMakeFactoryMap(t *testing.T) { out map[component.Type]Factory } - p1 := NewFactory("p1", nil) - p2 := NewFactory("p2", nil) + p1 := NewFactory(component.MustType("p1"), nil) + p2 := NewFactory(component.MustType("p2"), nil) testCases := []testCase{ { name: "different names", @@ -202,7 +197,7 @@ func TestMakeFactoryMap(t *testing.T) { }, { name: "same name", - in: []Factory{p1, p2, NewFactory("p1", nil)}, + in: []Factory{p1, p2, NewFactory(component.MustType("p1"), nil)}, }, } @@ -223,9 +218,9 @@ func TestMakeFactoryMap(t *testing.T) { func TestBuilder(t *testing.T) { defaultCfg := struct{}{} factories, err := MakeFactoryMap([]Factory{ - NewFactory("err", nil), + NewFactory(component.MustType("err"), nil), NewFactory( - "all", + component.MustType("all"), func() component.Config { return &defaultCfg }, WithTracesToTraces(createTracesToTraces, component.StabilityLevelDevelopment), WithTracesToMetrics(createTracesToMetrics, component.StabilityLevelDevelopment), @@ -247,28 +242,28 @@ func TestBuilder(t *testing.T) { }{ { name: "unknown", - id: component.NewID("unknown"), + id: component.NewID(component.MustType("unknown")), err: func(_, _ component.DataType) string { return "connector factory not available for: \"unknown\"" }, }, { name: "err", - id: component.NewID("err"), + id: component.NewID(component.MustType("err")), err: func(expType, rcvType component.DataType) string { return fmt.Sprintf("connector \"err\" cannot connect from %s to %s: telemetry type is not supported", expType, rcvType) }, }, { name: "all", - id: component.NewID("all"), + id: component.NewID(component.MustType("all")), err: func(_, _ component.DataType) string { return "" }, }, { name: "all/named", - id: component.NewIDWithName("all", "named"), + id: component.NewIDWithName(component.MustType("all"), "named"), err: func(_, _ component.DataType) string { return "" }, @@ -366,7 +361,7 @@ func TestBuilderMissingConfig(t *testing.T) { defaultCfg := struct{}{} factories, err := MakeFactoryMap([]Factory{ NewFactory( - "all", + component.MustType("all"), func() component.Config { return &defaultCfg }, WithTracesToTraces(createTracesToTraces, component.StabilityLevelDevelopment), WithTracesToMetrics(createTracesToMetrics, component.StabilityLevelDevelopment), @@ -383,7 +378,7 @@ func TestBuilderMissingConfig(t *testing.T) { require.NoError(t, err) bErr := NewBuilder(map[component.ID]component.Config{}, factories) - missingID := component.NewIDWithName("all", "missing") + missingID := component.NewIDWithName(component.MustType("all"), "missing") t2t, err := bErr.CreateTracesToTraces(context.Background(), createSettings(missingID), nil) assert.EqualError(t, err, "connector \"all/missing\" is not configured") @@ -423,17 +418,17 @@ func TestBuilderMissingConfig(t *testing.T) { } func TestBuilderGetters(t *testing.T) { - factories, err := MakeFactoryMap([]Factory{NewFactory("foo", nil)}...) + factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustType("foo"), nil)}...) require.NoError(t, err) - cfgs := map[component.ID]component.Config{component.NewID("foo"): struct{}{}} + cfgs := map[component.ID]component.Config{component.NewID(component.MustType("foo")): struct{}{}} b := NewBuilder(cfgs, factories) - assert.True(t, b.IsConfigured(component.NewID("foo"))) - assert.False(t, b.IsConfigured(component.NewID("bar"))) + assert.True(t, b.IsConfigured(component.NewID(component.MustType("foo")))) + assert.False(t, b.IsConfigured(component.NewID(component.MustType("bar")))) - assert.NotNil(t, b.Factory(component.NewID("foo").Type())) - assert.Nil(t, b.Factory(component.NewID("bar").Type())) + assert.NotNil(t, b.Factory(component.NewID(component.MustType("foo")).Type())) + assert.Nil(t, b.Factory(component.NewID(component.MustType("bar")).Type())) } var nopInstance = &nopConnector{ diff --git a/connector/connectortest/connector.go b/connector/connectortest/connector.go index 137a353423c..c1eb2456f39 100644 --- a/connector/connectortest/connector.go +++ b/connector/connectortest/connector.go @@ -13,7 +13,7 @@ import ( "go.opentelemetry.io/collector/consumer/consumertest" ) -const typeStr = "nop" +var nopType = component.MustType("nop") // NewNopCreateSettings returns a new nop settings for Create* functions. func NewNopCreateSettings() connector.CreateSettings { @@ -28,7 +28,7 @@ type nopConfig struct{} // NewNopFactory returns a connector.Factory that constructs nop processors. func NewNopFactory() connector.Factory { return connector.NewFactory( - "nop", + nopType, func() component.Config { return &nopConfig{} }, @@ -93,8 +93,8 @@ func NewNopBuilder() *connector.Builder { // Use a different ID than receivertest and exportertest to avoid ambiguous // configuration scenarios. Ambiguous IDs are detected in the 'otelcol' package, // but lower level packages such as 'service' assume that IDs are disambiguated. - connID := component.NewIDWithName(typeStr, "conn") + connID := component.NewIDWithName(nopType, "conn") return connector.NewBuilder( map[component.ID]component.Config{connID: nopFactory.CreateDefaultConfig()}, - map[component.Type]connector.Factory{typeStr: nopFactory}) + map[component.Type]connector.Factory{nopType: nopFactory}) } diff --git a/connector/connectortest/connector_test.go b/connector/connectortest/connector_test.go index d8db553d9a1..e2fca0d67a2 100644 --- a/connector/connectortest/connector_test.go +++ b/connector/connectortest/connector_test.go @@ -21,7 +21,7 @@ import ( func TestNewNopConnectorFactory(t *testing.T) { factory := NewNopFactory() require.NotNil(t, factory) - assert.Equal(t, component.Type("nop"), factory.Type()) + assert.Equal(t, component.MustType("nop"), factory.Type()) cfg := factory.CreateDefaultConfig() assert.Equal(t, &nopConfig{}, cfg) @@ -87,7 +87,7 @@ func TestNewNopBuilder(t *testing.T) { factory := NewNopFactory() cfg := factory.CreateDefaultConfig() set := NewNopCreateSettings() - set.ID = component.NewIDWithName(typeStr, "conn") + set.ID = component.NewIDWithName(nopType, "conn") tracesToTraces, err := factory.CreateTracesToTraces(context.Background(), set, cfg, consumertest.NewNop()) require.NoError(t, err) diff --git a/connector/logs_router_test.go b/connector/logs_router_test.go index 3fd0d701cc0..d84f0d36814 100644 --- a/connector/logs_router_test.go +++ b/connector/logs_router_test.go @@ -48,7 +48,7 @@ func fuzzLogs(numIDs, numCons, numLogs int) func(*testing.T) { // If any consumer is mutating, the router must report mutating for i := 0; i < numCons; i++ { - allIDs = append(allIDs, component.NewIDWithName("sink", strconv.Itoa(numCons))) + allIDs = append(allIDs, component.NewIDWithName(component.MustType("sink"), strconv.Itoa(numCons))) // Random chance for each consumer to be mutating if (numCons+numLogs+i)%4 == 0 { allCons = append(allCons, &mutatingLogsSink{LogsSink: new(consumertest.LogsSink)}) @@ -108,8 +108,8 @@ func TestLogsRouterConsumers(t *testing.T) { ctx := context.Background() ld := testdata.GenerateLogs(1) - fooID := component.NewID("foo") - barID := component.NewID("bar") + fooID := component.NewID(component.MustType("foo")) + barID := component.NewID(component.MustType("bar")) foo := new(consumertest.LogsSink) bar := new(consumertest.LogsSink) @@ -150,7 +150,7 @@ func TestLogsRouterConsumers(t *testing.T) { assert.Nil(t, none) assert.Error(t, err) - fake, err := r.Consumer(component.NewID("fake")) + fake, err := r.Consumer(component.NewID(component.MustType("fake"))) assert.Nil(t, fake) assert.Error(t, err) } diff --git a/connector/metrics_router_test.go b/connector/metrics_router_test.go index 69126b04ada..9a059d1444e 100644 --- a/connector/metrics_router_test.go +++ b/connector/metrics_router_test.go @@ -48,7 +48,7 @@ func fuzzMetrics(numIDs, numCons, numMetrics int) func(*testing.T) { // If any consumer is mutating, the router must report mutating for i := 0; i < numCons; i++ { - allIDs = append(allIDs, component.NewIDWithName("sink", strconv.Itoa(numCons))) + allIDs = append(allIDs, component.NewIDWithName(component.MustType("sink"), strconv.Itoa(numCons))) // Random chance for each consumer to be mutating if (numCons+numMetrics+i)%4 == 0 { allCons = append(allCons, &mutatingMetricsSink{MetricsSink: new(consumertest.MetricsSink)}) @@ -108,8 +108,8 @@ func TestMetricsRouterConsumers(t *testing.T) { ctx := context.Background() md := testdata.GenerateMetrics(1) - fooID := component.NewID("foo") - barID := component.NewID("bar") + fooID := component.NewID(component.MustType("foo")) + barID := component.NewID(component.MustType("bar")) foo := new(consumertest.MetricsSink) bar := new(consumertest.MetricsSink) @@ -150,7 +150,7 @@ func TestMetricsRouterConsumers(t *testing.T) { assert.Nil(t, none) assert.Error(t, err) - fake, err := r.Consumer(component.NewID("fake")) + fake, err := r.Consumer(component.NewID(component.MustType("fake"))) assert.Nil(t, fake) assert.Error(t, err) } diff --git a/connector/traces_router_test.go b/connector/traces_router_test.go index a89a687f9bc..134cb058a2a 100644 --- a/connector/traces_router_test.go +++ b/connector/traces_router_test.go @@ -48,7 +48,7 @@ func fuzzTraces(numIDs, numCons, numTraces int) func(*testing.T) { // If any consumer is mutating, the router must report mutating for i := 0; i < numCons; i++ { - allIDs = append(allIDs, component.NewIDWithName("sink", strconv.Itoa(numCons))) + allIDs = append(allIDs, component.NewIDWithName(component.MustType("sink"), strconv.Itoa(numCons))) // Random chance for each consumer to be mutating if (numCons+numTraces+i)%4 == 0 { allCons = append(allCons, &mutatingTracesSink{TracesSink: new(consumertest.TracesSink)}) @@ -108,8 +108,8 @@ func TestTracesRouterConsumer(t *testing.T) { ctx := context.Background() td := testdata.GenerateTraces(1) - fooID := component.NewID("foo") - barID := component.NewID("bar") + fooID := component.NewID(component.MustType("foo")) + barID := component.NewID(component.MustType("bar")) foo := new(consumertest.TracesSink) bar := new(consumertest.TracesSink) @@ -150,7 +150,7 @@ func TestTracesRouterConsumer(t *testing.T) { assert.Nil(t, none) assert.Error(t, err) - fake, err := r.Consumer(component.NewID("fake")) + fake, err := r.Consumer(component.NewID(component.MustType("fake"))) assert.Nil(t, fake) assert.Error(t, err) } diff --git a/exporter/debugexporter/factory.go b/exporter/debugexporter/factory.go index 5264c42866c..3d4baa22e36 100644 --- a/exporter/debugexporter/factory.go +++ b/exporter/debugexporter/factory.go @@ -13,9 +13,10 @@ import ( "go.opentelemetry.io/collector/exporter/internal/common" ) +// The value of "type" key in configuration. +var componentType = component.MustType("debug") + const ( - // The value of "type" key in configuration. - typeStr = "debug" defaultSamplingInitial = 2 defaultSamplingThereafter = 500 ) @@ -23,7 +24,7 @@ const ( // NewFactory creates a factory for Debug exporter func NewFactory() exporter.Factory { return exporter.NewFactory( - typeStr, + componentType, createDefaultConfig, exporter.WithTraces(createTracesExporter, metadata.TracesStability), exporter.WithMetrics(createMetricsExporter, metadata.MetricsStability), diff --git a/exporter/exporter_test.go b/exporter/exporter_test.go index eafa2c03f47..51e29c6f6cc 100644 --- a/exporter/exporter_test.go +++ b/exporter/exporter_test.go @@ -16,12 +16,12 @@ import ( ) func TestNewFactory(t *testing.T) { - const typeStr = "test" + var testType = component.MustType("test") defaultCfg := struct{}{} factory := NewFactory( - typeStr, + testType, func() component.Config { return &defaultCfg }) - assert.EqualValues(t, typeStr, factory.Type()) + assert.EqualValues(t, testType, factory.Type()) assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) _, err := factory.CreateTracesExporter(context.Background(), CreateSettings{}, &defaultCfg) assert.Error(t, err) @@ -32,15 +32,15 @@ func TestNewFactory(t *testing.T) { } func TestNewFactoryWithOptions(t *testing.T) { - const typeStr = "test" + var testType = component.MustType("test") defaultCfg := struct{}{} factory := NewFactory( - typeStr, + testType, func() component.Config { return &defaultCfg }, WithTraces(createTraces, component.StabilityLevelDevelopment), WithMetrics(createMetrics, component.StabilityLevelAlpha), WithLogs(createLogs, component.StabilityLevelDeprecated)) - assert.EqualValues(t, typeStr, factory.Type()) + assert.EqualValues(t, testType, factory.Type()) assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) assert.Equal(t, component.StabilityLevelDevelopment, factory.TracesExporterStability()) @@ -63,8 +63,8 @@ func TestMakeFactoryMap(t *testing.T) { out map[component.Type]Factory } - p1 := NewFactory("p1", nil) - p2 := NewFactory("p2", nil) + p1 := NewFactory(component.MustType("p1"), nil) + p2 := NewFactory(component.MustType("p2"), nil) testCases := []testCase{ { name: "different names", @@ -76,7 +76,7 @@ func TestMakeFactoryMap(t *testing.T) { }, { name: "same name", - in: []Factory{p1, p2, NewFactory("p1", nil)}, + in: []Factory{p1, p2, NewFactory(component.MustType("p1"), nil)}, }, } @@ -97,9 +97,9 @@ func TestMakeFactoryMap(t *testing.T) { func TestBuilder(t *testing.T) { defaultCfg := struct{}{} factories, err := MakeFactoryMap([]Factory{ - NewFactory("err", nil), + NewFactory(component.MustType("err"), nil), NewFactory( - "all", + component.MustType("all"), func() component.Config { return &defaultCfg }, WithTraces(createTraces, component.StabilityLevelDevelopment), WithMetrics(createMetrics, component.StabilityLevelAlpha), @@ -115,21 +115,21 @@ func TestBuilder(t *testing.T) { }{ { name: "unknown", - id: component.NewID("unknown"), + id: component.NewID(component.MustType("unknown")), err: "exporter factory not available for: \"unknown\"", }, { name: "err", - id: component.NewID("err"), + id: component.NewID(component.MustType("err")), err: "telemetry type is not supported", }, { name: "all", - id: component.NewID("all"), + id: component.NewID(component.MustType("all")), }, { name: "all/named", - id: component.NewIDWithName("all", "named"), + id: component.NewIDWithName(component.MustType("all"), "named"), }, } @@ -172,7 +172,7 @@ func TestBuilderMissingConfig(t *testing.T) { defaultCfg := struct{}{} factories, err := MakeFactoryMap([]Factory{ NewFactory( - "all", + component.MustType("all"), func() component.Config { return &defaultCfg }, WithTraces(createTraces, component.StabilityLevelDevelopment), WithMetrics(createMetrics, component.StabilityLevelAlpha), @@ -183,7 +183,7 @@ func TestBuilderMissingConfig(t *testing.T) { require.NoError(t, err) bErr := NewBuilder(map[component.ID]component.Config{}, factories) - missingID := component.NewIDWithName("all", "missing") + missingID := component.NewIDWithName(component.MustType("all"), "missing") te, err := bErr.CreateTraces(context.Background(), createSettings(missingID)) assert.EqualError(t, err, "exporter \"all/missing\" is not configured") @@ -199,14 +199,14 @@ func TestBuilderMissingConfig(t *testing.T) { } func TestBuilderFactory(t *testing.T) { - factories, err := MakeFactoryMap([]Factory{NewFactory("foo", nil)}...) + factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustType("foo"), nil)}...) require.NoError(t, err) - cfgs := map[component.ID]component.Config{component.NewID("foo"): struct{}{}} + cfgs := map[component.ID]component.Config{component.NewID(component.MustType("foo")): struct{}{}} b := NewBuilder(cfgs, factories) - assert.NotNil(t, b.Factory(component.NewID("foo").Type())) - assert.Nil(t, b.Factory(component.NewID("bar").Type())) + assert.NotNil(t, b.Factory(component.NewID(component.MustType("foo")).Type())) + assert.Nil(t, b.Factory(component.NewID(component.MustType("bar")).Type())) } var nopInstance = &nopExporter{ diff --git a/exporter/exporterhelper/common_test.go b/exporter/exporterhelper/common_test.go index bbc009fb7ae..9f40472b7e7 100644 --- a/exporter/exporterhelper/common_test.go +++ b/exporter/exporterhelper/common_test.go @@ -22,7 +22,8 @@ import ( ) var ( - defaultID = component.NewID("test") + defaultType = component.MustType("test") + defaultID = component.NewID(defaultType) defaultSettings = func() exporter.CreateSettings { set := exportertest.NewNopCreateSettings() set.ID = defaultID @@ -35,11 +36,11 @@ func newNoopObsrepSender(_ *ObsReport) requestSender { } func TestBaseExporter(t *testing.T) { - be, err := newBaseExporter(defaultSettings, "", false, nil, nil, newNoopObsrepSender) + be, err := newBaseExporter(defaultSettings, defaultType, false, nil, nil, newNoopObsrepSender) require.NoError(t, err) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) require.NoError(t, be.Shutdown(context.Background())) - be, err = newBaseExporter(defaultSettings, "", true, nil, nil, newNoopObsrepSender) + be, err = newBaseExporter(defaultSettings, defaultType, true, nil, nil, newNoopObsrepSender) require.NoError(t, err) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) require.NoError(t, be.Shutdown(context.Background())) @@ -48,7 +49,7 @@ func TestBaseExporter(t *testing.T) { func TestBaseExporterWithOptions(t *testing.T) { want := errors.New("my error") be, err := newBaseExporter( - defaultSettings, "", false, nil, nil, newNoopObsrepSender, + defaultSettings, defaultType, false, nil, nil, newNoopObsrepSender, WithStart(func(ctx context.Context, host component.Host) error { return want }), WithShutdown(func(ctx context.Context) error { return want }), WithTimeout(NewDefaultTimeoutSettings()), @@ -68,12 +69,12 @@ func checkStatus(t *testing.T, sd sdktrace.ReadOnlySpan, err error) { } func TestQueueRetryOptionsWithRequestExporter(t *testing.T) { - bs, err := newBaseExporter(exportertest.NewNopCreateSettings(), "", true, nil, nil, newNoopObsrepSender, + bs, err := newBaseExporter(exportertest.NewNopCreateSettings(), defaultType, true, nil, nil, newNoopObsrepSender, WithRetry(configretry.NewDefaultBackOffConfig())) require.Nil(t, err) require.True(t, bs.requestExporter) require.Panics(t, func() { - _, _ = newBaseExporter(exportertest.NewNopCreateSettings(), "", true, nil, nil, newNoopObsrepSender, + _, _ = newBaseExporter(exportertest.NewNopCreateSettings(), defaultType, true, nil, nil, newNoopObsrepSender, WithRetry(configretry.NewDefaultBackOffConfig()), WithQueue(NewDefaultQueueSettings())) }) } @@ -84,7 +85,7 @@ func TestBaseExporterLogging(t *testing.T) { set.Logger = zap.New(logger) rCfg := configretry.NewDefaultBackOffConfig() rCfg.Enabled = false - bs, err := newBaseExporter(set, "", true, nil, nil, newNoopObsrepSender, WithRetry(rCfg)) + bs, err := newBaseExporter(set, defaultType, true, nil, nil, newNoopObsrepSender, WithRetry(rCfg)) require.Nil(t, err) require.True(t, bs.requestExporter) sendErr := bs.send(context.Background(), newErrorRequest()) diff --git a/exporter/exporterhelper/internal/persistent_queue.go b/exporter/exporterhelper/internal/persistent_queue.go index 0a6629cb87e..9f23ab6a98c 100644 --- a/exporter/exporterhelper/internal/persistent_queue.go +++ b/exporter/exporterhelper/internal/persistent_queue.go @@ -511,7 +511,7 @@ func toStorageClient(ctx context.Context, storageID component.ID, host component return nil, errWrongExtensionType } - return storageExt.GetClient(ctx, component.KindExporter, ownerID, string(signal)) + return storageExt.GetClient(ctx, component.KindExporter, ownerID, signal.String()) } func getItemKey(index uint64) string { diff --git a/exporter/exporterhelper/internal/persistent_queue_test.go b/exporter/exporterhelper/internal/persistent_queue_test.go index 166449bdb25..e10e70a4c04 100644 --- a/exporter/exporterhelper/internal/persistent_queue_test.go +++ b/exporter/exporterhelper/internal/persistent_queue_test.go @@ -293,14 +293,14 @@ func TestToStorageClient(t *testing.T) { for _, tC := range testCases { t.Run(tC.desc, func(t *testing.T) { - storageID := component.NewIDWithName("file_storage", strconv.Itoa(tC.storageIndex)) + storageID := component.NewIDWithName(component.MustType("file_storage"), strconv.Itoa(tC.storageIndex)) var extensions = map[component.ID]component.Component{} for i := 0; i < tC.numStorages; i++ { - extensions[component.NewIDWithName("file_storage", strconv.Itoa(i))] = NewMockStorageExtension(tC.getClientError) + extensions[component.NewIDWithName(component.MustType("file_storage"), strconv.Itoa(i))] = NewMockStorageExtension(tC.getClientError) } host := &mockHost{ext: extensions} - ownerID := component.NewID("foo_exporter") + ownerID := component.NewID(component.MustType("foo_exporter")) // execute client, err := toStorageClient(context.Background(), storageID, host, ownerID, component.DataTypeTraces) @@ -318,7 +318,7 @@ func TestToStorageClient(t *testing.T) { } func TestInvalidStorageExtensionType(t *testing.T) { - storageID := component.NewIDWithName("extension", "extension") + storageID := component.NewIDWithName(component.MustType("extension"), "extension") // make a test extension factory := extensiontest.NewNopFactory() @@ -330,7 +330,7 @@ func TestInvalidStorageExtensionType(t *testing.T) { storageID: extension, } host := &mockHost{ext: extensions} - ownerID := component.NewID("foo_exporter") + ownerID := component.NewID(component.MustType("foo_exporter")) // execute client, err := toStorageClient(context.Background(), storageID, host, ownerID, component.DataTypeTraces) diff --git a/exporter/exporterhelper/logs_test.go b/exporter/exporterhelper/logs_test.go index 92bbd48edac..a867beda7a8 100644 --- a/exporter/exporterhelper/logs_test.go +++ b/exporter/exporterhelper/logs_test.go @@ -37,7 +37,7 @@ const ( ) var ( - fakeLogsExporterName = component.NewIDWithName("fake_logs_exporter", "with_name") + fakeLogsExporterName = component.NewIDWithName(component.MustType("fake_logs_exporter"), "with_name") fakeLogsExporterConfig = struct{}{} ) @@ -157,12 +157,12 @@ func TestLogsRequestExporter_Default_ExportError(t *testing.T) { func TestLogsExporter_WithPersistentQueue(t *testing.T) { qCfg := NewDefaultQueueSettings() - storageID := component.NewIDWithName("file_storage", "storage") + storageID := component.NewIDWithName(component.MustType("file_storage"), "storage") qCfg.StorageID = &storageID rCfg := configretry.NewDefaultBackOffConfig() ts := consumertest.LogsSink{} set := exportertest.NewNopCreateSettings() - set.ID = component.NewIDWithName("test_logs", "with_persistent_queue") + set.ID = component.NewIDWithName(component.MustType("test_logs"), "with_persistent_queue") te, err := NewLogsExporter(context.Background(), set, &fakeLogsExporterConfig, ts.ConsumeLogs, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) diff --git a/exporter/exporterhelper/metrics_test.go b/exporter/exporterhelper/metrics_test.go index 770ea801e48..84677313481 100644 --- a/exporter/exporterhelper/metrics_test.go +++ b/exporter/exporterhelper/metrics_test.go @@ -37,7 +37,7 @@ const ( ) var ( - fakeMetricsExporterName = component.NewIDWithName("fake_metrics_exporter", "with_name") + fakeMetricsExporterName = component.NewIDWithName(component.MustType("fake_metrics_exporter"), "with_name") fakeMetricsExporterConfig = struct{}{} ) @@ -158,12 +158,12 @@ func TestMetricsRequestExporter_Default_ExportError(t *testing.T) { func TestMetricsExporter_WithPersistentQueue(t *testing.T) { qCfg := NewDefaultQueueSettings() - storageID := component.NewIDWithName("file_storage", "storage") + storageID := component.NewIDWithName(component.MustType("file_storage"), "storage") qCfg.StorageID = &storageID rCfg := configretry.NewDefaultBackOffConfig() ms := consumertest.MetricsSink{} set := exportertest.NewNopCreateSettings() - set.ID = component.NewIDWithName("test_metrics", "with_persistent_queue") + set.ID = component.NewIDWithName(component.MustType("test_metrics"), "with_persistent_queue") te, err := NewMetricsExporter(context.Background(), set, &fakeTracesExporterConfig, ms.ConsumeMetrics, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) diff --git a/exporter/exporterhelper/obsexporter_test.go b/exporter/exporterhelper/obsexporter_test.go index c37a4287082..350fccff426 100644 --- a/exporter/exporterhelper/obsexporter_test.go +++ b/exporter/exporterhelper/obsexporter_test.go @@ -20,7 +20,7 @@ import ( ) var ( - exporterID = component.NewID("fakeExporter") + exporterID = component.NewID(component.MustType("fakeExporter")) errFake = errors.New("errFake") ) diff --git a/exporter/exporterhelper/obsreport_test.go b/exporter/exporterhelper/obsreport_test.go index 267748f5416..4a6aca7cca2 100644 --- a/exporter/exporterhelper/obsreport_test.go +++ b/exporter/exporterhelper/obsreport_test.go @@ -15,7 +15,7 @@ import ( ) func TestExportEnqueueFailure(t *testing.T) { - exporterID := component.NewID("fakeExporter") + exporterID := component.NewID(component.MustType("fakeExporter")) tt, err := componenttest.SetupTelemetry(exporterID) require.NoError(t, err) t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) diff --git a/exporter/exporterhelper/queue_sender_test.go b/exporter/exporterhelper/queue_sender_test.go index d56ec6d78b1..537d54a281c 100644 --- a/exporter/exporterhelper/queue_sender_test.go +++ b/exporter/exporterhelper/queue_sender_test.go @@ -26,7 +26,7 @@ func TestQueuedRetry_StopWhileWaiting(t *testing.T) { qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 1 rCfg := configretry.NewDefaultBackOffConfig() - be, err := newBaseExporter(defaultSettings, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) + be, err := newBaseExporter(defaultSettings, defaultType, false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) ocs := be.obsrepSender.(*observabilityConsumerSender) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) @@ -58,7 +58,7 @@ func TestQueuedRetry_DoNotPreserveCancellation(t *testing.T) { qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 1 rCfg := configretry.NewDefaultBackOffConfig() - be, err := newBaseExporter(defaultSettings, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) + be, err := newBaseExporter(defaultSettings, defaultType, false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) ocs := be.obsrepSender.(*observabilityConsumerSender) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) @@ -88,7 +88,7 @@ func TestQueuedRetry_RejectOnFull(t *testing.T) { set := exportertest.NewNopCreateSettings() logger, observed := observer.New(zap.ErrorLevel) set.Logger = zap.New(logger) - be, err := newBaseExporter(set, "", false, nil, nil, newNoopObsrepSender, WithQueue(qCfg)) + be, err := newBaseExporter(set, defaultType, false, nil, nil, newNoopObsrepSender, WithQueue(qCfg)) require.NoError(t, err) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) t.Cleanup(func() { @@ -108,7 +108,7 @@ func TestQueuedRetryHappyPath(t *testing.T) { qCfg := NewDefaultQueueSettings() rCfg := configretry.NewDefaultBackOffConfig() set := exporter.CreateSettings{ID: defaultID, TelemetrySettings: tt.TelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo()} - be, err := newBaseExporter(set, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) + be, err := newBaseExporter(set, defaultType, false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) ocs := be.obsrepSender.(*observabilityConsumerSender) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) @@ -145,7 +145,7 @@ func TestQueuedRetry_QueueMetricsReported(t *testing.T) { qCfg.NumConsumers = 0 // to make every request go straight to the queue rCfg := configretry.NewDefaultBackOffConfig() set := exporter.CreateSettings{ID: defaultID, TelemetrySettings: tt.TelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo()} - be, err := newBaseExporter(set, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) + be, err := newBaseExporter(set, defaultType, false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) @@ -237,11 +237,11 @@ func TestQueuedRetryPersistenceEnabled(t *testing.T) { t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) qCfg := NewDefaultQueueSettings() - storageID := component.NewIDWithName("file_storage", "storage") + storageID := component.NewIDWithName(component.MustType("file_storage"), "storage") qCfg.StorageID = &storageID // enable persistence rCfg := configretry.NewDefaultBackOffConfig() set := exporter.CreateSettings{ID: defaultID, TelemetrySettings: tt.TelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo()} - be, err := newBaseExporter(set, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) + be, err := newBaseExporter(set, defaultType, false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) var extensions = map[component.ID]component.Component{ @@ -261,11 +261,11 @@ func TestQueuedRetryPersistenceEnabledStorageError(t *testing.T) { t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) qCfg := NewDefaultQueueSettings() - storageID := component.NewIDWithName("file_storage", "storage") + storageID := component.NewIDWithName(component.MustType("file_storage"), "storage") qCfg.StorageID = &storageID // enable persistence rCfg := configretry.NewDefaultBackOffConfig() set := exporter.CreateSettings{ID: defaultID, TelemetrySettings: tt.TelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo()} - be, err := newBaseExporter(set, "", false, mockRequestMarshaler, mockRequestUnmarshaler(&mockRequest{}), newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) + be, err := newBaseExporter(set, defaultType, false, mockRequestMarshaler, mockRequestUnmarshaler(&mockRequest{}), newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) var extensions = map[component.ID]component.Component{ @@ -280,7 +280,7 @@ func TestQueuedRetryPersistenceEnabledStorageError(t *testing.T) { func TestQueuedRetryPersistentEnabled_NoDataLossOnShutdown(t *testing.T) { qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 1 - storageID := component.NewIDWithName("file_storage", "storage") + storageID := component.NewIDWithName(component.MustType("file_storage"), "storage") qCfg.StorageID = &storageID // enable persistence to ensure data is re-queued on shutdown rCfg := configretry.NewDefaultBackOffConfig() @@ -288,7 +288,7 @@ func TestQueuedRetryPersistentEnabled_NoDataLossOnShutdown(t *testing.T) { rCfg.MaxElapsedTime = 0 // retry infinitely so shutdown can be triggered mockReq := newErrorRequest() - be, err := newBaseExporter(defaultSettings, "", false, mockRequestMarshaler, mockRequestUnmarshaler(mockReq), + be, err := newBaseExporter(defaultSettings, defaultType, false, mockRequestMarshaler, mockRequestUnmarshaler(mockReq), newNoopObsrepSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -312,7 +312,7 @@ func TestQueuedRetryPersistentEnabled_NoDataLossOnShutdown(t *testing.T) { // start the exporter again replacing the preserved mockRequest in the unmarshaler with a new one that doesn't fail. replacedReq := newMockRequest(1, nil) - be, err = newBaseExporter(defaultSettings, "", false, mockRequestMarshaler, mockRequestUnmarshaler(replacedReq), + be, err = newBaseExporter(defaultSettings, defaultType, false, mockRequestMarshaler, mockRequestUnmarshaler(replacedReq), newNoopObsrepSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) require.NoError(t, be.Start(context.Background(), host)) @@ -323,7 +323,7 @@ func TestQueuedRetryPersistentEnabled_NoDataLossOnShutdown(t *testing.T) { } func TestQueueSenderNoStartShutdown(t *testing.T) { - qs := newQueueSender(NewDefaultQueueSettings(), exportertest.NewNopCreateSettings(), "", nil, nil, nil) + qs := newQueueSender(NewDefaultQueueSettings(), exportertest.NewNopCreateSettings(), defaultType, nil, nil, nil) assert.NoError(t, qs.Shutdown(context.Background())) } diff --git a/exporter/exporterhelper/retry_sender_test.go b/exporter/exporterhelper/retry_sender_test.go index 55089e9677c..b26c465e1dc 100644 --- a/exporter/exporterhelper/retry_sender_test.go +++ b/exporter/exporterhelper/retry_sender_test.go @@ -38,7 +38,7 @@ func TestQueuedRetry_DropOnPermanentError(t *testing.T) { qCfg := NewDefaultQueueSettings() rCfg := configretry.NewDefaultBackOffConfig() mockR := newMockRequest(2, consumererror.NewPermanent(errors.New("bad data"))) - be, err := newBaseExporter(defaultSettings, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) + be, err := newBaseExporter(defaultSettings, defaultType, false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) ocs := be.obsrepSender.(*observabilityConsumerSender) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) @@ -61,7 +61,7 @@ func TestQueuedRetry_DropOnNoRetry(t *testing.T) { qCfg := NewDefaultQueueSettings() rCfg := configretry.NewDefaultBackOffConfig() rCfg.Enabled = false - be, err := newBaseExporter(defaultSettings, "", false, mockRequestMarshaler, + be, err := newBaseExporter(defaultSettings, defaultType, false, mockRequestMarshaler, mockRequestUnmarshaler(newMockRequest(2, errors.New("transient error"))), newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -88,7 +88,7 @@ func TestQueuedRetry_OnError(t *testing.T) { qCfg.NumConsumers = 1 rCfg := configretry.NewDefaultBackOffConfig() rCfg.InitialInterval = 0 - be, err := newBaseExporter(defaultSettings, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) + be, err := newBaseExporter(defaultSettings, defaultType, false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) t.Cleanup(func() { @@ -116,7 +116,7 @@ func TestQueuedRetry_MaxElapsedTime(t *testing.T) { rCfg := configretry.NewDefaultBackOffConfig() rCfg.InitialInterval = time.Millisecond rCfg.MaxElapsedTime = 100 * time.Millisecond - be, err := newBaseExporter(defaultSettings, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) + be, err := newBaseExporter(defaultSettings, defaultType, false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) ocs := be.obsrepSender.(*observabilityConsumerSender) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) @@ -162,7 +162,7 @@ func TestQueuedRetry_ThrottleError(t *testing.T) { qCfg.NumConsumers = 1 rCfg := configretry.NewDefaultBackOffConfig() rCfg.InitialInterval = 10 * time.Millisecond - be, err := newBaseExporter(defaultSettings, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) + be, err := newBaseExporter(defaultSettings, defaultType, false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) ocs := be.obsrepSender.(*observabilityConsumerSender) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) @@ -194,7 +194,7 @@ func TestQueuedRetry_RetryOnError(t *testing.T) { qCfg.QueueSize = 1 rCfg := configretry.NewDefaultBackOffConfig() rCfg.InitialInterval = 0 - be, err := newBaseExporter(defaultSettings, "", false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) + be, err := newBaseExporter(defaultSettings, defaultType, false, nil, nil, newObservabilityConsumerSender, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) ocs := be.obsrepSender.(*observabilityConsumerSender) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) diff --git a/exporter/exporterhelper/traces_test.go b/exporter/exporterhelper/traces_test.go index d99b9025c91..d1579f9150f 100644 --- a/exporter/exporterhelper/traces_test.go +++ b/exporter/exporterhelper/traces_test.go @@ -37,7 +37,7 @@ const ( ) var ( - fakeTracesExporterName = component.NewIDWithName("fake_traces_exporter", "with_name") + fakeTracesExporterName = component.NewIDWithName(component.MustType("fake_traces_exporter"), "with_name") fakeTracesExporterConfig = struct{}{} ) @@ -155,12 +155,12 @@ func TestTracesRequestExporter_Default_ExportError(t *testing.T) { func TestTracesExporter_WithPersistentQueue(t *testing.T) { qCfg := NewDefaultQueueSettings() - storageID := component.NewIDWithName("file_storage", "storage") + storageID := component.NewIDWithName(component.MustType("file_storage"), "storage") qCfg.StorageID = &storageID rCfg := configretry.NewDefaultBackOffConfig() ts := consumertest.TracesSink{} set := exportertest.NewNopCreateSettings() - set.ID = component.NewIDWithName("test_traces", "with_persistent_queue") + set.ID = component.NewIDWithName(component.MustType("test_traces"), "with_persistent_queue") te, err := NewTracesExporter(context.Background(), set, &fakeTracesExporterConfig, ts.ConsumeTraces, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) diff --git a/exporter/exportertest/contract_checker_test.go b/exporter/exportertest/contract_checker_test.go index c99baa28792..580ef9adb71 100644 --- a/exporter/exportertest/contract_checker_test.go +++ b/exporter/exportertest/contract_checker_test.go @@ -78,7 +78,7 @@ func (mef *mockExporterFactory) createMockLogsExporter( func newMockExporterFactory(mr *mockReceiver) exporter.Factory { mef := &mockExporterFactory{mr: mr} return exporter.NewFactory( - "pass_through_exporter", + component.MustType("pass_through_exporter"), func() component.Config { return &nopConfig{} }, exporter.WithTraces(mef.createMockTracesExporter, component.StabilityLevelBeta), exporter.WithMetrics(mef.createMockMetricsExporter, component.StabilityLevelBeta), @@ -87,7 +87,7 @@ func newMockExporterFactory(mr *mockReceiver) exporter.Factory { } func newMockReceiverFactory(mr *mockReceiver) receiver.Factory { - return receiver.NewFactory("pass_through_receiver", + return receiver.NewFactory(component.MustType("pass_through_receiver"), func() component.Config { return &nopConfig{} }, receiver.WithTraces(func(_ context.Context, _ receiver.CreateSettings, _ component.Config, c consumer.Traces) (receiver.Traces, error) { mr.Traces = c diff --git a/exporter/exportertest/nop_exporter.go b/exporter/exportertest/nop_exporter.go index 4911116058a..708b1a9a1a0 100644 --- a/exporter/exportertest/nop_exporter.go +++ b/exporter/exportertest/nop_exporter.go @@ -12,7 +12,7 @@ import ( "go.opentelemetry.io/collector/exporter" ) -const typeStr = "nop" +var nopType = component.MustType("nop") // NewNopCreateSettings returns a new nop settings for Create*Exporter functions. func NewNopCreateSettings() exporter.CreateSettings { @@ -25,7 +25,7 @@ func NewNopCreateSettings() exporter.CreateSettings { // NewNopFactory returns an exporter.Factory that constructs nop exporters. func NewNopFactory() exporter.Factory { return exporter.NewFactory( - "nop", + nopType, func() component.Config { return &nopConfig{} }, exporter.WithTraces(createTracesExporter, component.StabilityLevelStable), exporter.WithMetrics(createMetricsExporter, component.StabilityLevelStable), @@ -62,6 +62,6 @@ type nopExporter struct { func NewNopBuilder() *exporter.Builder { nopFactory := NewNopFactory() return exporter.NewBuilder( - map[component.ID]component.Config{component.NewID(typeStr): nopFactory.CreateDefaultConfig()}, - map[component.Type]exporter.Factory{typeStr: nopFactory}) + map[component.ID]component.Config{component.NewID(nopType): nopFactory.CreateDefaultConfig()}, + map[component.Type]exporter.Factory{nopType: nopFactory}) } diff --git a/exporter/exportertest/nop_exporter_test.go b/exporter/exportertest/nop_exporter_test.go index ed7a36bc062..b86e8a42298 100644 --- a/exporter/exportertest/nop_exporter_test.go +++ b/exporter/exportertest/nop_exporter_test.go @@ -20,7 +20,7 @@ import ( func TestNewNopFactory(t *testing.T) { factory := NewNopFactory() require.NotNil(t, factory) - assert.Equal(t, component.Type("nop"), factory.Type()) + assert.Equal(t, component.MustType("nop"), factory.Type()) cfg := factory.CreateDefaultConfig() assert.Equal(t, &nopConfig{}, cfg) @@ -50,7 +50,7 @@ func TestNewNopBuilder(t *testing.T) { factory := NewNopFactory() cfg := factory.CreateDefaultConfig() set := NewNopCreateSettings() - set.ID = component.NewID(typeStr) + set.ID = component.NewID(nopType) traces, err := factory.CreateTracesExporter(context.Background(), set, cfg) require.NoError(t, err) diff --git a/exporter/loggingexporter/factory.go b/exporter/loggingexporter/factory.go index 70157fc2d98..4abf50ef042 100644 --- a/exporter/loggingexporter/factory.go +++ b/exporter/loggingexporter/factory.go @@ -15,9 +15,10 @@ import ( "go.opentelemetry.io/collector/exporter/loggingexporter/internal/metadata" ) +// The value of "type" key in configuration. +var componentType = component.MustType("logging") + const ( - // The value of "type" key in configuration. - typeStr = "logging" defaultSamplingInitial = 2 defaultSamplingThereafter = 500 ) @@ -25,7 +26,7 @@ const ( // NewFactory creates a factory for Logging exporter func NewFactory() exporter.Factory { return exporter.NewFactory( - typeStr, + componentType, createDefaultConfig, exporter.WithTraces(createTracesExporter, metadata.TracesStability), exporter.WithMetrics(createMetricsExporter, metadata.MetricsStability), diff --git a/exporter/otlpexporter/config_test.go b/exporter/otlpexporter/config_test.go index 78870e34b22..214f43e1ffd 100644 --- a/exporter/otlpexporter/config_test.go +++ b/exporter/otlpexporter/config_test.go @@ -74,7 +74,7 @@ func TestUnmarshalConfig(t *testing.T) { }, WriteBufferSize: 512 * 1024, BalancerName: "round_robin", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("nop")}, + Auth: &configauth.Authentication{AuthenticatorID: component.NewID(component.MustType("nop"))}, }, }, cfg) } diff --git a/extension/extension_test.go b/extension/extension_test.go index 23a57d0bcc9..30a3579bd94 100644 --- a/extension/extension_test.go +++ b/extension/extension_test.go @@ -21,18 +21,18 @@ type nopExtension struct { } func TestNewFactory(t *testing.T) { - const typeStr = "test" + var testType = component.MustType("test") defaultCfg := struct{}{} nopExtensionInstance := new(nopExtension) factory := NewFactory( - typeStr, + testType, func() component.Config { return &defaultCfg }, func(ctx context.Context, settings CreateSettings, extension component.Config) (Extension, error) { return nopExtensionInstance, nil }, component.StabilityLevelDevelopment) - assert.EqualValues(t, typeStr, factory.Type()) + assert.EqualValues(t, testType, factory.Type()) assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) assert.Equal(t, component.StabilityLevelDevelopment, factory.ExtensionStability()) @@ -48,8 +48,8 @@ func TestMakeFactoryMap(t *testing.T) { out map[component.Type]Factory } - p1 := NewFactory("p1", nil, nil, component.StabilityLevelAlpha) - p2 := NewFactory("p2", nil, nil, component.StabilityLevelAlpha) + p1 := NewFactory(component.MustType("p1"), nil, nil, component.StabilityLevelAlpha) + p2 := NewFactory(component.MustType("p2"), nil, nil, component.StabilityLevelAlpha) testCases := []testCase{ { name: "different names", @@ -61,7 +61,7 @@ func TestMakeFactoryMap(t *testing.T) { }, { name: "same name", - in: []Factory{p1, p2, NewFactory("p1", nil, nil, component.StabilityLevelAlpha)}, + in: []Factory{p1, p2, NewFactory(component.MustType("p1"), nil, nil, component.StabilityLevelAlpha)}, }, } for i := range testCases { @@ -79,14 +79,14 @@ func TestMakeFactoryMap(t *testing.T) { } func TestBuilder(t *testing.T) { - const typeStr = "test" + var testType = component.MustType("test") defaultCfg := struct{}{} - testID := component.NewID(typeStr) - unknownID := component.NewID("unknown") + testID := component.NewID(testType) + unknownID := component.NewID(component.MustType("unknown")) factories, err := MakeFactoryMap([]Factory{ NewFactory( - typeStr, + testType, func() component.Config { return &defaultCfg }, func(ctx context.Context, settings CreateSettings, extension component.Config) (Extension, error) { return nopExtension{CreateSettings: settings}, nil @@ -111,20 +111,20 @@ func TestBuilder(t *testing.T) { assert.EqualError(t, err, "extension factory not available for: \"unknown\"") assert.Nil(t, missingType) - missingCfg, err := b.Create(context.Background(), createSettings(component.NewIDWithName(typeStr, "foo"))) + missingCfg, err := b.Create(context.Background(), createSettings(component.NewIDWithName(testType, "foo"))) assert.EqualError(t, err, "extension \"test/foo\" is not configured") assert.Nil(t, missingCfg) } func TestBuilderFactory(t *testing.T) { - factories, err := MakeFactoryMap([]Factory{NewFactory("foo", nil, nil, component.StabilityLevelDevelopment)}...) + factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustType("foo"), nil, nil, component.StabilityLevelDevelopment)}...) require.NoError(t, err) - cfgs := map[component.ID]component.Config{component.NewID("foo"): struct{}{}} + cfgs := map[component.ID]component.Config{component.NewID(component.MustType("foo")): struct{}{}} b := NewBuilder(cfgs, factories) - assert.NotNil(t, b.Factory(component.NewID("foo").Type())) - assert.Nil(t, b.Factory(component.NewID("bar").Type())) + assert.NotNil(t, b.Factory(component.NewID(component.MustType("foo")).Type())) + assert.Nil(t, b.Factory(component.NewID(component.MustType("bar")).Type())) } func createSettings(id component.ID) CreateSettings { diff --git a/extension/extensiontest/nop_extension.go b/extension/extensiontest/nop_extension.go index 192650a0442..a2408de1575 100644 --- a/extension/extensiontest/nop_extension.go +++ b/extension/extensiontest/nop_extension.go @@ -11,7 +11,7 @@ import ( "go.opentelemetry.io/collector/extension" ) -const typeStr = "nop" +var nopType = component.MustType("nop") // NewNopCreateSettings returns a new nop settings for extension.Factory Create* functions. func NewNopCreateSettings() extension.CreateSettings { @@ -24,7 +24,7 @@ func NewNopCreateSettings() extension.CreateSettings { // NewNopFactory returns an extension.Factory that constructs nop extensions. func NewNopFactory() extension.Factory { return extension.NewFactory( - "nop", + nopType, func() component.Config { return &nopConfig{} }, @@ -48,6 +48,6 @@ type nopExtension struct { func NewNopBuilder() *extension.Builder { nopFactory := NewNopFactory() return extension.NewBuilder( - map[component.ID]component.Config{component.NewID(typeStr): nopFactory.CreateDefaultConfig()}, - map[component.Type]extension.Factory{typeStr: nopFactory}) + map[component.ID]component.Config{component.NewID(nopType): nopFactory.CreateDefaultConfig()}, + map[component.Type]extension.Factory{nopType: nopFactory}) } diff --git a/extension/extensiontest/nop_extension_test.go b/extension/extensiontest/nop_extension_test.go index c188feecdfc..5a2ad65b207 100644 --- a/extension/extensiontest/nop_extension_test.go +++ b/extension/extensiontest/nop_extension_test.go @@ -17,7 +17,7 @@ import ( func TestNewNopFactory(t *testing.T) { factory := NewNopFactory() require.NotNil(t, factory) - assert.Equal(t, component.Type("nop"), factory.Type()) + assert.Equal(t, component.MustType("nop"), factory.Type()) cfg := factory.CreateDefaultConfig() assert.Equal(t, &nopConfig{}, cfg) @@ -34,7 +34,7 @@ func TestNewNopBuilder(t *testing.T) { factory := NewNopFactory() cfg := factory.CreateDefaultConfig() set := NewNopCreateSettings() - set.ID = component.NewID(typeStr) + set.ID = component.NewID(nopType) ext, err := factory.CreateExtension(context.Background(), set, cfg) require.NoError(t, err) diff --git a/extension/extensiontest/statuswatcher_extension.go b/extension/extensiontest/statuswatcher_extension.go index e501353dcc6..d4c18e5a196 100644 --- a/extension/extensiontest/statuswatcher_extension.go +++ b/extension/extensiontest/statuswatcher_extension.go @@ -24,7 +24,7 @@ func NewStatusWatcherExtensionFactory( onStatusChanged func(source *component.InstanceID, event *component.StatusEvent), ) extension.Factory { return extension.NewFactory( - "statuswatcher", + component.MustType("statuswatcher"), func() component.Config { return &struct{}{} }, diff --git a/extension/extensiontest/statuswatcher_extension_test.go b/extension/extensiontest/statuswatcher_extension_test.go index 0bfdf4f5eda..4fc00e1f9a0 100644 --- a/extension/extensiontest/statuswatcher_extension_test.go +++ b/extension/extensiontest/statuswatcher_extension_test.go @@ -23,7 +23,7 @@ func TestStatusWatcherExtension(t *testing.T) { }, ) require.NotNil(t, factory) - assert.Equal(t, component.Type("statuswatcher"), factory.Type()) + assert.Equal(t, component.MustType("statuswatcher"), factory.Type()) cfg := factory.CreateDefaultConfig() assert.Equal(t, &struct{}{}, cfg) diff --git a/internal/memorylimiter/memorylimiter_test.go b/internal/memorylimiter/memorylimiter_test.go index c3395791a75..0be8265e41d 100644 --- a/internal/memorylimiter/memorylimiter_test.go +++ b/internal/memorylimiter/memorylimiter_test.go @@ -173,7 +173,7 @@ type host struct { func (h *host) GetExtensions() map[component.ID]component.Component { ret := make(map[component.ID]component.Component) - ret[component.NewID("ballast")] = &ballastExtension{ballastSize: h.ballastSize} + ret[component.NewID(component.MustType("ballast"))] = &ballastExtension{ballastSize: h.ballastSize} return ret } diff --git a/internal/sharedcomponent/sharedcomponent_test.go b/internal/sharedcomponent/sharedcomponent_test.go index 09589d7ad63..2f448ef7526 100644 --- a/internal/sharedcomponent/sharedcomponent_test.go +++ b/internal/sharedcomponent/sharedcomponent_test.go @@ -15,7 +15,7 @@ import ( "go.opentelemetry.io/collector/component/componenttest" ) -var id = component.NewID("test") +var id = component.NewID(component.MustType("test")) type baseComponent struct { component.StartFunc diff --git a/otelcol/command_components_test.go b/otelcol/command_components_test.go index 3fe9a2cdd51..1326098da8c 100644 --- a/otelcol/command_components_test.go +++ b/otelcol/command_components_test.go @@ -16,6 +16,8 @@ import ( "go.opentelemetry.io/collector/component" ) +var nopType = component.MustType("nop") + func TestNewBuildSubCommand(t *testing.T) { cfgProvider, err := NewConfigProvider(newDefaultConfigProviderSettings([]string{filepath.Join("testdata", "otelcol-nop.yaml")})) require.NoError(t, err) @@ -31,7 +33,7 @@ func TestNewBuildSubCommand(t *testing.T) { ExpectedYamlStruct := componentsOutput{ BuildInfo: component.NewDefaultBuildInfo(), Receivers: []componentWithStability{{ - Name: component.Type("nop"), + Name: nopType, Stability: map[string]string{ "logs": "Stable", "metrics": "Stable", @@ -39,7 +41,7 @@ func TestNewBuildSubCommand(t *testing.T) { }, }}, Processors: []componentWithStability{{ - Name: component.Type("nop"), + Name: nopType, Stability: map[string]string{ "logs": "Stable", "metrics": "Stable", @@ -47,7 +49,7 @@ func TestNewBuildSubCommand(t *testing.T) { }, }}, Exporters: []componentWithStability{{ - Name: component.Type("nop"), + Name: nopType, Stability: map[string]string{ "logs": "Stable", "metrics": "Stable", @@ -55,7 +57,7 @@ func TestNewBuildSubCommand(t *testing.T) { }, }}, Connectors: []componentWithStability{{ - Name: component.Type("nop"), + Name: nopType, Stability: map[string]string{ "logs-to-logs": "Development", "logs-to-metrics": "Development", @@ -71,7 +73,7 @@ func TestNewBuildSubCommand(t *testing.T) { }, }}, Extensions: []componentWithStability{{ - Name: component.Type("nop"), + Name: nopType, Stability: map[string]string{ "extension": "Stable", }, diff --git a/otelcol/config_test.go b/otelcol/config_test.go index 9a4ddb87c4f..408050229b4 100644 --- a/otelcol/config_test.go +++ b/otelcol/config_test.go @@ -76,7 +76,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-extension-reference", cfgFn: func() *Config { cfg := generateConfig() - cfg.Service.Extensions = append(cfg.Service.Extensions, component.NewIDWithName("nop", "2")) + cfg.Service.Extensions = append(cfg.Service.Extensions, component.NewIDWithName(component.MustType("nop"), "2")) return cfg }, expected: errors.New(`service::extensions: references extension "nop/2" which is not configured`), @@ -85,8 +85,8 @@ func TestConfigValidate(t *testing.T) { name: "invalid-receiver-reference", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.NewID("traces")] - pipe.Receivers = append(pipe.Receivers, component.NewIDWithName("nop", "2")) + pipe := cfg.Service.Pipelines[component.NewID(component.MustType("traces"))] + pipe.Receivers = append(pipe.Receivers, component.NewIDWithName(component.MustType("nop"), "2")) return cfg }, expected: errors.New(`service::pipelines::traces: references receiver "nop/2" which is not configured`), @@ -95,8 +95,8 @@ func TestConfigValidate(t *testing.T) { name: "invalid-processor-reference", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.NewID("traces")] - pipe.Processors = append(pipe.Processors, component.NewIDWithName("nop", "2")) + pipe := cfg.Service.Pipelines[component.NewID(component.MustType("traces"))] + pipe.Processors = append(pipe.Processors, component.NewIDWithName(component.MustType("nop"), "2")) return cfg }, expected: errors.New(`service::pipelines::traces: references processor "nop/2" which is not configured`), @@ -105,8 +105,8 @@ func TestConfigValidate(t *testing.T) { name: "invalid-exporter-reference", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.NewID("traces")] - pipe.Exporters = append(pipe.Exporters, component.NewIDWithName("nop", "2")) + pipe := cfg.Service.Pipelines[component.NewID(component.MustType("traces"))] + pipe.Exporters = append(pipe.Exporters, component.NewIDWithName(component.MustType("nop"), "2")) return cfg }, expected: errors.New(`service::pipelines::traces: references exporter "nop/2" which is not configured`), @@ -115,7 +115,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-receiver-config", cfgFn: func() *Config { cfg := generateConfig() - cfg.Receivers[component.NewID("nop")] = &errConfig{ + cfg.Receivers[component.NewID(component.MustType("nop"))] = &errConfig{ validateErr: errInvalidRecvConfig, } return cfg @@ -126,7 +126,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-exporter-config", cfgFn: func() *Config { cfg := generateConfig() - cfg.Exporters[component.NewID("nop")] = &errConfig{ + cfg.Exporters[component.NewID(component.MustType("nop"))] = &errConfig{ validateErr: errInvalidExpConfig, } return cfg @@ -137,7 +137,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-processor-config", cfgFn: func() *Config { cfg := generateConfig() - cfg.Processors[component.NewID("nop")] = &errConfig{ + cfg.Processors[component.NewID(component.MustType("nop"))] = &errConfig{ validateErr: errInvalidProcConfig, } return cfg @@ -148,7 +148,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-extension-config", cfgFn: func() *Config { cfg := generateConfig() - cfg.Extensions[component.NewID("nop")] = &errConfig{ + cfg.Extensions[component.NewID(component.MustType("nop"))] = &errConfig{ validateErr: errInvalidExtConfig, } return cfg @@ -159,7 +159,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-connector-config", cfgFn: func() *Config { cfg := generateConfig() - cfg.Connectors[component.NewIDWithName("nop", "conn")] = &errConfig{ + cfg.Connectors[component.NewIDWithName(component.MustType("nop"), "conn")] = &errConfig{ validateErr: errInvalidConnConfig, } return cfg @@ -170,34 +170,34 @@ func TestConfigValidate(t *testing.T) { name: "ambiguous-connector-name-as-receiver", cfgFn: func() *Config { cfg := generateConfig() - cfg.Receivers[component.NewID("nop/2")] = &errConfig{} - cfg.Connectors[component.NewID("nop/2")] = &errConfig{} - pipe := cfg.Service.Pipelines[component.NewID("traces")] - pipe.Receivers = append(pipe.Receivers, component.NewIDWithName("nop", "2")) - pipe.Exporters = append(pipe.Exporters, component.NewIDWithName("nop", "2")) + cfg.Receivers[component.NewID(component.MustType("nop2"))] = &errConfig{} + cfg.Connectors[component.NewID(component.MustType("nop2"))] = &errConfig{} + pipe := cfg.Service.Pipelines[component.NewID(component.MustType("traces"))] + pipe.Receivers = append(pipe.Receivers, component.NewIDWithName(component.MustType("nop"), "2")) + pipe.Exporters = append(pipe.Exporters, component.NewIDWithName(component.MustType("nop"), "2")) return cfg }, - expected: errors.New(`connectors::nop/2: ambiguous ID: Found both "nop/2" receiver and "nop/2" connector. Change one of the components' IDs to eliminate ambiguity (e.g. rename "nop/2" connector to "nop/2/connector")`), + expected: errors.New(`connectors::nop2: ambiguous ID: Found both "nop2" receiver and "nop2" connector. Change one of the components' IDs to eliminate ambiguity (e.g. rename "nop2" connector to "nop2/connector")`), }, { name: "ambiguous-connector-name-as-exporter", cfgFn: func() *Config { cfg := generateConfig() - cfg.Exporters[component.NewID("nop/2")] = &errConfig{} - cfg.Connectors[component.NewID("nop/2")] = &errConfig{} - pipe := cfg.Service.Pipelines[component.NewID("traces")] - pipe.Receivers = append(pipe.Receivers, component.NewIDWithName("nop", "2")) - pipe.Exporters = append(pipe.Exporters, component.NewIDWithName("nop", "2")) + cfg.Exporters[component.NewID(component.MustType("nop2"))] = &errConfig{} + cfg.Connectors[component.NewID(component.MustType("nop2"))] = &errConfig{} + pipe := cfg.Service.Pipelines[component.NewID(component.MustType("traces"))] + pipe.Receivers = append(pipe.Receivers, component.NewIDWithName(component.MustType("nop"), "2")) + pipe.Exporters = append(pipe.Exporters, component.NewIDWithName(component.MustType("nop"), "2")) return cfg }, - expected: errors.New(`connectors::nop/2: ambiguous ID: Found both "nop/2" exporter and "nop/2" connector. Change one of the components' IDs to eliminate ambiguity (e.g. rename "nop/2" connector to "nop/2/connector")`), + expected: errors.New(`connectors::nop2: ambiguous ID: Found both "nop2" exporter and "nop2" connector. Change one of the components' IDs to eliminate ambiguity (e.g. rename "nop2" connector to "nop2/connector")`), }, { name: "invalid-connector-reference-as-receiver", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.NewID("traces")] - pipe.Receivers = append(pipe.Receivers, component.NewIDWithName("nop", "conn2")) + pipe := cfg.Service.Pipelines[component.NewID(component.MustType("traces"))] + pipe.Receivers = append(pipe.Receivers, component.NewIDWithName(component.MustType("nop"), "conn2")) return cfg }, expected: errors.New(`service::pipelines::traces: references receiver "nop/conn2" which is not configured`), @@ -206,8 +206,8 @@ func TestConfigValidate(t *testing.T) { name: "invalid-connector-reference-as-receiver", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.NewID("traces")] - pipe.Exporters = append(pipe.Exporters, component.NewIDWithName("nop", "conn2")) + pipe := cfg.Service.Pipelines[component.NewID(component.MustType("traces"))] + pipe.Exporters = append(pipe.Exporters, component.NewIDWithName(component.MustType("nop"), "conn2")) return cfg }, expected: errors.New(`service::pipelines::traces: references exporter "nop/conn2" which is not configured`), @@ -234,19 +234,19 @@ func TestConfigValidate(t *testing.T) { func generateConfig() *Config { return &Config{ Receivers: map[component.ID]component.Config{ - component.NewID("nop"): &errConfig{}, + component.NewID(component.MustType("nop")): &errConfig{}, }, Exporters: map[component.ID]component.Config{ - component.NewID("nop"): &errConfig{}, + component.NewID(component.MustType("nop")): &errConfig{}, }, Processors: map[component.ID]component.Config{ - component.NewID("nop"): &errConfig{}, + component.NewID(component.MustType("nop")): &errConfig{}, }, Connectors: map[component.ID]component.Config{ - component.NewIDWithName("nop", "conn"): &errConfig{}, + component.NewIDWithName(component.MustType("nop"), "conn"): &errConfig{}, }, Extensions: map[component.ID]component.Config{ - component.NewID("nop"): &errConfig{}, + component.NewID(component.MustType("nop")): &errConfig{}, }, Service: service.Config{ Telemetry: telemetry.Config{ @@ -265,12 +265,12 @@ func generateConfig() *Config { Address: ":8080", }, }, - Extensions: []component.ID{component.NewID("nop")}, + Extensions: []component.ID{component.NewID(component.MustType("nop"))}, Pipelines: pipelines.Config{ - component.NewID("traces"): { - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, }, diff --git a/otelcol/internal/configunmarshaler/configs_test.go b/otelcol/internal/configunmarshaler/configs_test.go index bc869456455..ee269fc89b4 100644 --- a/otelcol/internal/configunmarshaler/configs_test.go +++ b/otelcol/internal/configunmarshaler/configs_test.go @@ -18,6 +18,8 @@ import ( "go.opentelemetry.io/collector/receiver/receivertest" ) +var nopType = component.MustType("nop") + var testKinds = []struct { kind string factories map[component.Type]component.Factory @@ -25,31 +27,31 @@ var testKinds = []struct { { kind: "receiver", factories: map[component.Type]component.Factory{ - "nop": receivertest.NewNopFactory(), + nopType: receivertest.NewNopFactory(), }, }, { kind: "processor", factories: map[component.Type]component.Factory{ - "nop": processortest.NewNopFactory(), + nopType: processortest.NewNopFactory(), }, }, { kind: "exporter", factories: map[component.Type]component.Factory{ - "nop": exportertest.NewNopFactory(), + nopType: exportertest.NewNopFactory(), }, }, { kind: "connector", factories: map[component.Type]component.Factory{ - "nop": connectortest.NewNopFactory(), + nopType: connectortest.NewNopFactory(), }, }, { kind: "extension", factories: map[component.Type]component.Factory{ - "nop": extensiontest.NewNopFactory(), + nopType: extensiontest.NewNopFactory(), }, }, } @@ -65,8 +67,8 @@ func TestUnmarshal(t *testing.T) { require.NoError(t, cfgs.Unmarshal(conf)) assert.Equal(t, map[component.ID]component.Config{ - component.NewID("nop"): tk.factories["nop"].CreateDefaultConfig(), - component.NewIDWithName("nop", "my"+tk.kind): tk.factories["nop"].CreateDefaultConfig(), + component.NewID(nopType): tk.factories[nopType].CreateDefaultConfig(), + component.NewIDWithName(nopType, "my"+tk.kind): tk.factories[nopType].CreateDefaultConfig(), }, cfgs.Configs()) }) } diff --git a/otelcol/otelcoltest/config_test.go b/otelcol/otelcoltest/config_test.go index 1ab8ad1304d..d6396ff782b 100644 --- a/otelcol/otelcoltest/config_test.go +++ b/otelcol/otelcoltest/config_test.go @@ -23,39 +23,39 @@ func TestLoadConfig(t *testing.T) { // Verify extensions. require.Len(t, cfg.Extensions, 2) - assert.Contains(t, cfg.Extensions, component.NewID("nop")) - assert.Contains(t, cfg.Extensions, component.NewIDWithName("nop", "myextension")) + assert.Contains(t, cfg.Extensions, component.NewID(component.MustType("nop"))) + assert.Contains(t, cfg.Extensions, component.NewIDWithName(component.MustType("nop"), "myextension")) // Verify receivers require.Len(t, cfg.Receivers, 2) - assert.Contains(t, cfg.Receivers, component.NewID("nop")) - assert.Contains(t, cfg.Receivers, component.NewIDWithName("nop", "myreceiver")) + assert.Contains(t, cfg.Receivers, component.NewID(component.MustType("nop"))) + assert.Contains(t, cfg.Receivers, component.NewIDWithName(component.MustType("nop"), "myreceiver")) // Verify exporters assert.Len(t, cfg.Exporters, 2) - assert.Contains(t, cfg.Exporters, component.NewID("nop")) - assert.Contains(t, cfg.Exporters, component.NewIDWithName("nop", "myexporter")) + assert.Contains(t, cfg.Exporters, component.NewID(component.MustType("nop"))) + assert.Contains(t, cfg.Exporters, component.NewIDWithName(component.MustType("nop"), "myexporter")) // Verify procs assert.Len(t, cfg.Processors, 2) - assert.Contains(t, cfg.Processors, component.NewID("nop")) - assert.Contains(t, cfg.Processors, component.NewIDWithName("nop", "myprocessor")) + assert.Contains(t, cfg.Processors, component.NewID(component.MustType("nop"))) + assert.Contains(t, cfg.Processors, component.NewIDWithName(component.MustType("nop"), "myprocessor")) // Verify connectors assert.Len(t, cfg.Connectors, 1) - assert.Contains(t, cfg.Connectors, component.NewIDWithName("nop", "myconnector")) + assert.Contains(t, cfg.Connectors, component.NewIDWithName(component.MustType("nop"), "myconnector")) // Verify service. require.Len(t, cfg.Service.Extensions, 1) - assert.Contains(t, cfg.Service.Extensions, component.NewID("nop")) + assert.Contains(t, cfg.Service.Extensions, component.NewID(component.MustType("nop"))) require.Len(t, cfg.Service.Pipelines, 1) assert.Equal(t, &pipelines.PipelineConfig{ - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("nop")}, + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, - cfg.Service.Pipelines[component.NewID("traces")], + cfg.Service.Pipelines[component.NewID(component.MustType("traces"))], "Did not load pipeline config correctly") } diff --git a/otelcol/otelcoltest/nop_factories_test.go b/otelcol/otelcoltest/nop_factories_test.go index b70720c026b..a0f018cfe44 100644 --- a/otelcol/otelcoltest/nop_factories_test.go +++ b/otelcol/otelcoltest/nop_factories_test.go @@ -11,32 +11,34 @@ import ( "go.opentelemetry.io/collector/component" ) +var nopType = component.MustType("nop") + func TestNopFactories(t *testing.T) { nopFactories, err := NopFactories() require.NoError(t, err) require.Equal(t, 1, len(nopFactories.Receivers)) - nopReceiverFactory, ok := nopFactories.Receivers["nop"] + nopReceiverFactory, ok := nopFactories.Receivers[nopType] require.True(t, ok) - require.Equal(t, component.Type("nop"), nopReceiverFactory.Type()) + require.Equal(t, nopType, nopReceiverFactory.Type()) require.Equal(t, 1, len(nopFactories.Processors)) - nopProcessorFactory, ok := nopFactories.Processors["nop"] + nopProcessorFactory, ok := nopFactories.Processors[nopType] require.True(t, ok) - require.Equal(t, component.Type("nop"), nopProcessorFactory.Type()) + require.Equal(t, nopType, nopProcessorFactory.Type()) require.Equal(t, 1, len(nopFactories.Exporters)) - nopExporterFactory, ok := nopFactories.Exporters["nop"] + nopExporterFactory, ok := nopFactories.Exporters[nopType] require.True(t, ok) - require.Equal(t, component.Type("nop"), nopExporterFactory.Type()) + require.Equal(t, nopType, nopExporterFactory.Type()) require.Equal(t, 1, len(nopFactories.Extensions)) - nopExtensionFactory, ok := nopFactories.Extensions["nop"] + nopExtensionFactory, ok := nopFactories.Extensions[nopType] require.True(t, ok) - require.Equal(t, component.Type("nop"), nopExtensionFactory.Type()) + require.Equal(t, nopType, nopExtensionFactory.Type()) require.Equal(t, 1, len(nopFactories.Connectors)) - nopConnectorFactory, ok := nopFactories.Connectors["nop"] + nopConnectorFactory, ok := nopFactories.Connectors[nopType] require.True(t, ok) - require.Equal(t, component.Type("nop"), nopConnectorFactory.Type()) + require.Equal(t, nopType, nopConnectorFactory.Type()) } diff --git a/processor/batchprocessor/metrics_test.go b/processor/batchprocessor/metrics_test.go index a79fc187c42..ebf60bb6eec 100644 --- a/processor/batchprocessor/metrics_test.go +++ b/processor/batchprocessor/metrics_test.go @@ -97,7 +97,7 @@ func setupTelemetry(t *testing.T) testTelemetry { func (tt *testTelemetry) NewProcessorCreateSettings() processor.CreateSettings { settings := processortest.NewNopCreateSettings() settings.MeterProvider = tt.meterProvider - settings.ID = component.NewID(typeStr) + settings.ID = component.NewID(component.MustType("batch")) return settings } diff --git a/processor/memorylimiterprocessor/memorylimiter_test.go b/processor/memorylimiterprocessor/memorylimiter_test.go index 6a3c3999ce9..bf372943a25 100644 --- a/processor/memorylimiterprocessor/memorylimiter_test.go +++ b/processor/memorylimiterprocessor/memorylimiter_test.go @@ -467,7 +467,7 @@ type host struct { func (h *host) GetExtensions() map[component.ID]component.Component { ret := make(map[component.ID]component.Component) - ret[component.NewID("ballast")] = &ballastExtension{ballastSize: h.ballastSize} + ret[component.NewID(component.MustType("ballast"))] = &ballastExtension{ballastSize: h.ballastSize} return ret } diff --git a/processor/processor_test.go b/processor/processor_test.go index 11d70512186..4095e9d7001 100644 --- a/processor/processor_test.go +++ b/processor/processor_test.go @@ -17,12 +17,12 @@ import ( ) func TestNewFactory(t *testing.T) { - const typeStr = "test" + var testType = component.MustType("test") defaultCfg := struct{}{} factory := NewFactory( - typeStr, + testType, func() component.Config { return &defaultCfg }) - assert.EqualValues(t, typeStr, factory.Type()) + assert.EqualValues(t, testType, factory.Type()) assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) _, err := factory.CreateTracesProcessor(context.Background(), CreateSettings{}, &defaultCfg, nil) assert.Error(t, err) @@ -33,15 +33,15 @@ func TestNewFactory(t *testing.T) { } func TestNewFactoryWithOptions(t *testing.T) { - const typeStr = "test" + var testType = component.MustType("test") defaultCfg := struct{}{} factory := NewFactory( - typeStr, + testType, func() component.Config { return &defaultCfg }, WithTraces(createTraces, component.StabilityLevelAlpha), WithMetrics(createMetrics, component.StabilityLevelBeta), WithLogs(createLogs, component.StabilityLevelUnmaintained)) - assert.EqualValues(t, typeStr, factory.Type()) + assert.EqualValues(t, testType, factory.Type()) assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) assert.Equal(t, component.StabilityLevelAlpha, factory.TracesProcessorStability()) @@ -64,8 +64,8 @@ func TestMakeFactoryMap(t *testing.T) { out map[component.Type]Factory } - p1 := NewFactory("p1", nil) - p2 := NewFactory("p2", nil) + p1 := NewFactory(component.MustType("p1"), nil) + p2 := NewFactory(component.MustType("p2"), nil) testCases := []testCase{ { name: "different names", @@ -77,7 +77,7 @@ func TestMakeFactoryMap(t *testing.T) { }, { name: "same name", - in: []Factory{p1, p2, NewFactory("p1", nil)}, + in: []Factory{p1, p2, NewFactory(component.MustType("p1"), nil)}, }, } @@ -98,9 +98,9 @@ func TestMakeFactoryMap(t *testing.T) { func TestBuilder(t *testing.T) { defaultCfg := struct{}{} factories, err := MakeFactoryMap([]Factory{ - NewFactory("err", nil), + NewFactory(component.MustType("err"), nil), NewFactory( - "all", + component.MustType("all"), func() component.Config { return &defaultCfg }, WithTraces(createTraces, component.StabilityLevelDevelopment), WithMetrics(createMetrics, component.StabilityLevelAlpha), @@ -116,21 +116,21 @@ func TestBuilder(t *testing.T) { }{ { name: "unknown", - id: component.NewID("unknown"), + id: component.NewID(component.MustType("unknown")), err: "processor factory not available for: \"unknown\"", }, { name: "err", - id: component.NewID("err"), + id: component.NewID(component.MustType("err")), err: "telemetry type is not supported", }, { name: "all", - id: component.NewID("all"), + id: component.NewID(component.MustType("all")), }, { name: "all/named", - id: component.NewIDWithName("all", "named"), + id: component.NewIDWithName(component.MustType("all"), "named"), }, } @@ -173,7 +173,7 @@ func TestBuilderMissingConfig(t *testing.T) { defaultCfg := struct{}{} factories, err := MakeFactoryMap([]Factory{ NewFactory( - "all", + component.MustType("all"), func() component.Config { return &defaultCfg }, WithTraces(createTraces, component.StabilityLevelDevelopment), WithMetrics(createMetrics, component.StabilityLevelAlpha), @@ -184,7 +184,7 @@ func TestBuilderMissingConfig(t *testing.T) { require.NoError(t, err) bErr := NewBuilder(map[component.ID]component.Config{}, factories) - missingID := component.NewIDWithName("all", "missing") + missingID := component.NewIDWithName(component.MustType("all"), "missing") te, err := bErr.CreateTraces(context.Background(), createSettings(missingID), nil) assert.EqualError(t, err, "processor \"all/missing\" is not configured") @@ -200,14 +200,14 @@ func TestBuilderMissingConfig(t *testing.T) { } func TestBuilderFactory(t *testing.T) { - factories, err := MakeFactoryMap([]Factory{NewFactory("foo", nil)}...) + factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustType("foo"), nil)}...) require.NoError(t, err) - cfgs := map[component.ID]component.Config{component.NewID("foo"): struct{}{}} + cfgs := map[component.ID]component.Config{component.NewID(component.MustType("foo")): struct{}{}} b := NewBuilder(cfgs, factories) - assert.NotNil(t, b.Factory(component.NewID("foo").Type())) - assert.Nil(t, b.Factory(component.NewID("bar").Type())) + assert.NotNil(t, b.Factory(component.NewID(component.MustType("foo")).Type())) + assert.Nil(t, b.Factory(component.NewID(component.MustType("bar")).Type())) } var nopInstance = &nopProcessor{ diff --git a/processor/processorhelper/obsreport_test.go b/processor/processorhelper/obsreport_test.go index 41a395c37ba..23c803c5caf 100644 --- a/processor/processorhelper/obsreport_test.go +++ b/processor/processorhelper/obsreport_test.go @@ -16,7 +16,7 @@ import ( ) var ( - processorID = component.NewID("fakeProcessor") + processorID = component.NewID(component.MustType("fakeProcessor")) ) func TestProcessorTraceData(t *testing.T) { diff --git a/processor/processortest/nop_processor.go b/processor/processortest/nop_processor.go index 2e5133f6bdc..9a0ab35463f 100644 --- a/processor/processortest/nop_processor.go +++ b/processor/processortest/nop_processor.go @@ -13,7 +13,7 @@ import ( "go.opentelemetry.io/collector/processor" ) -const typeStr = "nop" +var nopType = component.MustType("nop") // NewNopCreateSettings returns a new nop settings for Create* functions. func NewNopCreateSettings() processor.CreateSettings { @@ -26,7 +26,7 @@ func NewNopCreateSettings() processor.CreateSettings { // NewNopFactory returns a component.ProcessorFactory that constructs nop processors. func NewNopFactory() processor.Factory { return processor.NewFactory( - "nop", + nopType, func() component.Config { return &nopConfig{} }, processor.WithTraces(createTracesProcessor, component.StabilityLevelStable), processor.WithMetrics(createMetricsProcessor, component.StabilityLevelStable), @@ -63,6 +63,6 @@ type nopProcessor struct { func NewNopBuilder() *processor.Builder { nopFactory := NewNopFactory() return processor.NewBuilder( - map[component.ID]component.Config{component.NewID(typeStr): nopFactory.CreateDefaultConfig()}, - map[component.Type]processor.Factory{typeStr: nopFactory}) + map[component.ID]component.Config{component.NewID(nopType): nopFactory.CreateDefaultConfig()}, + map[component.Type]processor.Factory{nopType: nopFactory}) } diff --git a/processor/processortest/nop_processor_test.go b/processor/processortest/nop_processor_test.go index 44f581bd2eb..8f8a4365f67 100644 --- a/processor/processortest/nop_processor_test.go +++ b/processor/processortest/nop_processor_test.go @@ -22,7 +22,7 @@ import ( func TestNewNopFactory(t *testing.T) { factory := NewNopFactory() require.NotNil(t, factory) - assert.Equal(t, component.Type("nop"), factory.Type()) + assert.Equal(t, component.MustType("nop"), factory.Type()) cfg := factory.CreateDefaultConfig() assert.Equal(t, &nopConfig{}, cfg) @@ -55,7 +55,7 @@ func TestNewNopBuilder(t *testing.T) { factory := NewNopFactory() cfg := factory.CreateDefaultConfig() set := NewNopCreateSettings() - set.ID = component.NewID(typeStr) + set.ID = component.NewID(nopType) traces, err := factory.CreateTracesProcessor(context.Background(), set, cfg, consumertest.NewNop()) require.NoError(t, err) diff --git a/processor/processortest/unhealthy_processor.go b/processor/processortest/unhealthy_processor.go index 508fbfde897..c0e3d7b9c16 100644 --- a/processor/processortest/unhealthy_processor.go +++ b/processor/processortest/unhealthy_processor.go @@ -24,7 +24,7 @@ func NewUnhealthyProcessorCreateSettings() processor.CreateSettings { // NewUnhealthyProcessorFactory returns a component.ProcessorFactory that constructs nop processors. func NewUnhealthyProcessorFactory() processor.Factory { return processor.NewFactory( - "unhealthy", + component.MustType("unhealthy"), func() component.Config { return &struct{}{} }, diff --git a/processor/processortest/unhealthy_processor_test.go b/processor/processortest/unhealthy_processor_test.go index adc80322f22..bdac70236f5 100644 --- a/processor/processortest/unhealthy_processor_test.go +++ b/processor/processortest/unhealthy_processor_test.go @@ -22,7 +22,7 @@ import ( func TestNewUnhealthyProcessorFactory(t *testing.T) { factory := NewUnhealthyProcessorFactory() require.NotNil(t, factory) - assert.Equal(t, component.Type("unhealthy"), factory.Type()) + assert.Equal(t, component.MustType("unhealthy"), factory.Type()) cfg := factory.CreateDefaultConfig() assert.Equal(t, &struct{}{}, cfg) diff --git a/receiver/otlpreceiver/internal/logs/otlp_test.go b/receiver/otlpreceiver/internal/logs/otlp_test.go index b13eab39820..3541095b0da 100644 --- a/receiver/otlpreceiver/internal/logs/otlp_test.go +++ b/receiver/otlpreceiver/internal/logs/otlp_test.go @@ -92,7 +92,7 @@ func otlpReceiverOnGRPCServer(t *testing.T, lc consumer.Logs) net.Addr { }) set := receivertest.NewNopCreateSettings() - set.ID = component.NewIDWithName("otlp", "log") + set.ID = component.NewIDWithName(component.MustType("otlp"), "log") obsreport, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{ ReceiverID: set.ID, Transport: "grpc", diff --git a/receiver/otlpreceiver/internal/metrics/otlp_test.go b/receiver/otlpreceiver/internal/metrics/otlp_test.go index 0700cdcf828..f655de45a48 100644 --- a/receiver/otlpreceiver/internal/metrics/otlp_test.go +++ b/receiver/otlpreceiver/internal/metrics/otlp_test.go @@ -93,7 +93,7 @@ func otlpReceiverOnGRPCServer(t *testing.T, mc consumer.Metrics) net.Addr { }) set := receivertest.NewNopCreateSettings() - set.ID = component.NewIDWithName("otlp", "metrics") + set.ID = component.NewIDWithName(component.MustType("otlp"), "metrics") obsreport, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{ ReceiverID: set.ID, Transport: "grpc", diff --git a/receiver/otlpreceiver/internal/trace/otlp_test.go b/receiver/otlpreceiver/internal/trace/otlp_test.go index 0bfdbbe1b9f..84b3c018d75 100644 --- a/receiver/otlpreceiver/internal/trace/otlp_test.go +++ b/receiver/otlpreceiver/internal/trace/otlp_test.go @@ -89,7 +89,7 @@ func otlpReceiverOnGRPCServer(t *testing.T, tc consumer.Traces) net.Addr { }) set := receivertest.NewNopCreateSettings() - set.ID = component.NewIDWithName("otlp", "trace") + set.ID = component.NewIDWithName(component.MustType("otlp"), "trace") obsreport, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{ ReceiverID: set.ID, Transport: "grpc", diff --git a/receiver/otlpreceiver/otlp_test.go b/receiver/otlpreceiver/otlp_test.go index 20e00a38292..37287a78e54 100644 --- a/receiver/otlpreceiver/otlp_test.go +++ b/receiver/otlpreceiver/otlp_test.go @@ -48,7 +48,7 @@ import ( const otlpReceiverName = "receiver_test" -var otlpReceiverID = component.NewIDWithName("otlp", otlpReceiverName) +var otlpReceiverID = component.NewIDWithName(component.MustType("otlp"), otlpReceiverName) func TestJsonHttp(t *testing.T) { tests := []struct { diff --git a/receiver/receiver_test.go b/receiver/receiver_test.go index d04dd88247d..228611e536d 100644 --- a/receiver/receiver_test.go +++ b/receiver/receiver_test.go @@ -17,12 +17,12 @@ import ( ) func TestNewFactory(t *testing.T) { - const typeStr = "test" + var testType = component.MustType("test") defaultCfg := struct{}{} factory := NewFactory( - typeStr, + testType, func() component.Config { return &defaultCfg }) - assert.EqualValues(t, typeStr, factory.Type()) + assert.EqualValues(t, testType, factory.Type()) assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) _, err := factory.CreateTracesReceiver(context.Background(), CreateSettings{}, &defaultCfg, nil) assert.Error(t, err) @@ -33,15 +33,15 @@ func TestNewFactory(t *testing.T) { } func TestNewFactoryWithOptions(t *testing.T) { - const typeStr = "test" + var testType = component.MustType("test") defaultCfg := struct{}{} factory := NewFactory( - typeStr, + testType, func() component.Config { return &defaultCfg }, WithTraces(createTraces, component.StabilityLevelDeprecated), WithMetrics(createMetrics, component.StabilityLevelAlpha), WithLogs(createLogs, component.StabilityLevelStable)) - assert.EqualValues(t, typeStr, factory.Type()) + assert.EqualValues(t, testType, factory.Type()) assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) assert.Equal(t, component.StabilityLevelDeprecated, factory.TracesReceiverStability()) @@ -64,8 +64,8 @@ func TestMakeFactoryMap(t *testing.T) { out map[component.Type]Factory } - p1 := NewFactory("p1", nil) - p2 := NewFactory("p2", nil) + p1 := NewFactory(component.MustType("p1"), nil) + p2 := NewFactory(component.MustType("p2"), nil) testCases := []testCase{ { name: "different names", @@ -77,7 +77,7 @@ func TestMakeFactoryMap(t *testing.T) { }, { name: "same name", - in: []Factory{p1, p2, NewFactory("p1", nil)}, + in: []Factory{p1, p2, NewFactory(component.MustType("p1"), nil)}, }, } @@ -98,9 +98,9 @@ func TestMakeFactoryMap(t *testing.T) { func TestBuilder(t *testing.T) { defaultCfg := struct{}{} factories, err := MakeFactoryMap([]Factory{ - NewFactory("err", nil), + NewFactory(component.MustType("err"), nil), NewFactory( - "all", + component.MustType("all"), func() component.Config { return &defaultCfg }, WithTraces(createTraces, component.StabilityLevelDevelopment), WithMetrics(createMetrics, component.StabilityLevelAlpha), @@ -116,21 +116,21 @@ func TestBuilder(t *testing.T) { }{ { name: "unknown", - id: component.NewID("unknown"), + id: component.NewID(component.MustType("unknown")), err: "receiver factory not available for: \"unknown\"", }, { name: "err", - id: component.NewID("err"), + id: component.NewID(component.MustType("err")), err: "telemetry type is not supported", }, { name: "all", - id: component.NewID("all"), + id: component.NewID(component.MustType("all")), }, { name: "all/named", - id: component.NewIDWithName("all", "named"), + id: component.NewIDWithName(component.MustType("all"), "named"), }, } @@ -173,7 +173,7 @@ func TestBuilderMissingConfig(t *testing.T) { defaultCfg := struct{}{} factories, err := MakeFactoryMap([]Factory{ NewFactory( - "all", + component.MustType("all"), func() component.Config { return &defaultCfg }, WithTraces(createTraces, component.StabilityLevelDevelopment), WithMetrics(createMetrics, component.StabilityLevelAlpha), @@ -184,7 +184,7 @@ func TestBuilderMissingConfig(t *testing.T) { require.NoError(t, err) bErr := NewBuilder(map[component.ID]component.Config{}, factories) - missingID := component.NewIDWithName("all", "missing") + missingID := component.NewIDWithName(component.MustType("all"), "missing") te, err := bErr.CreateTraces(context.Background(), createSettings(missingID), nil) assert.EqualError(t, err, "receiver \"all/missing\" is not configured") @@ -200,14 +200,14 @@ func TestBuilderMissingConfig(t *testing.T) { } func TestBuilderFactory(t *testing.T) { - factories, err := MakeFactoryMap([]Factory{NewFactory("foo", nil)}...) + factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustType("foo"), nil)}...) require.NoError(t, err) - cfgs := map[component.ID]component.Config{component.NewID("foo"): struct{}{}} + cfgs := map[component.ID]component.Config{component.NewID(component.MustType("foo")): struct{}{}} b := NewBuilder(cfgs, factories) - assert.NotNil(t, b.Factory(component.NewID("foo").Type())) - assert.Nil(t, b.Factory(component.NewID("bar").Type())) + assert.NotNil(t, b.Factory(component.NewID(component.MustType("foo")).Type())) + assert.Nil(t, b.Factory(component.NewID(component.MustType("bar")).Type())) } var nopInstance = &nopReceiver{ diff --git a/receiver/receiverhelper/obsreport_test.go b/receiver/receiverhelper/obsreport_test.go index 3e229cbc07a..4bb7a564edd 100644 --- a/receiver/receiverhelper/obsreport_test.go +++ b/receiver/receiverhelper/obsreport_test.go @@ -25,7 +25,7 @@ const ( ) var ( - receiverID = component.NewID("fakeReceiver") + receiverID = component.NewID(component.MustType("fakeReceiver")) errFake = errors.New("errFake") ) diff --git a/receiver/receivertest/contract_checker_test.go b/receiver/receivertest/contract_checker_test.go index 2212d0b6196..2ca16c1e341 100644 --- a/receiver/receivertest/contract_checker_test.go +++ b/receiver/receivertest/contract_checker_test.go @@ -83,7 +83,7 @@ func (g *exampleGenerator) Generate() []UniqueIDAttrVal { func newExampleFactory() receiver.Factory { return receiver.NewFactory( - "example_receiver", + component.MustType("example_receiver"), func() component.Config { return &exampleReceiverConfig{} }, diff --git a/receiver/receivertest/nop_receiver.go b/receiver/receivertest/nop_receiver.go index 6113bd03c58..09590781abe 100644 --- a/receiver/receivertest/nop_receiver.go +++ b/receiver/receivertest/nop_receiver.go @@ -12,7 +12,7 @@ import ( "go.opentelemetry.io/collector/receiver" ) -const typeStr = "nop" +var componentType = component.MustType("nop") // NewNopCreateSettings returns a new nop settings for Create* functions. func NewNopCreateSettings() receiver.CreateSettings { @@ -25,7 +25,7 @@ func NewNopCreateSettings() receiver.CreateSettings { // NewNopFactory returns a receiver.Factory that constructs nop receivers. func NewNopFactory() receiver.Factory { return receiver.NewFactory( - "nop", + componentType, func() component.Config { return &nopConfig{} }, receiver.WithTraces(createTraces, component.StabilityLevelStable), receiver.WithMetrics(createMetrics, component.StabilityLevelStable), @@ -58,6 +58,6 @@ type nopReceiver struct { func NewNopBuilder() *receiver.Builder { nopFactory := NewNopFactory() return receiver.NewBuilder( - map[component.ID]component.Config{component.NewID(typeStr): nopFactory.CreateDefaultConfig()}, - map[component.Type]receiver.Factory{typeStr: nopFactory}) + map[component.ID]component.Config{component.NewID(componentType): nopFactory.CreateDefaultConfig()}, + map[component.Type]receiver.Factory{componentType: nopFactory}) } diff --git a/receiver/receivertest/nop_receiver_test.go b/receiver/receivertest/nop_receiver_test.go index f2f74d3f17e..0feee2262b6 100644 --- a/receiver/receivertest/nop_receiver_test.go +++ b/receiver/receivertest/nop_receiver_test.go @@ -15,10 +15,12 @@ import ( "go.opentelemetry.io/collector/consumer/consumertest" ) +var nopType = component.MustType("nop") + func TestNewNopFactory(t *testing.T) { factory := NewNopFactory() require.NotNil(t, factory) - assert.Equal(t, component.Type("nop"), factory.Type()) + assert.Equal(t, nopType, factory.Type()) cfg := factory.CreateDefaultConfig() assert.Equal(t, &nopConfig{}, cfg) @@ -45,7 +47,7 @@ func TestNewNopBuilder(t *testing.T) { factory := NewNopFactory() cfg := factory.CreateDefaultConfig() set := NewNopCreateSettings() - set.ID = component.NewID(typeStr) + set.ID = component.NewID(nopType) traces, err := factory.CreateTracesReceiver(context.Background(), set, cfg, consumertest.NewNop()) require.NoError(t, err) diff --git a/receiver/scraperhelper/obsreport.go b/receiver/scraperhelper/obsreport.go index f8d03f5684d..a8ba76b66e7 100644 --- a/receiver/scraperhelper/obsreport.go +++ b/receiver/scraperhelper/obsreport.go @@ -130,7 +130,7 @@ func (s *ObsReport) EndMetricsOp( // end span according to errors if span.IsRecording() { span.SetAttributes( - attribute.String(obsmetrics.FormatKey, string(component.DataTypeMetrics)), + attribute.String(obsmetrics.FormatKey, component.DataTypeMetrics.String()), attribute.Int64(obsmetrics.ScrapedMetricPointsKey, int64(numScrapedMetrics)), attribute.Int64(obsmetrics.ErroredMetricPointsKey, int64(numErroredMetrics)), ) diff --git a/receiver/scraperhelper/obsreport_test.go b/receiver/scraperhelper/obsreport_test.go index e804bb0fa12..b26a228400b 100644 --- a/receiver/scraperhelper/obsreport_test.go +++ b/receiver/scraperhelper/obsreport_test.go @@ -21,8 +21,8 @@ import ( ) var ( - receiverID = component.NewID("fakeReceiver") - scraperID = component.NewID("fakeScraper") + receiverID = component.NewID(component.MustType("fakeReceiver")) + scraperID = component.NewID(component.MustType("fakeScraper")) errFake = errors.New("errFake") partialErrFake = scrapererror.NewPartialScrapeError(errFake, 1) diff --git a/receiver/scraperhelper/scraper.go b/receiver/scraperhelper/scraper.go index 70bfe099d3a..9326e89e518 100644 --- a/receiver/scraperhelper/scraper.go +++ b/receiver/scraperhelper/scraper.go @@ -67,7 +67,7 @@ func NewScraper(name string, scrape ScrapeFunc, options ...ScraperOption) (Scrap } bs := &baseScraper{ ScrapeFunc: scrape, - id: component.NewID(component.Type(name)), + id: component.NewID(component.MustType(name)), } for _, op := range options { op(bs) diff --git a/receiver/scraperhelper/scrapercontroller_test.go b/receiver/scraperhelper/scrapercontroller_test.go index 05005c4453d..3b3a880cc37 100644 --- a/receiver/scraperhelper/scrapercontroller_test.go +++ b/receiver/scraperhelper/scrapercontroller_test.go @@ -134,7 +134,7 @@ func TestScrapeController(t *testing.T) { for _, test := range testCases { test := test t.Run(test.name, func(t *testing.T) { - receiverID := component.NewID("receiver") + receiverID := component.NewID(component.MustType("receiver")) tt, err := componenttest.SetupTelemetry(receiverID) require.NoError(t, err) t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) @@ -326,7 +326,7 @@ func assertScraperViews(t *testing.T, tt componenttest.TestTelemetry, expectedEr } } - require.NoError(t, tt.CheckScraperMetrics(component.NewID("receiver"), component.NewID("scraper"), expectedScraped, expectedErrored)) + require.NoError(t, tt.CheckScraperMetrics(component.NewID(component.MustType("receiver")), component.NewID(component.MustType("scraper")), expectedScraped, expectedErrored)) } func TestSingleScrapePerInterval(t *testing.T) { @@ -337,7 +337,7 @@ func TestSingleScrapePerInterval(t *testing.T) { tickerCh := make(chan time.Time) - scp, err := NewScraper("", tsm.scrape) + scp, err := NewScraper("scaper", tsm.scrape) assert.NoError(t, err) receiver, err := NewScraperControllerReceiver( @@ -379,7 +379,7 @@ func TestScrapeControllerStartsOnInit(t *testing.T) { ch: make(chan int, 1), } - scp, err := NewScraper("", tsm.scrape) + scp, err := NewScraper("scraper", tsm.scrape) require.NoError(t, err, "Must not error when creating scraper") r, err := NewScraperControllerReceiver( diff --git a/receiver/scraperhelper/settings_test.go b/receiver/scraperhelper/settings_test.go index 0fa0d57f915..a8456e2b0c6 100644 --- a/receiver/scraperhelper/settings_test.go +++ b/receiver/scraperhelper/settings_test.go @@ -8,6 +8,7 @@ import ( "time" "github.com/stretchr/testify/assert" + "go.opentelemetry.io/collector/component" ) func TestScrapeControllerSettings(t *testing.T) { @@ -20,7 +21,7 @@ func TestScrapeControllerSettings(t *testing.T) { }{ { name: "default configuration", - set: NewDefaultScraperControllerSettings(""), + set: NewDefaultScraperControllerSettings(component.MustType("test")), errVal: "", }, { diff --git a/service/config_test.go b/service/config_test.go index c3b659d0dec..a2488896a1f 100644 --- a/service/config_test.go +++ b/service/config_test.go @@ -42,7 +42,7 @@ func TestConfigValidate(t *testing.T) { name: "duplicate-processor-reference", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Pipelines[component.NewID("traces")] + pipe := cfg.Pipelines[component.NewID(component.MustType("traces"))] pipe.Processors = append(pipe.Processors, pipe.Processors...) return cfg }, @@ -52,10 +52,10 @@ func TestConfigValidate(t *testing.T) { name: "invalid-service-pipeline-type", cfgFn: func() *Config { cfg := generateConfig() - cfg.Pipelines[component.NewID("wrongtype")] = &pipelines.PipelineConfig{ - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("nop")}, + cfg.Pipelines[component.NewID(component.MustType("wrongtype"))] = &pipelines.PipelineConfig{ + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, } return cfg }, @@ -99,12 +99,12 @@ func generateConfig() *Config { Address: ":8080", }, }, - Extensions: extensions.Config{component.NewID("nop")}, + Extensions: extensions.Config{component.NewID(component.MustType("nop"))}, Pipelines: pipelines.Config{ - component.NewID("traces"): { - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, } diff --git a/service/extensions/extensions_test.go b/service/extensions/extensions_test.go index e2a0db4275f..cb44a4f2f99 100644 --- a/service/extensions/extensions_test.go +++ b/service/extensions/extensions_test.go @@ -38,17 +38,17 @@ func TestBuildExtensions(t *testing.T) { { name: "extension_not_configured", config: Config{ - component.NewID("myextension"), + component.NewID(component.MustType("myextension")), }, wantErrMsg: "failed to create extension \"myextension\": extension \"myextension\" is not configured", }, { name: "missing_extension_factory", extensionsConfigs: map[component.ID]component.Config{ - component.NewID("unknown"): nopExtensionConfig, + component.NewID(component.MustType("unknown")): nopExtensionConfig, }, config: Config{ - component.NewID("unknown"), + component.NewID(component.MustType("unknown")), }, wantErrMsg: "failed to create extension \"unknown\": extension factory not available for: \"unknown\"", }, @@ -212,11 +212,11 @@ func TestNotifyConfig(t *testing.T) { notificationError := errors.New("Error processing config") nopExtensionFactory := extensiontest.NewNopFactory() nopExtensionConfig := nopExtensionFactory.CreateDefaultConfig() - n1ExtensionFactory := newConfigWatcherExtensionFactory("notifiable1", func() error { return nil }) + n1ExtensionFactory := newConfigWatcherExtensionFactory(component.MustType("notifiable1"), func() error { return nil }) n1ExtensionConfig := n1ExtensionFactory.CreateDefaultConfig() - n2ExtensionFactory := newConfigWatcherExtensionFactory("notifiable2", func() error { return nil }) + n2ExtensionFactory := newConfigWatcherExtensionFactory(component.MustType("notifiable2"), func() error { return nil }) n2ExtensionConfig := n1ExtensionFactory.CreateDefaultConfig() - nErrExtensionFactory := newConfigWatcherExtensionFactory("notifiableErr", func() error { return notificationError }) + nErrExtensionFactory := newConfigWatcherExtensionFactory(component.MustType("notifiableErr"), func() error { return notificationError }) nErrExtensionConfig := nErrExtensionFactory.CreateDefaultConfig() tests := []struct { @@ -230,52 +230,52 @@ func TestNotifyConfig(t *testing.T) { { name: "No notifiable extensions", factories: map[component.Type]extension.Factory{ - "nop": nopExtensionFactory, + component.MustType("nop"): nopExtensionFactory, }, extensionsConfigs: map[component.ID]component.Config{ - component.NewID("nop"): nopExtensionConfig, + component.NewID(component.MustType("nop")): nopExtensionConfig, }, serviceExtensions: []component.ID{ - component.NewID("nop"), + component.NewID(component.MustType("nop")), }, }, { name: "One notifiable extension", factories: map[component.Type]extension.Factory{ - "notifiable1": n1ExtensionFactory, + component.MustType("notifiable1"): n1ExtensionFactory, }, extensionsConfigs: map[component.ID]component.Config{ - component.NewID("notifiable1"): n1ExtensionConfig, + component.NewID(component.MustType("notifiable1")): n1ExtensionConfig, }, serviceExtensions: []component.ID{ - component.NewID("notifiable1"), + component.NewID(component.MustType("notifiable1")), }, }, { name: "Multiple notifiable extensions", factories: map[component.Type]extension.Factory{ - "notifiable1": n1ExtensionFactory, - "notifiable2": n2ExtensionFactory, + component.MustType("notifiable1"): n1ExtensionFactory, + component.MustType("notifiable2"): n2ExtensionFactory, }, extensionsConfigs: map[component.ID]component.Config{ - component.NewID("notifiable1"): n1ExtensionConfig, - component.NewID("notifiable2"): n2ExtensionConfig, + component.NewID(component.MustType("notifiable1")): n1ExtensionConfig, + component.NewID(component.MustType("notifiable2")): n2ExtensionConfig, }, serviceExtensions: []component.ID{ - component.NewID("notifiable1"), - component.NewID("notifiable2"), + component.NewID(component.MustType("notifiable1")), + component.NewID(component.MustType("notifiable2")), }, }, { name: "Errors in extension notification", factories: map[component.Type]extension.Factory{ - "notifiableErr": nErrExtensionFactory, + component.MustType("notifiableErr"): nErrExtensionFactory, }, extensionsConfigs: map[component.ID]component.Config{ - component.NewID("notifiableErr"): nErrExtensionConfig, + component.NewID(component.MustType("notifiableErr")): nErrExtensionConfig, }, serviceExtensions: []component.ID{ - component.NewID("notifiableErr"), + component.NewID(component.MustType("notifiableErr")), }, want: notificationError, }, @@ -335,7 +335,7 @@ func newConfigWatcherExtensionFactory(name component.Type, fn func() error) exte func newBadExtensionFactory() extension.Factory { return extension.NewFactory( - "bf", + component.MustType("bf"), func() component.Config { return &struct{}{} }, @@ -348,7 +348,7 @@ func newBadExtensionFactory() extension.Factory { func newCreateErrorExtensionFactory() extension.Factory { return extension.NewFactory( - "err", + component.MustType("err"), func() component.Config { return &struct{}{} }, @@ -410,14 +410,15 @@ func TestStatusReportedOnStartupShutdown(t *testing.T) { }, } { t.Run(tc.name, func(t *testing.T) { - compID := component.NewID("statustest") - factory := newStatusTestExtensionFactory("statustest", tc.startErr, tc.shutdownErr) + statusType := component.MustType("statustest") + compID := component.NewID(statusType) + factory := newStatusTestExtensionFactory(statusType, tc.startErr, tc.shutdownErr) config := factory.CreateDefaultConfig() extensionsConfigs := map[component.ID]component.Config{ compID: config, } factories := map[component.Type]extension.Factory{ - "statustest": factory, + statusType: factory, } extensions, err := New( context.Background(), @@ -484,7 +485,7 @@ func newStatusTestExtensionFactory(name component.Type, startErr, shutdownErr er func newRecordingExtensionFactory(startCallback func(set extension.CreateSettings, host component.Host) error, shutdownCallback func(set extension.CreateSettings) error) extension.Factory { return extension.NewFactory( - "recording", + component.MustType("recording"), func() component.Config { return &recordingExtensionConfig{} }, @@ -519,7 +520,7 @@ func (ext *recordingExtension) Dependencies() []component.ID { } deps := make([]component.ID, len(ext.config.dependencies)) for i, dep := range ext.config.dependencies { - deps[i] = component.NewIDWithName("recording", dep) + deps[i] = component.NewIDWithName(component.MustType("recording"), dep) } return deps } diff --git a/service/internal/components/loggers.go b/service/internal/components/loggers.go index 026d4e189b2..f4178977b2d 100644 --- a/service/internal/components/loggers.go +++ b/service/internal/components/loggers.go @@ -25,7 +25,7 @@ func ReceiverLogger(logger *zap.Logger, id component.ID, dt component.DataType) return logger.With( zap.String(zapKindKey, strings.ToLower(component.KindReceiver.String())), zap.String(zapNameKey, id.String()), - zap.String(zapDataTypeKey, string(dt))) + zap.String(zapDataTypeKey, dt.String())) } func ProcessorLogger(logger *zap.Logger, id component.ID, pipelineID component.ID) *zap.Logger { @@ -38,7 +38,7 @@ func ProcessorLogger(logger *zap.Logger, id component.ID, pipelineID component.I func ExporterLogger(logger *zap.Logger, id component.ID, dt component.DataType) *zap.Logger { return logger.With( zap.String(zapKindKey, strings.ToLower(component.KindExporter.String())), - zap.String(zapDataTypeKey, string(dt)), + zap.String(zapDataTypeKey, dt.String()), zap.String(zapNameKey, id.String())) } @@ -52,6 +52,6 @@ func ConnectorLogger(logger *zap.Logger, id component.ID, expDT, rcvDT component return logger.With( zap.String(zapKindKey, strings.ToLower(component.KindConnector.String())), zap.String(zapNameKey, id.String()), - zap.String(zapExporterInPipeline, string(expDT)), - zap.String(zapReceiverInPipeline, string(rcvDT))) + zap.String(zapExporterInPipeline, expDT.String()), + zap.String(zapReceiverInPipeline, rcvDT.String())) } diff --git a/service/internal/graph/graph_test.go b/service/internal/graph/graph_test.go index 84c922f407e..7867d67e1c7 100644 --- a/service/internal/graph/graph_test.go +++ b/service/internal/graph/graph_test.go @@ -90,48 +90,48 @@ func TestGraphStartStop(t *testing.T) { { name: "single", edges: [][2]component.ID{ - {component.NewIDWithName("r", "1"), component.NewIDWithName("p", "1")}, - {component.NewIDWithName("r", "2"), component.NewIDWithName("p", "1")}, - {component.NewIDWithName("p", "1"), component.NewIDWithName("p", "2")}, - {component.NewIDWithName("p", "2"), component.NewIDWithName("e", "1")}, - {component.NewIDWithName("p", "1"), component.NewIDWithName("e", "2")}, + {component.NewIDWithName(component.MustType("r"), "1"), component.NewIDWithName(component.MustType("p"), "1")}, + {component.NewIDWithName(component.MustType("r"), "2"), component.NewIDWithName(component.MustType("p"), "1")}, + {component.NewIDWithName(component.MustType("p"), "1"), component.NewIDWithName(component.MustType("p"), "2")}, + {component.NewIDWithName(component.MustType("p"), "2"), component.NewIDWithName(component.MustType("e"), "1")}, + {component.NewIDWithName(component.MustType("p"), "1"), component.NewIDWithName(component.MustType("e"), "2")}, }, }, { name: "multi", edges: [][2]component.ID{ // Pipeline 1 - {component.NewIDWithName("r", "1"), component.NewIDWithName("p", "1")}, - {component.NewIDWithName("r", "2"), component.NewIDWithName("p", "1")}, - {component.NewIDWithName("p", "1"), component.NewIDWithName("p", "2")}, - {component.NewIDWithName("p", "2"), component.NewIDWithName("e", "1")}, - {component.NewIDWithName("p", "1"), component.NewIDWithName("e", "2")}, + {component.NewIDWithName(component.MustType("r"), "1"), component.NewIDWithName(component.MustType("p"), "1")}, + {component.NewIDWithName(component.MustType("r"), "2"), component.NewIDWithName(component.MustType("p"), "1")}, + {component.NewIDWithName(component.MustType("p"), "1"), component.NewIDWithName(component.MustType("p"), "2")}, + {component.NewIDWithName(component.MustType("p"), "2"), component.NewIDWithName(component.MustType("e"), "1")}, + {component.NewIDWithName(component.MustType("p"), "1"), component.NewIDWithName(component.MustType("e"), "2")}, // Pipeline 2, shares r1 and e2 - {component.NewIDWithName("r", "1"), component.NewIDWithName("p", "3")}, - {component.NewIDWithName("p", "3"), component.NewIDWithName("e", "2")}, + {component.NewIDWithName(component.MustType("r"), "1"), component.NewIDWithName(component.MustType("p"), "3")}, + {component.NewIDWithName(component.MustType("p"), "3"), component.NewIDWithName(component.MustType("e"), "2")}, }, }, { name: "connected", edges: [][2]component.ID{ // Pipeline 1 - {component.NewIDWithName("r", "1"), component.NewIDWithName("p", "1")}, - {component.NewIDWithName("r", "2"), component.NewIDWithName("p", "1")}, - {component.NewIDWithName("p", "1"), component.NewIDWithName("p", "2")}, - {component.NewIDWithName("p", "2"), component.NewIDWithName("e", "1")}, - {component.NewIDWithName("p", "1"), component.NewIDWithName("c", "1")}, + {component.NewIDWithName(component.MustType("r"), "1"), component.NewIDWithName(component.MustType("p"), "1")}, + {component.NewIDWithName(component.MustType("r"), "2"), component.NewIDWithName(component.MustType("p"), "1")}, + {component.NewIDWithName(component.MustType("p"), "1"), component.NewIDWithName(component.MustType("p"), "2")}, + {component.NewIDWithName(component.MustType("p"), "2"), component.NewIDWithName(component.MustType("e"), "1")}, + {component.NewIDWithName(component.MustType("p"), "1"), component.NewIDWithName(component.MustType("c"), "1")}, // Pipeline 2, shares r1 and c1 - {component.NewIDWithName("r", "1"), component.NewIDWithName("p", "3")}, - {component.NewIDWithName("p", "3"), component.NewIDWithName("c", "1")}, + {component.NewIDWithName(component.MustType("r"), "1"), component.NewIDWithName(component.MustType("p"), "3")}, + {component.NewIDWithName(component.MustType("p"), "3"), component.NewIDWithName(component.MustType("c"), "1")}, // Pipeline 3, emits to e2 and c2 - {component.NewIDWithName("c", "1"), component.NewIDWithName("e", "2")}, - {component.NewIDWithName("c", "1"), component.NewIDWithName("c", "2")}, + {component.NewIDWithName(component.MustType("c"), "1"), component.NewIDWithName(component.MustType("e"), "2")}, + {component.NewIDWithName(component.MustType("c"), "1"), component.NewIDWithName(component.MustType("c"), "2")}, // Pipeline 4, also emits to e2 - {component.NewIDWithName("c", "2"), component.NewIDWithName("e", "2")}, + {component.NewIDWithName(component.MustType("c"), "2"), component.NewIDWithName(component.MustType("e"), "2")}, }, }, } @@ -171,10 +171,10 @@ func TestGraphStartStop(t *testing.T) { func TestGraphStartStopCycle(t *testing.T) { pg := &Graph{componentGraph: simple.NewDirectedGraph()} - r1 := &testNode{id: component.NewIDWithName("r", "1")} - p1 := &testNode{id: component.NewIDWithName("p", "1")} - c1 := &testNode{id: component.NewIDWithName("c", "1")} - e1 := &testNode{id: component.NewIDWithName("e", "1")} + r1 := &testNode{id: component.NewIDWithName(component.MustType("r"), "1")} + p1 := &testNode{id: component.NewIDWithName(component.MustType("p"), "1")} + c1 := &testNode{id: component.NewIDWithName(component.MustType("c"), "1")} + e1 := &testNode{id: component.NewIDWithName(component.MustType("e"), "1")} pg.instanceIDs = map[int64]*component.InstanceID{ r1.ID(): {}, @@ -201,11 +201,11 @@ func TestGraphStartStopComponentError(t *testing.T) { pg := &Graph{componentGraph: simple.NewDirectedGraph()} pg.telemetry = servicetelemetry.NewNopTelemetrySettings() r1 := &testNode{ - id: component.NewIDWithName("r", "1"), + id: component.NewIDWithName(component.MustType("r"), "1"), startErr: errors.New("foo"), } e1 := &testNode{ - id: component.NewIDWithName("e", "1"), + id: component.NewIDWithName(component.MustType("e"), "1"), shutdownErr: errors.New("bar"), } pg.instanceIDs = map[int64]*component.InstanceID{ @@ -229,20 +229,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_simple.yaml", pipelineConfigs: pipelines.Config{ - component.NewID("traces"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewID("metrics"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewID("logs"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("logs")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -250,20 +250,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_simple_mutate.yaml", pipelineConfigs: pipelines.Config{ - component.NewID("traces"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewID("metrics"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewID("logs"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("logs")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -271,20 +271,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_simple_multi_proc.yaml", pipelineConfigs: pipelines.Config{ - component.NewID("traces"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewID("exampleprocessor"), component.NewIDWithName("exampleprocessor", "mutate")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor")), component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewID("metrics"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewID("exampleprocessor"), component.NewIDWithName("exampleprocessor", "mutate")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor")), component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewID("logs"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewID("exampleprocessor"), component.NewIDWithName("exampleprocessor", "mutate")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("logs")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor")), component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -292,17 +292,17 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_simple_no_proc.yaml", pipelineConfigs: pipelines.Config{ - component.NewID("traces"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewID("metrics"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewID("logs"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("logs")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -310,20 +310,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_multi.yaml", pipelineConfigs: pipelines.Config{ - component.NewID("traces"): { - Receivers: []component.ID{component.NewID("examplereceiver"), component.NewIDWithName("examplereceiver", "1")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate"), component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter"), component.NewIDWithName("exampleexporter", "1")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver")), component.NewIDWithName(component.MustType("examplereceiver"), "1")}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate"), component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter")), component.NewIDWithName(component.MustType("exampleexporter"), "1")}, }, - component.NewID("metrics"): { - Receivers: []component.ID{component.NewID("examplereceiver"), component.NewIDWithName("examplereceiver", "1")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate"), component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter"), component.NewIDWithName("exampleexporter", "1")}, + component.NewID(component.MustType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver")), component.NewIDWithName(component.MustType("examplereceiver"), "1")}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate"), component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter")), component.NewIDWithName(component.MustType("exampleexporter"), "1")}, }, - component.NewID("logs"): { - Receivers: []component.ID{component.NewID("examplereceiver"), component.NewIDWithName("examplereceiver", "1")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate"), component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter"), component.NewIDWithName("exampleexporter", "1")}, + component.NewID(component.MustType("logs")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver")), component.NewIDWithName(component.MustType("examplereceiver"), "1")}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate"), component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter")), component.NewIDWithName(component.MustType("exampleexporter"), "1")}, }, }, expectedPerExporter: 2, @@ -331,17 +331,17 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_multi_no_proc.yaml", pipelineConfigs: pipelines.Config{ - component.NewID("traces"): { - Receivers: []component.ID{component.NewID("examplereceiver"), component.NewIDWithName("examplereceiver", "1")}, - Exporters: []component.ID{component.NewID("exampleexporter"), component.NewIDWithName("exampleexporter", "1")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver")), component.NewIDWithName(component.MustType("examplereceiver"), "1")}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter")), component.NewIDWithName(component.MustType("exampleexporter"), "1")}, }, - component.NewID("metrics"): { - Receivers: []component.ID{component.NewID("examplereceiver"), component.NewIDWithName("examplereceiver", "1")}, - Exporters: []component.ID{component.NewID("exampleexporter"), component.NewIDWithName("exampleexporter", "1")}, + component.NewID(component.MustType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver")), component.NewIDWithName(component.MustType("examplereceiver"), "1")}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter")), component.NewIDWithName(component.MustType("exampleexporter"), "1")}, }, - component.NewID("logs"): { - Receivers: []component.ID{component.NewID("examplereceiver"), component.NewIDWithName("examplereceiver", "1")}, - Exporters: []component.ID{component.NewID("exampleexporter"), component.NewIDWithName("exampleexporter", "1")}, + component.NewID(component.MustType("logs")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver")), component.NewIDWithName(component.MustType("examplereceiver"), "1")}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter")), component.NewIDWithName(component.MustType("exampleexporter"), "1")}, }, }, expectedPerExporter: 2, @@ -349,32 +349,32 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "multi_pipeline_receivers_and_exporters.yaml", pipelineConfigs: pipelines.Config{ - component.NewID("traces"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewIDWithName("traces", "1"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("traces"), "1"): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewID("metrics"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewIDWithName("metrics", "1"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("metrics"), "1"): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewID("logs"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("logs")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewIDWithName("logs", "1"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("logs"), "1"): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, }, expectedPerExporter: 2, @@ -382,15 +382,15 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_simple_traces.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName("traces", "in"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, + component.NewIDWithName(component.MustType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName("traces", "out"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("traces"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -398,15 +398,15 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_simple_metrics.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName("metrics", "in"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, + component.NewIDWithName(component.MustType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName("metrics", "out"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("metrics"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -414,15 +414,15 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_simple_logs.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName("logs", "in"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, + component.NewIDWithName(component.MustType("logs"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName("logs", "out"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("logs"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -430,25 +430,25 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_fork_merge_traces.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName("traces", "in"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, + component.NewIDWithName(component.MustType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName("traces", "type0"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "merge")}, + component.NewIDWithName(component.MustType("traces"), "type0"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "merge")}, }, - component.NewIDWithName("traces", "type1"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "merge")}, + component.NewIDWithName(component.MustType("traces"), "type1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "merge")}, }, - component.NewIDWithName("traces", "out"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "merge")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("traces"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "merge")}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, }, expectedPerExporter: 2, @@ -456,25 +456,25 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_fork_merge_metrics.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName("metrics", "in"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, + component.NewIDWithName(component.MustType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName("metrics", "type0"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "merge")}, + component.NewIDWithName(component.MustType("metrics"), "type0"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "merge")}, }, - component.NewIDWithName("metrics", "type1"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "merge")}, + component.NewIDWithName(component.MustType("metrics"), "type1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "merge")}, }, - component.NewIDWithName("metrics", "out"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "merge")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("metrics"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "merge")}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, }, expectedPerExporter: 2, @@ -482,25 +482,25 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_fork_merge_logs.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName("logs", "in"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, + component.NewIDWithName(component.MustType("logs"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName("logs", "type0"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "merge")}, + component.NewIDWithName(component.MustType("logs"), "type0"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "merge")}, }, - component.NewIDWithName("logs", "type1"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "merge")}, + component.NewIDWithName(component.MustType("logs"), "type1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "merge")}, }, - component.NewIDWithName("logs", "out"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "merge")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("logs"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "merge")}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, }, expectedPerExporter: 2, @@ -508,20 +508,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_translate_from_traces.yaml", pipelineConfigs: pipelines.Config{ - component.NewID("traces"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleconnector")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleconnector"))}, }, - component.NewID("metrics"): { - Receivers: []component.ID{component.NewID("exampleconnector")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustType("exampleconnector"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewID("logs"): { - Receivers: []component.ID{component.NewID("exampleconnector")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("logs")): { + Receivers: []component.ID{component.NewID(component.MustType("exampleconnector"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -529,20 +529,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_translate_from_metrics.yaml", pipelineConfigs: pipelines.Config{ - component.NewID("metrics"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleconnector")}, + component.NewID(component.MustType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleconnector"))}, }, - component.NewID("traces"): { - Receivers: []component.ID{component.NewID("exampleconnector")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewID(component.MustType("exampleconnector"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewID("logs"): { - Receivers: []component.ID{component.NewID("exampleconnector")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("logs")): { + Receivers: []component.ID{component.NewID(component.MustType("exampleconnector"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -550,20 +550,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_translate_from_logs.yaml", pipelineConfigs: pipelines.Config{ - component.NewID("logs"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleconnector")}, + component.NewID(component.MustType("logs")): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleconnector"))}, }, - component.NewID("traces"): { - Receivers: []component.ID{component.NewID("exampleconnector")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewID(component.MustType("exampleconnector"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewID("metrics"): { - Receivers: []component.ID{component.NewID("exampleconnector")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewID(component.MustType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustType("exampleconnector"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -571,35 +571,35 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_matrix.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName("traces", "in"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate")}, - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, + component.NewIDWithName(component.MustType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName("metrics", "in"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate")}, - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, + component.NewIDWithName(component.MustType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName("logs", "in"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate")}, - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, + component.NewIDWithName(component.MustType("logs"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName("traces", "out"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("traces"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewIDWithName("metrics", "out"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("metrics"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewIDWithName("logs", "out"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("logs"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, }, expectedPerExporter: 3, @@ -607,29 +607,29 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_lanes.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName("traces", "in"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Exporters: []component.ID{component.NewID("mockforward")}, + component.NewIDWithName(component.MustType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Exporters: []component.ID{component.NewID(component.MustType("mockforward"))}, }, - component.NewIDWithName("traces", "out"): { - Receivers: []component.ID{component.NewID("mockforward")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("traces"), "out"): { + Receivers: []component.ID{component.NewID(component.MustType("mockforward"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewIDWithName("metrics", "in"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Exporters: []component.ID{component.NewID("mockforward")}, + component.NewIDWithName(component.MustType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Exporters: []component.ID{component.NewID(component.MustType("mockforward"))}, }, - component.NewIDWithName("metrics", "out"): { - Receivers: []component.ID{component.NewID("mockforward")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("metrics"), "out"): { + Receivers: []component.ID{component.NewID(component.MustType("mockforward"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewIDWithName("logs", "in"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Exporters: []component.ID{component.NewID("mockforward")}, + component.NewIDWithName(component.MustType("logs"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Exporters: []component.ID{component.NewID(component.MustType("mockforward"))}, }, - component.NewIDWithName("logs", "out"): { - Receivers: []component.ID{component.NewID("mockforward")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("logs"), "out"): { + Receivers: []component.ID{component.NewID(component.MustType("mockforward"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -637,25 +637,25 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_mutate_traces.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName("traces", "in"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, + component.NewIDWithName(component.MustType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName("traces", "out0"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("traces"), "out0"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewIDWithName("traces", "middle"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "mutate")}, + component.NewIDWithName(component.MustType("traces"), "middle"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "mutate")}, }, - component.NewIDWithName("traces", "out1"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "mutate")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("traces"), "out1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "mutate")}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, }, expectedPerExporter: 2, @@ -663,25 +663,25 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_mutate_metrics.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName("metrics", "in"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, + component.NewIDWithName(component.MustType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName("metrics", "out0"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("metrics"), "out0"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewIDWithName("metrics", "middle"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "mutate")}, + component.NewIDWithName(component.MustType("metrics"), "middle"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "mutate")}, }, - component.NewIDWithName("metrics", "out1"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "mutate")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("metrics"), "out1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "mutate")}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, }, expectedPerExporter: 2, @@ -689,25 +689,25 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_mutate_logs.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName("logs", "in"): { - Receivers: []component.ID{component.NewID("examplereceiver")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, + component.NewIDWithName(component.MustType("logs"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName("logs", "out0"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("logs"), "out0"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, - component.NewIDWithName("logs", "middle"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "inherit_mutate")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewIDWithName("exampleconnector", "mutate")}, + component.NewIDWithName(component.MustType("logs"), "middle"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "mutate")}, }, - component.NewIDWithName("logs", "out1"): { - Receivers: []component.ID{component.NewIDWithName("exampleconnector", "mutate")}, - Processors: []component.ID{component.NewID("exampleprocessor")}, - Exporters: []component.ID{component.NewID("exampleexporter")}, + component.NewIDWithName(component.MustType("logs"), "out1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "mutate")}, + Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, }, }, expectedPerExporter: 2, @@ -722,8 +722,8 @@ func TestConnectorPipelinesGraph(t *testing.T) { BuildInfo: component.NewDefaultBuildInfo(), ReceiverBuilder: receiver.NewBuilder( map[component.ID]component.Config{ - component.NewID("examplereceiver"): testcomponents.ExampleReceiverFactory.CreateDefaultConfig(), - component.NewIDWithName("examplereceiver", "1"): testcomponents.ExampleReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("examplereceiver")): testcomponents.ExampleReceiverFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("examplereceiver"), "1"): testcomponents.ExampleReceiverFactory.CreateDefaultConfig(), }, map[component.Type]receiver.Factory{ testcomponents.ExampleReceiverFactory.Type(): testcomponents.ExampleReceiverFactory, @@ -731,8 +731,8 @@ func TestConnectorPipelinesGraph(t *testing.T) { ), ProcessorBuilder: processor.NewBuilder( map[component.ID]component.Config{ - component.NewID("exampleprocessor"): testcomponents.ExampleProcessorFactory.CreateDefaultConfig(), - component.NewIDWithName("exampleprocessor", "mutate"): testcomponents.ExampleProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("exampleprocessor")): testcomponents.ExampleProcessorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("exampleprocessor"), "mutate"): testcomponents.ExampleProcessorFactory.CreateDefaultConfig(), }, map[component.Type]processor.Factory{ testcomponents.ExampleProcessorFactory.Type(): testcomponents.ExampleProcessorFactory, @@ -740,8 +740,8 @@ func TestConnectorPipelinesGraph(t *testing.T) { ), ExporterBuilder: exporter.NewBuilder( map[component.ID]component.Config{ - component.NewID("exampleexporter"): testcomponents.ExampleExporterFactory.CreateDefaultConfig(), - component.NewIDWithName("exampleexporter", "1"): testcomponents.ExampleExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("exampleexporter")): testcomponents.ExampleExporterFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("exampleexporter"), "1"): testcomponents.ExampleExporterFactory.CreateDefaultConfig(), }, map[component.Type]exporter.Factory{ testcomponents.ExampleExporterFactory.Type(): testcomponents.ExampleExporterFactory, @@ -749,11 +749,11 @@ func TestConnectorPipelinesGraph(t *testing.T) { ), ConnectorBuilder: connector.NewBuilder( map[component.ID]component.Config{ - component.NewID("exampleconnector"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName("exampleconnector", "merge"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName("exampleconnector", "mutate"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName("exampleconnector", "inherit_mutate"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), - component.NewID("mockforward"): testcomponents.MockForwardConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("exampleconnector")): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("exampleconnector"), "merge"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("exampleconnector"), "mutate"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("mockforward")): testcomponents.MockForwardConnectorFactory.CreateDefaultConfig(), }, map[component.Type]connector.Factory{ testcomponents.ExampleConnectorFactory.Type(): testcomponents.ExampleConnectorFactory, @@ -984,24 +984,24 @@ func TestConnectorPipelinesGraph(t *testing.T) { } func TestConnectorRouter(t *testing.T) { - rcvrID := component.NewID("examplereceiver") - routeTracesID := component.NewIDWithName("examplerouter", "traces") - routeMetricsID := component.NewIDWithName("examplerouter", "metrics") - routeLogsID := component.NewIDWithName("examplerouter", "logs") - expRightID := component.NewIDWithName("exampleexporter", "right") - expLeftID := component.NewIDWithName("exampleexporter", "left") + rcvrID := component.NewID(component.MustType("examplereceiver")) + routeTracesID := component.NewIDWithName(component.MustType("examplerouter"), "traces") + routeMetricsID := component.NewIDWithName(component.MustType("examplerouter"), "metrics") + routeLogsID := component.NewIDWithName(component.MustType("examplerouter"), "logs") + expRightID := component.NewIDWithName(component.MustType("exampleexporter"), "right") + expLeftID := component.NewIDWithName(component.MustType("exampleexporter"), "left") - tracesInID := component.NewIDWithName("traces", "in") - tracesRightID := component.NewIDWithName("traces", "right") - tracesLeftID := component.NewIDWithName("traces", "left") + tracesInID := component.NewIDWithName(component.MustType("traces"), "in") + tracesRightID := component.NewIDWithName(component.MustType("traces"), "right") + tracesLeftID := component.NewIDWithName(component.MustType("traces"), "left") - metricsInID := component.NewIDWithName("metrics", "in") - metricsRightID := component.NewIDWithName("metrics", "right") - metricsLeftID := component.NewIDWithName("metrics", "left") + metricsInID := component.NewIDWithName(component.MustType("metrics"), "in") + metricsRightID := component.NewIDWithName(component.MustType("metrics"), "right") + metricsLeftID := component.NewIDWithName(component.MustType("metrics"), "left") - logsInID := component.NewIDWithName("logs", "in") - logsRightID := component.NewIDWithName("logs", "right") - logsLeftID := component.NewIDWithName("logs", "left") + logsInID := component.NewIDWithName(component.MustType("logs"), "in") + logsRightID := component.NewIDWithName(component.MustType("logs"), "right") + logsLeftID := component.NewIDWithName(component.MustType("logs"), "left") ctx := context.Background() set := Settings{ @@ -1188,15 +1188,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_exporter_logs", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("bf"): badExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("bf")): badExporterFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID("logs"): { - Receivers: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("bf")}, + component.NewID(component.MustType("logs")): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("bf"))}, }, }, expected: "failed to create \"bf\" exporter for data type \"logs\": telemetry type is not supported", @@ -1204,15 +1204,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_exporter_metrics", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("bf"): badExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("bf")): badExporterFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID("metrics"): { - Receivers: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("bf")}, + component.NewID(component.MustType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("bf"))}, }, }, expected: "failed to create \"bf\" exporter for data type \"metrics\": telemetry type is not supported", @@ -1220,15 +1220,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_exporter_traces", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("bf"): badExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("bf")): badExporterFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID("traces"): { - Receivers: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("bf")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("bf"))}, }, }, expected: "failed to create \"bf\" exporter for data type \"traces\": telemetry type is not supported", @@ -1236,19 +1236,19 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_processor_logs", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID("bf"): badProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("bf")): badProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID("logs"): { - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("bf")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewID(component.MustType("logs")): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Processors: []component.ID{component.NewID(component.MustType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "failed to create \"bf\" processor, in pipeline \"logs\": telemetry type is not supported", @@ -1256,19 +1256,19 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_processor_metrics", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID("bf"): badProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("bf")): badProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID("metrics"): { - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("bf")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewID(component.MustType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Processors: []component.ID{component.NewID(component.MustType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "failed to create \"bf\" processor, in pipeline \"metrics\": telemetry type is not supported", @@ -1276,19 +1276,19 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_processor_traces", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID("bf"): badProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("bf")): badProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID("traces"): { - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("bf")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Processors: []component.ID{component.NewID(component.MustType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "failed to create \"bf\" processor, in pipeline \"traces\": telemetry type is not supported", @@ -1296,15 +1296,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_receiver_logs", receiverCfgs: map[component.ID]component.Config{ - component.NewID("bf"): badReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("bf")): badReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID("logs"): { - Receivers: []component.ID{component.NewID("bf")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewID(component.MustType("logs")): { + Receivers: []component.ID{component.NewID(component.MustType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "failed to create \"bf\" receiver for data type \"logs\": telemetry type is not supported", @@ -1312,15 +1312,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_receiver_metrics", receiverCfgs: map[component.ID]component.Config{ - component.NewID("bf"): badReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("bf")): badReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID("metrics"): { - Receivers: []component.ID{component.NewID("bf")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewID(component.MustType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "failed to create \"bf\" receiver for data type \"metrics\": telemetry type is not supported", @@ -1328,15 +1328,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_receiver_traces", receiverCfgs: map[component.ID]component.Config{ - component.NewID("bf"): badReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("bf")): badReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID("traces"): { - Receivers: []component.ID{component.NewID("bf")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewID(component.MustType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "failed to create \"bf\" receiver for data type \"traces\": telemetry type is not supported", @@ -1344,22 +1344,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_traces_traces.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID("bf"): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("bf")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName("traces", "in"): { - Receivers: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("bf")}, + component.NewIDWithName(component.MustType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("bf"))}, }, - component.NewIDWithName("traces", "out"): { - Receivers: []component.ID{component.NewID("bf")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewIDWithName(component.MustType("traces"), "out"): { + Receivers: []component.ID{component.NewID(component.MustType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "connector \"bf\" used as exporter in traces pipeline but not used in any supported receiver pipeline", @@ -1367,22 +1367,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_traces_metrics.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID("bf"): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("bf")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName("traces", "in"): { - Receivers: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("bf")}, + component.NewIDWithName(component.MustType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("bf"))}, }, - component.NewIDWithName("metrics", "out"): { - Receivers: []component.ID{component.NewID("bf")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewIDWithName(component.MustType("metrics"), "out"): { + Receivers: []component.ID{component.NewID(component.MustType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "connector \"bf\" used as exporter in traces pipeline but not used in any supported receiver pipeline", @@ -1390,22 +1390,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_traces_logs.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID("bf"): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("bf")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName("traces", "in"): { - Receivers: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("bf")}, + component.NewIDWithName(component.MustType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("bf"))}, }, - component.NewIDWithName("logs", "out"): { - Receivers: []component.ID{component.NewID("bf")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewIDWithName(component.MustType("logs"), "out"): { + Receivers: []component.ID{component.NewID(component.MustType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "connector \"bf\" used as exporter in traces pipeline but not used in any supported receiver pipeline", @@ -1413,22 +1413,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_metrics_traces.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID("bf"): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("bf")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName("metrics", "in"): { - Receivers: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("bf")}, + component.NewIDWithName(component.MustType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("bf"))}, }, - component.NewIDWithName("traces", "out"): { - Receivers: []component.ID{component.NewID("bf")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewIDWithName(component.MustType("traces"), "out"): { + Receivers: []component.ID{component.NewID(component.MustType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "connector \"bf\" used as exporter in metrics pipeline but not used in any supported receiver pipeline", @@ -1436,22 +1436,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_metrics_metrics.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID("bf"): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("bf")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName("metrics", "in"): { - Receivers: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("bf")}, + component.NewIDWithName(component.MustType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("bf"))}, }, - component.NewIDWithName("metrics", "out"): { - Receivers: []component.ID{component.NewID("bf")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewIDWithName(component.MustType("metrics"), "out"): { + Receivers: []component.ID{component.NewID(component.MustType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "connector \"bf\" used as exporter in metrics pipeline but not used in any supported receiver pipeline", @@ -1459,22 +1459,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_metrics_logs.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID("bf"): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("bf")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName("metrics", "in"): { - Receivers: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("bf")}, + component.NewIDWithName(component.MustType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("bf"))}, }, - component.NewIDWithName("logs", "out"): { - Receivers: []component.ID{component.NewID("bf")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewIDWithName(component.MustType("logs"), "out"): { + Receivers: []component.ID{component.NewID(component.MustType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "connector \"bf\" used as exporter in metrics pipeline but not used in any supported receiver pipeline", @@ -1482,22 +1482,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_logs_traces.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID("bf"): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("bf")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName("logs", "in"): { - Receivers: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("bf")}, + component.NewIDWithName(component.MustType("logs"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("bf"))}, }, - component.NewIDWithName("traces", "out"): { - Receivers: []component.ID{component.NewID("bf")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewIDWithName(component.MustType("traces"), "out"): { + Receivers: []component.ID{component.NewID(component.MustType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "connector \"bf\" used as exporter in logs pipeline but not used in any supported receiver pipeline", @@ -1505,22 +1505,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_logs_metrics.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID("bf"): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("bf")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName("logs", "in"): { - Receivers: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("bf")}, + component.NewIDWithName(component.MustType("logs"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("bf"))}, }, - component.NewIDWithName("metrics", "out"): { - Receivers: []component.ID{component.NewID("bf")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewIDWithName(component.MustType("metrics"), "out"): { + Receivers: []component.ID{component.NewID(component.MustType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "connector \"bf\" used as exporter in logs pipeline but not used in any supported receiver pipeline", @@ -1528,22 +1528,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_logs_logs.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID("bf"): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("bf")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName("logs", "in"): { - Receivers: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("bf")}, + component.NewIDWithName(component.MustType("logs"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("bf"))}, }, - component.NewIDWithName("logs", "out"): { - Receivers: []component.ID{component.NewID("bf")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewIDWithName(component.MustType("logs"), "out"): { + Receivers: []component.ID{component.NewID(component.MustType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "connector \"bf\" used as exporter in logs pipeline but not used in any supported receiver pipeline", @@ -1551,18 +1551,18 @@ func TestGraphBuildErrors(t *testing.T) { { name: "orphaned-connector-use-as-exporter", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName("metrics", "in"): { - Receivers: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewIDWithName("nop", "conn")}, + component.NewIDWithName(component.MustType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, }, }, expected: `connector "nop/conn" used as exporter in metrics pipeline but not used in any supported receiver pipeline`, @@ -1570,18 +1570,18 @@ func TestGraphBuildErrors(t *testing.T) { { name: "orphaned-connector-use-as-receiver", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName("traces", "out"): { - Receivers: []component.ID{component.NewIDWithName("nop", "conn")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewIDWithName(component.MustType("traces"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: `connector "nop/conn" used as receiver in traces pipeline but not used in any supported exporter pipeline`, @@ -1589,26 +1589,26 @@ func TestGraphBuildErrors(t *testing.T) { { name: "partially-orphaned-connector-use-as-exporter", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID("mockforward"): mfConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("mockforward")): mfConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName("traces", "in"): { - Receivers: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("mockforward")}, + component.NewIDWithName(component.MustType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("mockforward"))}, }, - component.NewIDWithName("traces", "out"): { - Receivers: []component.ID{component.NewID("mockforward")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewIDWithName(component.MustType("traces"), "out"): { + Receivers: []component.ID{component.NewID(component.MustType("mockforward"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, - component.NewIDWithName("metrics", "in"): { - Receivers: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("mockforward")}, + component.NewIDWithName(component.MustType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("mockforward"))}, }, }, expected: `connector "mockforward" used as exporter in metrics pipeline but not used in any supported receiver pipeline`, @@ -1616,26 +1616,26 @@ func TestGraphBuildErrors(t *testing.T) { { name: "partially-orphaned-connector-use-as-receiver", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID("mockforward"): mfConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("mockforward")): mfConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName("metrics", "in"): { - Receivers: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("mockforward")}, + component.NewIDWithName(component.MustType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("mockforward"))}, }, - component.NewIDWithName("metrics", "out"): { - Receivers: []component.ID{component.NewID("mockforward")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewIDWithName(component.MustType("metrics"), "out"): { + Receivers: []component.ID{component.NewID(component.MustType("mockforward"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, - component.NewIDWithName("traces", "out"): { - Receivers: []component.ID{component.NewID("mockforward")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewIDWithName(component.MustType("traces"), "out"): { + Receivers: []component.ID{component.NewID(component.MustType("mockforward"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: `connector "mockforward" used as receiver in traces pipeline but not used in any supported exporter pipeline`, @@ -1643,22 +1643,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_simple_cycle_traces.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID("traces"): { - Receivers: []component.ID{component.NewIDWithName("nop", "conn")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewIDWithName("nop", "conn")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, }, }, expected: `cycle detected: ` + @@ -1669,22 +1669,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_simple_cycle_metrics.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID("metrics"): { - Receivers: []component.ID{component.NewIDWithName("nop", "conn")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewIDWithName("nop", "conn")}, + component.NewID(component.MustType("metrics")): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, }, }, expected: `cycle detected: ` + @@ -1695,22 +1695,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_simple_cycle_logs.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID("logs"): { - Receivers: []component.ID{component.NewIDWithName("nop", "conn")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewIDWithName("nop", "conn")}, + component.NewID(component.MustType("logs")): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, }, }, expected: `cycle detected: ` + @@ -1721,39 +1721,39 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_deep_cycle_traces.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName("nop", "conn1"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName("nop", "conn2"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("nop"), "conn1"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("nop"), "conn2"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName("traces", "in"): { - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewIDWithName("nop", "conn")}, + component.NewIDWithName(component.MustType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, }, - component.NewIDWithName("traces", "1"): { - Receivers: []component.ID{component.NewIDWithName("nop", "conn")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewIDWithName("nop", "conn1")}, + component.NewIDWithName(component.MustType("traces"), "1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn1")}, }, - component.NewIDWithName("traces", "2"): { - Receivers: []component.ID{component.NewIDWithName("nop", "conn1")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewIDWithName("nop", "conn2"), component.NewIDWithName("nop", "conn")}, + component.NewIDWithName(component.MustType("traces"), "2"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn1")}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn2"), component.NewIDWithName(component.MustType("nop"), "conn")}, }, - component.NewIDWithName("traces", "out"): { - Receivers: []component.ID{component.NewIDWithName("nop", "conn2")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewIDWithName(component.MustType("traces"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn2")}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: `cycle detected: ` + @@ -1766,39 +1766,39 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_deep_cycle_metrics.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName("nop", "conn1"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName("nop", "conn2"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("nop"), "conn1"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("nop"), "conn2"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName("metrics", "in"): { - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewIDWithName("nop", "conn")}, + component.NewIDWithName(component.MustType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, }, - component.NewIDWithName("metrics", "1"): { - Receivers: []component.ID{component.NewIDWithName("nop", "conn")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewIDWithName("nop", "conn1")}, + component.NewIDWithName(component.MustType("metrics"), "1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn1")}, }, - component.NewIDWithName("metrics", "2"): { - Receivers: []component.ID{component.NewIDWithName("nop", "conn1")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewIDWithName("nop", "conn2"), component.NewIDWithName("nop", "conn")}, + component.NewIDWithName(component.MustType("metrics"), "2"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn1")}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn2"), component.NewIDWithName(component.MustType("nop"), "conn")}, }, - component.NewIDWithName("metrics", "out"): { - Receivers: []component.ID{component.NewIDWithName("nop", "conn2")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewIDWithName(component.MustType("metrics"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn2")}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: `cycle detected: ` + @@ -1811,39 +1811,39 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_deep_cycle_logs.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName("nop", "conn1"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName("nop", "conn2"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("nop"), "conn1"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("nop"), "conn2"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName("logs", "in"): { - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewIDWithName("nop", "conn")}, + component.NewIDWithName(component.MustType("logs"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, }, - component.NewIDWithName("logs", "1"): { - Receivers: []component.ID{component.NewIDWithName("nop", "conn")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewIDWithName("nop", "conn1")}, + component.NewIDWithName(component.MustType("logs"), "1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn1")}, }, - component.NewIDWithName("logs", "2"): { - Receivers: []component.ID{component.NewIDWithName("nop", "conn1")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewIDWithName("nop", "conn2"), component.NewIDWithName("nop", "conn")}, + component.NewIDWithName(component.MustType("logs"), "2"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn1")}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn2"), component.NewIDWithName(component.MustType("nop"), "conn")}, }, - component.NewIDWithName("logs", "out"): { - Receivers: []component.ID{component.NewIDWithName("nop", "conn2")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewIDWithName(component.MustType("logs"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn2")}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: `cycle detected: ` + @@ -1856,55 +1856,55 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_deep_cycle_multi_signal.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName("nop", "fork"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName("nop", "count"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName("nop", "forkagain"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName("nop", "rawlog"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("nop"), "fork"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("nop"), "count"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("nop"), "forkagain"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustType("nop"), "rawlog"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName("traces", "in"): { - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewIDWithName("nop", "fork")}, - }, - component.NewIDWithName("traces", "copy1"): { - Receivers: []component.ID{component.NewIDWithName("nop", "fork")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewIDWithName("nop", "count")}, - }, - component.NewIDWithName("traces", "copy2"): { - Receivers: []component.ID{component.NewIDWithName("nop", "fork")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewIDWithName("nop", "forkagain")}, - }, - component.NewIDWithName("traces", "copy2a"): { - Receivers: []component.ID{component.NewIDWithName("nop", "forkagain")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewIDWithName("nop", "count")}, - }, - component.NewIDWithName("traces", "copy2b"): { - Receivers: []component.ID{component.NewIDWithName("nop", "forkagain")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewIDWithName("nop", "rawlog")}, - }, - component.NewIDWithName("metrics", "count"): { - Receivers: []component.ID{component.NewIDWithName("nop", "count")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("nop")}, - }, - component.NewIDWithName("logs", "raw"): { - Receivers: []component.ID{component.NewIDWithName("nop", "rawlog")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewIDWithName("nop", "fork")}, // cannot loop back to "nop/fork" + component.NewIDWithName(component.MustType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "fork")}, + }, + component.NewIDWithName(component.MustType("traces"), "copy1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "fork")}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "count")}, + }, + component.NewIDWithName(component.MustType("traces"), "copy2"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "fork")}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "forkagain")}, + }, + component.NewIDWithName(component.MustType("traces"), "copy2a"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "forkagain")}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "count")}, + }, + component.NewIDWithName(component.MustType("traces"), "copy2b"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "forkagain")}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "rawlog")}, + }, + component.NewIDWithName(component.MustType("metrics"), "count"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "count")}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + }, + component.NewIDWithName(component.MustType("logs"), "raw"): { + Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "rawlog")}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "fork")}, // cannot loop back to "nop/fork" }, }, expected: `cycle detected: ` + @@ -1919,15 +1919,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_exporter_config", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID("traces"): { - Receivers: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("nop"), component.NewIDWithName("nop", "1")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop")), component.NewIDWithName(component.MustType("nop"), "1")}, }, }, expected: "failed to create \"nop/1\" exporter for data type \"traces\": exporter \"nop/1\" is not configured", @@ -1935,15 +1935,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_exporter_factory", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("unknown"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("unknown")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID("traces"): { - Receivers: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("unknown")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("unknown"))}, }, }, expected: "failed to create \"unknown\" exporter for data type \"traces\": exporter factory not available for: \"unknown\"", @@ -1951,19 +1951,19 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_processor_config", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID("metrics"): { - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("nop"), component.NewIDWithName("nop", "1")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewID(component.MustType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Processors: []component.ID{component.NewID(component.MustType("nop")), component.NewIDWithName(component.MustType("nop"), "1")}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "failed to create \"nop/1\" processor, in pipeline \"metrics\": processor \"nop/1\" is not configured", @@ -1971,19 +1971,19 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_processor_factory", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID("unknown"): nopProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("unknown")): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID("metrics"): { - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("unknown")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewID(component.MustType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Processors: []component.ID{component.NewID(component.MustType("unknown"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "failed to create \"unknown\" processor, in pipeline \"metrics\": processor factory not available for: \"unknown\"", @@ -1991,15 +1991,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_receiver_config", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID("logs"): { - Receivers: []component.ID{component.NewID("nop"), component.NewIDWithName("nop", "1")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewID(component.MustType("logs")): { + Receivers: []component.ID{component.NewID(component.MustType("nop")), component.NewIDWithName(component.MustType("nop"), "1")}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "failed to create \"nop/1\" receiver for data type \"logs\": receiver \"nop/1\" is not configured", @@ -2007,15 +2007,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_receiver_factory", receiverCfgs: map[component.ID]component.Config{ - component.NewID("unknown"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("unknown")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID("logs"): { - Receivers: []component.ID{component.NewID("unknown")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewID(component.MustType("logs")): { + Receivers: []component.ID{component.NewID(component.MustType("unknown"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "failed to create \"unknown\" receiver for data type \"logs\": receiver factory not available for: \"unknown\"", @@ -2023,22 +2023,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_connector_factory", receiverCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID("unknown"): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustType("unknown")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName("traces", "in"): { - Receivers: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("unknown")}, + component.NewIDWithName(component.MustType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("unknown"))}, }, - component.NewIDWithName("traces", "out"): { - Receivers: []component.ID{component.NewID("unknown")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewIDWithName(component.MustType("traces"), "out"): { + Receivers: []component.ID{component.NewID(component.MustType("unknown"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, }, expected: "connector factory not available for: \"unknown\"", @@ -2138,12 +2138,12 @@ func TestGraphFailToStartAndShutdown(t *testing.T) { dataTypes := []component.DataType{component.DataTypeTraces, component.DataTypeMetrics, component.DataTypeLogs} for _, dt := range dataTypes { - t.Run(string(dt)+"/receiver", func(t *testing.T) { + t.Run(dt.String()+"/receiver", func(t *testing.T) { set.PipelineConfigs = pipelines.Config{ component.NewID(dt): { - Receivers: []component.ID{component.NewID("nop"), component.NewID("err")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("nop")}, + Receivers: []component.ID{component.NewID(component.MustType("nop")), component.NewID(component.MustType("err"))}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, } pipelines, err := Build(context.Background(), set) @@ -2152,12 +2152,12 @@ func TestGraphFailToStartAndShutdown(t *testing.T) { assert.Error(t, pipelines.ShutdownAll(context.Background())) }) - t.Run(string(dt)+"/processor", func(t *testing.T) { + t.Run(dt.String()+"/processor", func(t *testing.T) { set.PipelineConfigs = pipelines.Config{ component.NewID(dt): { - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("nop"), component.NewID("err")}, - Exporters: []component.ID{component.NewID("nop")}, + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Processors: []component.ID{component.NewID(component.MustType("nop")), component.NewID(component.MustType("err"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, } pipelines, err := Build(context.Background(), set) @@ -2166,12 +2166,12 @@ func TestGraphFailToStartAndShutdown(t *testing.T) { assert.Error(t, pipelines.ShutdownAll(context.Background())) }) - t.Run(string(dt)+"/exporter", func(t *testing.T) { + t.Run(dt.String()+"/exporter", func(t *testing.T) { set.PipelineConfigs = pipelines.Config{ component.NewID(dt): { - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("nop"), component.NewID("err")}, + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop")), component.NewID(component.MustType("err"))}, }, } pipelines, err := Build(context.Background(), set) @@ -2181,17 +2181,17 @@ func TestGraphFailToStartAndShutdown(t *testing.T) { }) for _, dt2 := range dataTypes { - t.Run(string(dt)+"/"+string(dt2)+"/connector", func(t *testing.T) { + t.Run(dt.String()+"/"+dt2.String()+"/connector", func(t *testing.T) { set.PipelineConfigs = pipelines.Config{ component.NewIDWithName(dt, "in"): { - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("nop"), component.NewIDWithName("err", "conn")}, + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop")), component.NewIDWithName(component.MustType("err"), "conn")}, }, component.NewIDWithName(dt2, "out"): { - Receivers: []component.ID{component.NewID("nop"), component.NewIDWithName("err", "conn")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("nop")}, + Receivers: []component.ID{component.NewID(component.MustType("nop")), component.NewIDWithName(component.MustType("err"), "conn")}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, } pipelines, err := Build(context.Background(), set) @@ -2205,13 +2205,13 @@ func TestGraphFailToStartAndShutdown(t *testing.T) { func TestStatusReportedOnStartupShutdown(t *testing.T) { - rNoErr := &testNode{id: component.NewIDWithName("r-no-err", "1")} - rStErr := &testNode{id: component.NewIDWithName("r-st-err", "1"), startErr: assert.AnError} - rSdErr := &testNode{id: component.NewIDWithName("r-sd-err", "1"), shutdownErr: assert.AnError} + rNoErr := &testNode{id: component.NewIDWithName(component.MustType("r_no_err"), "1")} + rStErr := &testNode{id: component.NewIDWithName(component.MustType("r_st_err"), "1"), startErr: assert.AnError} + rSdErr := &testNode{id: component.NewIDWithName(component.MustType("r_sd_err"), "1"), shutdownErr: assert.AnError} - eNoErr := &testNode{id: component.NewIDWithName("e-no-err", "1")} - eStErr := &testNode{id: component.NewIDWithName("e-st-err", "1"), startErr: assert.AnError} - eSdErr := &testNode{id: component.NewIDWithName("e-sd-err", "1"), shutdownErr: assert.AnError} + eNoErr := &testNode{id: component.NewIDWithName(component.MustType("e_no_err"), "1")} + eStErr := &testNode{id: component.NewIDWithName(component.MustType("e_st_err"), "1"), startErr: assert.AnError} + eSdErr := &testNode{id: component.NewIDWithName(component.MustType("e_sd_err"), "1"), shutdownErr: assert.AnError} instanceIDs := map[*testNode]*component.InstanceID{ rNoErr: {ID: rNoErr.id}, @@ -2390,9 +2390,10 @@ func (g *Graph) getReceivers() map[component.DataType]map[component.ID]component // - E instances of the connector as a receiver. // - R instances of the connector as an exporter. func expectedInstances(m pipelines.Config, pID component.ID) (int, int) { + exConnectorType := component.MustType("exampleconnector") var r, e int for _, rID := range m[pID].Receivers { - if rID.Type() != "exampleconnector" { + if rID.Type() != exConnectorType { r++ continue } @@ -2409,7 +2410,7 @@ func expectedInstances(m pipelines.Config, pID component.ID) (int, int) { r += len(typeMap) } for _, eID := range m[pID].Exporters { - if eID.Type() != "exampleconnector" { + if eID.Type() != exConnectorType { e++ continue } @@ -2429,31 +2430,31 @@ func expectedInstances(m pipelines.Config, pID component.ID) (int, int) { } func newBadReceiverFactory() receiver.Factory { - return receiver.NewFactory("bf", func() component.Config { + return receiver.NewFactory(component.MustType("bf"), func() component.Config { return &struct{}{} }) } func newBadProcessorFactory() processor.Factory { - return processor.NewFactory("bf", func() component.Config { + return processor.NewFactory(component.MustType("bf"), func() component.Config { return &struct{}{} }) } func newBadExporterFactory() exporter.Factory { - return exporter.NewFactory("bf", func() component.Config { + return exporter.NewFactory(component.MustType("bf"), func() component.Config { return &struct{}{} }) } func newBadConnectorFactory() connector.Factory { - return connector.NewFactory("bf", func() component.Config { + return connector.NewFactory(component.MustType("bf"), func() component.Config { return &struct{}{} }) } func newErrReceiverFactory() receiver.Factory { - return receiver.NewFactory("err", + return receiver.NewFactory(component.MustType("err"), func() component.Config { return &struct{}{} }, receiver.WithTraces(func(context.Context, receiver.CreateSettings, component.Config, consumer.Traces) (receiver.Traces, error) { return &errComponent{}, nil @@ -2468,7 +2469,7 @@ func newErrReceiverFactory() receiver.Factory { } func newErrProcessorFactory() processor.Factory { - return processor.NewFactory("err", + return processor.NewFactory(component.MustType("err"), func() component.Config { return &struct{}{} }, processor.WithTraces(func(context.Context, processor.CreateSettings, component.Config, consumer.Traces) (processor.Traces, error) { return &errComponent{}, nil @@ -2483,7 +2484,7 @@ func newErrProcessorFactory() processor.Factory { } func newErrExporterFactory() exporter.Factory { - return exporter.NewFactory("err", + return exporter.NewFactory(component.MustType("err"), func() component.Config { return &struct{}{} }, exporter.WithTraces(func(context.Context, exporter.CreateSettings, component.Config) (exporter.Traces, error) { return &errComponent{}, nil @@ -2498,7 +2499,7 @@ func newErrExporterFactory() exporter.Factory { } func newErrConnectorFactory() connector.Factory { - return connector.NewFactory("err", func() component.Config { + return connector.NewFactory(component.MustType("err"), func() component.Config { return &struct{}{} }, connector.WithTracesToTraces(func(context.Context, connector.CreateSettings, component.Config, consumer.Traces) (connector.Traces, error) { diff --git a/service/internal/graph/nodes.go b/service/internal/graph/nodes.go index 79d627d5bf7..13726d1c760 100644 --- a/service/internal/graph/nodes.go +++ b/service/internal/graph/nodes.go @@ -61,7 +61,7 @@ type receiverNode struct { func newReceiverNode(pipelineType component.DataType, recvID component.ID) *receiverNode { return &receiverNode{ - nodeID: newNodeID(receiverSeed, string(pipelineType), recvID.String()), + nodeID: newNodeID(receiverSeed, pipelineType.String(), recvID.String()), componentID: recvID, pipelineType: pipelineType, } @@ -165,7 +165,7 @@ type exporterNode struct { func newExporterNode(pipelineType component.DataType, exprID component.ID) *exporterNode { return &exporterNode{ - nodeID: newNodeID(exporterSeed, string(pipelineType), exprID.String()), + nodeID: newNodeID(exporterSeed, pipelineType.String(), exprID.String()), componentID: exprID, pipelineType: pipelineType, } @@ -215,7 +215,7 @@ type connectorNode struct { func newConnectorNode(exprPipelineType, rcvrPipelineType component.DataType, connID component.ID) *connectorNode { return &connectorNode{ - nodeID: newNodeID(connectorSeed, connID.String(), string(exprPipelineType), string(rcvrPipelineType)), + nodeID: newNodeID(connectorSeed, connID.String(), exprPipelineType.String(), rcvrPipelineType.String()), componentID: connID, exprPipelineType: exprPipelineType, rcvrPipelineType: rcvrPipelineType, diff --git a/service/internal/graph/zpages.go b/service/internal/graph/zpages.go index 0c7c0829eed..0f2793974e9 100644 --- a/service/internal/graph/zpages.go +++ b/service/internal/graph/zpages.go @@ -55,7 +55,7 @@ func (g *Graph) HandleZPages(w http.ResponseWriter, r *http.Request) { sumData.Rows = append(sumData.Rows, zpages.SummaryPipelinesTableRowData{ FullName: c.String(), - InputType: string(c.Type()), + InputType: c.Type().String(), MutatesData: p.capabilitiesNode.getConsumer().Capabilities().MutatesData, Receivers: recvIDs, Processors: procIDs, diff --git a/service/internal/testcomponents/example_connector.go b/service/internal/testcomponents/example_connector.go index c5c10b92b78..d5dde3d8e93 100644 --- a/service/internal/testcomponents/example_connector.go +++ b/service/internal/testcomponents/example_connector.go @@ -15,7 +15,7 @@ import ( "go.opentelemetry.io/collector/pdata/ptrace" ) -const connType = "exampleconnector" +var connType = component.MustType("exampleconnector") // ExampleConnectorFactory is factory for ExampleConnector. var ExampleConnectorFactory = connector.NewFactory( @@ -36,7 +36,7 @@ var ExampleConnectorFactory = connector.NewFactory( ) var MockForwardConnectorFactory = connector.NewFactory( - "mockforward", + component.MustType("mockforward"), createExampleConnectorDefaultConfig, connector.WithTracesToTraces(createExampleTracesToTraces, component.StabilityLevelDevelopment), connector.WithMetricsToMetrics(createExampleMetricsToMetrics, component.StabilityLevelDevelopment), diff --git a/service/internal/testcomponents/example_exporter.go b/service/internal/testcomponents/example_exporter.go index 7c5f512d361..f6bc66d8456 100644 --- a/service/internal/testcomponents/example_exporter.go +++ b/service/internal/testcomponents/example_exporter.go @@ -14,14 +14,13 @@ import ( "go.opentelemetry.io/collector/pdata/ptrace" ) -const ( - typeStr = "exampleexporter" - stability = component.StabilityLevelDevelopment -) +var testType = component.MustType("exampleexporter") + +const stability = component.StabilityLevelDevelopment // ExampleExporterFactory is factory for ExampleExporter. var ExampleExporterFactory = exporter.NewFactory( - typeStr, + testType, createExporterDefaultConfig, exporter.WithTraces(createTracesExporter, stability), exporter.WithMetrics(createMetricsExporter, stability), diff --git a/service/internal/testcomponents/example_processor.go b/service/internal/testcomponents/example_processor.go index 8189264b5c3..bf245d6bea0 100644 --- a/service/internal/testcomponents/example_processor.go +++ b/service/internal/testcomponents/example_processor.go @@ -11,7 +11,7 @@ import ( "go.opentelemetry.io/collector/processor" ) -const procType = "exampleprocessor" +var procType = component.MustType("exampleprocessor") // ExampleProcessorFactory is factory for ExampleProcessor. var ExampleProcessorFactory = processor.NewFactory( diff --git a/service/internal/testcomponents/example_receiver.go b/service/internal/testcomponents/example_receiver.go index e59d9cb67bb..5091513fab2 100644 --- a/service/internal/testcomponents/example_receiver.go +++ b/service/internal/testcomponents/example_receiver.go @@ -11,7 +11,7 @@ import ( "go.opentelemetry.io/collector/receiver" ) -const receiverType = component.Type("examplereceiver") +var receiverType = component.MustType("examplereceiver") // ExampleReceiverFactory is factory for ExampleReceiver. var ExampleReceiverFactory = receiver.NewFactory( diff --git a/service/internal/testcomponents/example_router.go b/service/internal/testcomponents/example_router.go index 45d2a17c561..e3c5d7ed8f5 100644 --- a/service/internal/testcomponents/example_router.go +++ b/service/internal/testcomponents/example_router.go @@ -14,7 +14,7 @@ import ( "go.opentelemetry.io/collector/pdata/ptrace" ) -const routerType = "examplerouter" +var routerType = component.MustType("examplerouter") // ExampleRouterFactory is factory for ExampleRouter. var ExampleRouterFactory = connector.NewFactory( diff --git a/service/internal/testcomponents/example_router_test.go b/service/internal/testcomponents/example_router_test.go index a34a70160e0..8f011641a6a 100644 --- a/service/internal/testcomponents/example_router_test.go +++ b/service/internal/testcomponents/example_router_test.go @@ -31,8 +31,8 @@ func TestExampleRouter(t *testing.T) { } func TestTracesRouter(t *testing.T) { - leftID := component.NewIDWithName("sink", "left") - rightID := component.NewIDWithName("sink", "right") + leftID := component.NewIDWithName(component.MustType("sink"), "left") + rightID := component.NewIDWithName(component.MustType("sink"), "right") sinkLeft := new(consumertest.TracesSink) sinkRight := new(consumertest.TracesSink) @@ -70,8 +70,8 @@ func TestTracesRouter(t *testing.T) { } func TestMetricsRouter(t *testing.T) { - leftID := component.NewIDWithName("sink", "left") - rightID := component.NewIDWithName("sink", "right") + leftID := component.NewIDWithName(component.MustType("sink"), "left") + rightID := component.NewIDWithName(component.MustType("sink"), "right") sinkLeft := new(consumertest.MetricsSink) sinkRight := new(consumertest.MetricsSink) @@ -109,8 +109,8 @@ func TestMetricsRouter(t *testing.T) { } func TestLogsRouter(t *testing.T) { - leftID := component.NewIDWithName("sink", "left") - rightID := component.NewIDWithName("sink", "right") + leftID := component.NewIDWithName(component.MustType("sink"), "left") + rightID := component.NewIDWithName(component.MustType("sink"), "right") sinkLeft := new(consumertest.LogsSink) sinkRight := new(consumertest.LogsSink) diff --git a/service/pipelines/config_test.go b/service/pipelines/config_test.go index e08dff3741a..c5cbc73aff5 100644 --- a/service/pipelines/config_test.go +++ b/service/pipelines/config_test.go @@ -28,7 +28,7 @@ func TestConfigValidate(t *testing.T) { name: "duplicate-processor-reference", cfgFn: func() Config { cfg := generateConfig() - pipe := cfg[component.NewID("traces")] + pipe := cfg[component.NewID(component.MustType("traces"))] pipe.Processors = append(pipe.Processors, pipe.Processors...) return cfg }, @@ -38,7 +38,7 @@ func TestConfigValidate(t *testing.T) { name: "missing-pipeline-receivers", cfgFn: func() Config { cfg := generateConfig() - cfg[component.NewID("traces")].Receivers = nil + cfg[component.NewID(component.MustType("traces"))].Receivers = nil return cfg }, expected: fmt.Errorf(`pipeline "traces": %w`, errMissingServicePipelineReceivers), @@ -47,7 +47,7 @@ func TestConfigValidate(t *testing.T) { name: "missing-pipeline-exporters", cfgFn: func() Config { cfg := generateConfig() - cfg[component.NewID("traces")].Exporters = nil + cfg[component.NewID(component.MustType("traces"))].Exporters = nil return cfg }, expected: fmt.Errorf(`pipeline "traces": %w`, errMissingServicePipelineExporters), @@ -63,10 +63,10 @@ func TestConfigValidate(t *testing.T) { name: "invalid-service-pipeline-type", cfgFn: func() Config { cfg := generateConfig() - cfg[component.NewID("wrongtype")] = &PipelineConfig{ - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("nop")}, + cfg[component.NewID(component.MustType("wrongtype"))] = &PipelineConfig{ + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, } return cfg }, @@ -84,10 +84,10 @@ func TestConfigValidate(t *testing.T) { func generateConfig() Config { return map[component.ID]*PipelineConfig{ - component.NewID("traces"): { - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewID(component.MustType("nop"))}, + Processors: []component.ID{component.NewID(component.MustType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustType("nop"))}, }, } } diff --git a/service/service_test.go b/service/service_test.go index 47d0061fd6a..16e9a2bda11 100644 --- a/service/service_test.go +++ b/service/service_test.go @@ -168,6 +168,11 @@ func ownMetricsTestCases() []ownMetricsTestCase { }} } +var ( + nopType = component.MustType("nop") + wrongType = component.MustType("wrong") +) + func TestServiceGetFactory(t *testing.T) { set := newNopSettings() srv, err := New(context.Background(), set, newNopConfig()) @@ -178,23 +183,23 @@ func TestServiceGetFactory(t *testing.T) { assert.NoError(t, srv.Shutdown(context.Background())) }) - assert.Nil(t, srv.host.GetFactory(component.KindReceiver, "wrongtype")) - assert.Equal(t, set.Receivers.Factory("nop"), srv.host.GetFactory(component.KindReceiver, "nop")) + assert.Nil(t, srv.host.GetFactory(component.KindReceiver, wrongType)) + assert.Equal(t, set.Receivers.Factory(nopType), srv.host.GetFactory(component.KindReceiver, nopType)) - assert.Nil(t, srv.host.GetFactory(component.KindProcessor, "wrongtype")) - assert.Equal(t, set.Processors.Factory("nop"), srv.host.GetFactory(component.KindProcessor, "nop")) + assert.Nil(t, srv.host.GetFactory(component.KindProcessor, wrongType)) + assert.Equal(t, set.Processors.Factory(nopType), srv.host.GetFactory(component.KindProcessor, nopType)) - assert.Nil(t, srv.host.GetFactory(component.KindExporter, "wrongtype")) - assert.Equal(t, set.Exporters.Factory("nop"), srv.host.GetFactory(component.KindExporter, "nop")) + assert.Nil(t, srv.host.GetFactory(component.KindExporter, wrongType)) + assert.Equal(t, set.Exporters.Factory(nopType), srv.host.GetFactory(component.KindExporter, nopType)) - assert.Nil(t, srv.host.GetFactory(component.KindConnector, "wrongtype")) - assert.Equal(t, set.Connectors.Factory("nop"), srv.host.GetFactory(component.KindConnector, "nop")) + assert.Nil(t, srv.host.GetFactory(component.KindConnector, wrongType)) + assert.Equal(t, set.Connectors.Factory(nopType), srv.host.GetFactory(component.KindConnector, nopType)) - assert.Nil(t, srv.host.GetFactory(component.KindExtension, "wrongtype")) - assert.Equal(t, set.Extensions.Factory("nop"), srv.host.GetFactory(component.KindExtension, "nop")) + assert.Nil(t, srv.host.GetFactory(component.KindExtension, wrongType)) + assert.Equal(t, set.Extensions.Factory(nopType), srv.host.GetFactory(component.KindExtension, nopType)) // Try retrieve non existing component.Kind. - assert.Nil(t, srv.host.GetFactory(42, "nop")) + assert.Nil(t, srv.host.GetFactory(42, nopType)) } func TestServiceGetExtensions(t *testing.T) { @@ -209,7 +214,7 @@ func TestServiceGetExtensions(t *testing.T) { extMap := srv.host.GetExtensions() assert.Len(t, extMap, 1) - assert.Contains(t, extMap, component.NewID("nop")) + assert.Contains(t, extMap, component.NewID(nopType)) } func TestServiceGetExporters(t *testing.T) { @@ -224,18 +229,18 @@ func TestServiceGetExporters(t *testing.T) { expMap := srv.host.GetExporters() assert.Len(t, expMap, 3) assert.Len(t, expMap[component.DataTypeTraces], 1) - assert.Contains(t, expMap[component.DataTypeTraces], component.NewID("nop")) + assert.Contains(t, expMap[component.DataTypeTraces], component.NewID(nopType)) assert.Len(t, expMap[component.DataTypeMetrics], 1) - assert.Contains(t, expMap[component.DataTypeMetrics], component.NewID("nop")) + assert.Contains(t, expMap[component.DataTypeMetrics], component.NewID(nopType)) assert.Len(t, expMap[component.DataTypeLogs], 1) - assert.Contains(t, expMap[component.DataTypeLogs], component.NewID("nop")) + assert.Contains(t, expMap[component.DataTypeLogs], component.NewID(nopType)) } // TestServiceTelemetryCleanupOnError tests that if newService errors due to an invalid config telemetry is cleaned up // and another service with a valid config can be started right after. func TestServiceTelemetryCleanupOnError(t *testing.T) { invalidCfg := newNopConfig() - invalidCfg.Pipelines[component.NewID("traces")].Processors[0] = component.NewID("invalid") + invalidCfg.Pipelines[component.NewID(component.MustType("traces"))].Processors[0] = component.NewID(component.MustType("invalid")) // Create a service with an invalid config and expect an error _, err := New(context.Background(), newNopSettings(), invalidCfg) require.Error(t, err) @@ -270,12 +275,12 @@ func testCollectorStartHelper(t *testing.T, tc ownMetricsTestCase) { set := newNopSettings() set.BuildInfo = component.BuildInfo{Version: "test version", Command: otelCommand} set.Extensions = extension.NewBuilder( - map[component.ID]component.Config{component.NewID("zpages"): &zpagesextension.Config{TCPAddr: confignet.TCPAddr{Endpoint: zpagesAddr}}}, - map[component.Type]extension.Factory{"zpages": zpagesextension.NewFactory()}) + map[component.ID]component.Config{component.NewID(component.MustType("zpages")): &zpagesextension.Config{TCPAddr: confignet.TCPAddr{Endpoint: zpagesAddr}}}, + map[component.Type]extension.Factory{component.MustType("zpages"): zpagesextension.NewFactory()}) set.LoggingOptions = []zap.Option{zap.Hooks(hook)} cfg := newNopConfig() - cfg.Extensions = []component.ID{component.NewID("zpages")} + cfg.Extensions = []component.ID{component.NewID(component.MustType("zpages"))} cfg.Telemetry.Metrics.Address = metricsAddr cfg.Telemetry.Resource = make(map[string]*string) // Include resource attributes under the service::telemetry::resource key. @@ -351,7 +356,7 @@ func TestExtensionNotificationFailure(t *testing.T) { set := newNopSettings() cfg := newNopConfig() - var extName component.Type = "configWatcher" + var extName = component.MustType("configWatcher") configWatcherExtensionFactory := newConfigWatcherExtensionFactory(extName) set.Extensions = extension.NewBuilder( map[component.ID]component.Config{component.NewID(extName): configWatcherExtensionFactory.CreateDefaultConfig()}, @@ -374,7 +379,7 @@ func TestNilCollectorEffectiveConfig(t *testing.T) { set.CollectorConf = nil cfg := newNopConfig() - var extName component.Type = "configWatcher" + var extName = component.MustType("configWatcher") configWatcherExtensionFactory := newConfigWatcherExtensionFactory(extName) set.Extensions = extension.NewBuilder( map[component.ID]component.Config{component.NewID(extName): configWatcherExtensionFactory.CreateDefaultConfig()}, @@ -527,27 +532,27 @@ func newNopSettings() Settings { func newNopConfig() Config { return newNopConfigPipelineConfigs(pipelines.Config{ - component.NewID("traces"): { - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewID(component.MustType("traces")): { + Receivers: []component.ID{component.NewID(nopType)}, + Processors: []component.ID{component.NewID(nopType)}, + Exporters: []component.ID{component.NewID(nopType)}, }, - component.NewID("metrics"): { - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewID(component.MustType("metrics")): { + Receivers: []component.ID{component.NewID(nopType)}, + Processors: []component.ID{component.NewID(nopType)}, + Exporters: []component.ID{component.NewID(nopType)}, }, - component.NewID("logs"): { - Receivers: []component.ID{component.NewID("nop")}, - Processors: []component.ID{component.NewID("nop")}, - Exporters: []component.ID{component.NewID("nop")}, + component.NewID(component.MustType("logs")): { + Receivers: []component.ID{component.NewID(nopType)}, + Processors: []component.ID{component.NewID(nopType)}, + Exporters: []component.ID{component.NewID(nopType)}, }, }) } func newNopConfigPipelineConfigs(pipelineCfgs pipelines.Config) Config { return Config{ - Extensions: extensions.Config{component.NewID("nop")}, + Extensions: extensions.Config{component.NewID(nopType)}, Pipelines: pipelineCfgs, Telemetry: telemetry.Config{ Logs: telemetry.LogsConfig{ From 8bbc8b978bd00eddbf977f8c6bf73065ab2350ff Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Fri, 26 Jan 2024 16:59:54 +0100 Subject: [PATCH 02/13] [cmd/mdatagen, *] Use component.MustType to build component.Type --- cmd/mdatagen/internal/metadata/generated_status.go | 5 ++++- cmd/mdatagen/main_test.go | 10 ++++++++-- cmd/mdatagen/templates/status.go.tmpl | 7 +++++-- .../internal/metadata/generated_status.go | 5 ++++- .../internal/metadata/generated_status.go | 5 ++++- .../internal/metadata/generated_status.go | 5 ++++- .../otlpexporter/internal/metadata/generated_status.go | 5 ++++- .../internal/metadata/generated_status.go | 5 ++++- .../internal/metadata/generated_status.go | 5 ++++- .../internal/metadata/generated_status.go | 5 ++++- .../internal/metadata/generated_status.go | 5 ++++- .../internal/metadata/generated_status.go | 5 ++++- .../internal/metadata/generated_status.go | 5 ++++- .../otlpreceiver/internal/metadata/generated_status.go | 5 ++++- 14 files changed, 61 insertions(+), 16 deletions(-) diff --git a/cmd/mdatagen/internal/metadata/generated_status.go b/cmd/mdatagen/internal/metadata/generated_status.go index 02b54824865..ac60a5ce31f 100644 --- a/cmd/mdatagen/internal/metadata/generated_status.go +++ b/cmd/mdatagen/internal/metadata/generated_status.go @@ -9,8 +9,11 @@ import ( "go.opentelemetry.io/collector/component" ) +var ( + Type = component.MustType("file") +) + const ( - Type = "file" TracesStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelDevelopment MetricsStability = component.StabilityLevelStable diff --git a/cmd/mdatagen/main_test.go b/cmd/mdatagen/main_test.go index 56f4413aa49..f00d7ca639e 100644 --- a/cmd/mdatagen/main_test.go +++ b/cmd/mdatagen/main_test.go @@ -328,8 +328,11 @@ import ( "go.opentelemetry.io/otel/trace" ) +var ( + Type = component.MustType("foo") +) + const ( - Type = "foo" MetricsStability = component.StabilityLevelBeta ) @@ -362,8 +365,11 @@ import ( "go.opentelemetry.io/otel/trace" ) +var ( + Type = component.MustType("foo") +) + const ( - Type = "foo" MetricsStability = component.StabilityLevelAlpha ) diff --git a/cmd/mdatagen/templates/status.go.tmpl b/cmd/mdatagen/templates/status.go.tmpl index 654e6b1518a..886dde6dbf2 100644 --- a/cmd/mdatagen/templates/status.go.tmpl +++ b/cmd/mdatagen/templates/status.go.tmpl @@ -8,8 +8,11 @@ import ( "go.opentelemetry.io/otel/trace" ) +var ( + Type = component.MustType("{{ .Type }}") +) + const ( - Type = "{{ .Type }}" {{- range $stability, $signals := .Status.Stability }} {{- range $signal := $signals }} {{ toCamelCase $signal }}Stability = component.StabilityLevel{{ casesTitle $stability }} @@ -23,4 +26,4 @@ func Meter(settings component.TelemetrySettings) metric.Meter { func Tracer(settings component.TelemetrySettings) trace.Tracer { return settings.TracerProvider.Tracer("{{ .ScopeName }}") -} \ No newline at end of file +} diff --git a/connector/forwardconnector/internal/metadata/generated_status.go b/connector/forwardconnector/internal/metadata/generated_status.go index 82477a52d7c..a2ee29fd254 100644 --- a/connector/forwardconnector/internal/metadata/generated_status.go +++ b/connector/forwardconnector/internal/metadata/generated_status.go @@ -9,8 +9,11 @@ import ( "go.opentelemetry.io/collector/component" ) +var ( + Type = component.MustType("forward") +) + const ( - Type = "forward" TracesToTracesStability = component.StabilityLevelBeta MetricsToMetricsStability = component.StabilityLevelBeta LogsToLogsStability = component.StabilityLevelBeta diff --git a/exporter/debugexporter/internal/metadata/generated_status.go b/exporter/debugexporter/internal/metadata/generated_status.go index 00fdd4b26ad..ffdb48a1b73 100644 --- a/exporter/debugexporter/internal/metadata/generated_status.go +++ b/exporter/debugexporter/internal/metadata/generated_status.go @@ -9,8 +9,11 @@ import ( "go.opentelemetry.io/collector/component" ) +var ( + Type = component.MustType("debug") +) + const ( - Type = "debug" TracesStability = component.StabilityLevelDevelopment MetricsStability = component.StabilityLevelDevelopment LogsStability = component.StabilityLevelDevelopment diff --git a/exporter/loggingexporter/internal/metadata/generated_status.go b/exporter/loggingexporter/internal/metadata/generated_status.go index 20698f3672a..d510359663e 100644 --- a/exporter/loggingexporter/internal/metadata/generated_status.go +++ b/exporter/loggingexporter/internal/metadata/generated_status.go @@ -9,8 +9,11 @@ import ( "go.opentelemetry.io/collector/component" ) +var ( + Type = component.MustType("logging") +) + const ( - Type = "logging" TracesStability = component.StabilityLevelDeprecated MetricsStability = component.StabilityLevelDeprecated LogsStability = component.StabilityLevelDeprecated diff --git a/exporter/otlpexporter/internal/metadata/generated_status.go b/exporter/otlpexporter/internal/metadata/generated_status.go index 6876ebc2b26..d5fff19b086 100644 --- a/exporter/otlpexporter/internal/metadata/generated_status.go +++ b/exporter/otlpexporter/internal/metadata/generated_status.go @@ -9,8 +9,11 @@ import ( "go.opentelemetry.io/collector/component" ) +var ( + Type = component.MustType("otlp") +) + const ( - Type = "otlp" LogsStability = component.StabilityLevelBeta TracesStability = component.StabilityLevelStable MetricsStability = component.StabilityLevelStable diff --git a/exporter/otlphttpexporter/internal/metadata/generated_status.go b/exporter/otlphttpexporter/internal/metadata/generated_status.go index f6f8933d685..7f96dea72b5 100644 --- a/exporter/otlphttpexporter/internal/metadata/generated_status.go +++ b/exporter/otlphttpexporter/internal/metadata/generated_status.go @@ -9,8 +9,11 @@ import ( "go.opentelemetry.io/collector/component" ) +var ( + Type = component.MustType("otlphttp") +) + const ( - Type = "otlphttp" LogsStability = component.StabilityLevelBeta TracesStability = component.StabilityLevelStable MetricsStability = component.StabilityLevelStable diff --git a/extension/ballastextension/internal/metadata/generated_status.go b/extension/ballastextension/internal/metadata/generated_status.go index 70ced31503c..6949900abae 100644 --- a/extension/ballastextension/internal/metadata/generated_status.go +++ b/extension/ballastextension/internal/metadata/generated_status.go @@ -9,8 +9,11 @@ import ( "go.opentelemetry.io/collector/component" ) +var ( + Type = component.MustType("memory_ballast") +) + const ( - Type = "memory_ballast" ExtensionStability = component.StabilityLevelDeprecated ) diff --git a/extension/memorylimiterextension/internal/metadata/generated_status.go b/extension/memorylimiterextension/internal/metadata/generated_status.go index b76d2f1cd74..14c76c773b4 100644 --- a/extension/memorylimiterextension/internal/metadata/generated_status.go +++ b/extension/memorylimiterextension/internal/metadata/generated_status.go @@ -9,8 +9,11 @@ import ( "go.opentelemetry.io/collector/component" ) +var ( + Type = component.MustType("memory_limiter") +) + const ( - Type = "memory_limiter" ExtensionStability = component.StabilityLevelDevelopment ) diff --git a/extension/zpagesextension/internal/metadata/generated_status.go b/extension/zpagesextension/internal/metadata/generated_status.go index 72170d1f87b..eea2d1bfde1 100644 --- a/extension/zpagesextension/internal/metadata/generated_status.go +++ b/extension/zpagesextension/internal/metadata/generated_status.go @@ -9,8 +9,11 @@ import ( "go.opentelemetry.io/collector/component" ) +var ( + Type = component.MustType("zpages") +) + const ( - Type = "zpages" ExtensionStability = component.StabilityLevelBeta ) diff --git a/processor/batchprocessor/internal/metadata/generated_status.go b/processor/batchprocessor/internal/metadata/generated_status.go index eb9c10bdafe..a3bf4bcc8e0 100644 --- a/processor/batchprocessor/internal/metadata/generated_status.go +++ b/processor/batchprocessor/internal/metadata/generated_status.go @@ -9,8 +9,11 @@ import ( "go.opentelemetry.io/collector/component" ) +var ( + Type = component.MustType("batch") +) + const ( - Type = "batch" TracesStability = component.StabilityLevelBeta MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta diff --git a/processor/memorylimiterprocessor/internal/metadata/generated_status.go b/processor/memorylimiterprocessor/internal/metadata/generated_status.go index 7068f5e29eb..75e6b866094 100644 --- a/processor/memorylimiterprocessor/internal/metadata/generated_status.go +++ b/processor/memorylimiterprocessor/internal/metadata/generated_status.go @@ -9,8 +9,11 @@ import ( "go.opentelemetry.io/collector/component" ) +var ( + Type = component.MustType("memory_limiter") +) + const ( - Type = "memory_limiter" TracesStability = component.StabilityLevelBeta MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelBeta diff --git a/receiver/otlpreceiver/internal/metadata/generated_status.go b/receiver/otlpreceiver/internal/metadata/generated_status.go index ec7a695b15f..d67e10166a4 100644 --- a/receiver/otlpreceiver/internal/metadata/generated_status.go +++ b/receiver/otlpreceiver/internal/metadata/generated_status.go @@ -9,8 +9,11 @@ import ( "go.opentelemetry.io/collector/component" ) +var ( + Type = component.MustType("otlp") +) + const ( - Type = "otlp" LogsStability = component.StabilityLevelBeta TracesStability = component.StabilityLevelStable MetricsStability = component.StabilityLevelStable From 5c237bca149cbaf6373d37cda052e3eaaa0010ad Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Mon, 29 Jan 2024 18:24:32 +0100 Subject: [PATCH 03/13] Add changelog note --- .../mx-psi_component-type-validation.yaml | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 .chloggen/mx-psi_component-type-validation.yaml diff --git a/.chloggen/mx-psi_component-type-validation.yaml b/.chloggen/mx-psi_component-type-validation.yaml new file mode 100755 index 00000000000..d359ac32a6b --- /dev/null +++ b/.chloggen/mx-psi_component-type-validation.yaml @@ -0,0 +1,26 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: component + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Validate component.ID at creation and unmarshaling time. + +# One or more tracking issues or pull requests related to the change +issues: [9208] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: | + - A component.Type must start with an ASCII alphabetic character and can only contain ASCII alphanumeric characters and '_'. + +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [api] From 0dc8797508ee608e8e81dca135cf2348ebc5e4f2 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Mon, 29 Jan 2024 18:37:23 +0100 Subject: [PATCH 04/13] Correct changelog note --- .chloggen/mx-psi_component-type-validation.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.chloggen/mx-psi_component-type-validation.yaml b/.chloggen/mx-psi_component-type-validation.yaml index d359ac32a6b..af38d42d60f 100755 --- a/.chloggen/mx-psi_component-type-validation.yaml +++ b/.chloggen/mx-psi_component-type-validation.yaml @@ -7,7 +7,7 @@ change_type: breaking component: component # A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Validate component.ID at creation and unmarshaling time. +note: Validate component.Type at creation and unmarshaling time. # One or more tracking issues or pull requests related to the change issues: [9208] From 91c9be8aeb94cce1ca2b0ea8ccb7404c985cf57e Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Mon, 29 Jan 2024 18:39:42 +0100 Subject: [PATCH 05/13] make gogenerate --- receiver/scraperhelper/settings_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/receiver/scraperhelper/settings_test.go b/receiver/scraperhelper/settings_test.go index a8456e2b0c6..57570181ea5 100644 --- a/receiver/scraperhelper/settings_test.go +++ b/receiver/scraperhelper/settings_test.go @@ -8,6 +8,7 @@ import ( "time" "github.com/stretchr/testify/assert" + "go.opentelemetry.io/collector/component" ) From 796a4f641b3630176027e0adfc8e54bdb9f6b01e Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Tue, 30 Jan 2024 13:16:55 +0100 Subject: [PATCH 06/13] Remove mention to '-' from documentation --- component/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/component/config.go b/component/config.go index 6bccbab61fb..dc177a8c38d 100644 --- a/component/config.go +++ b/component/config.go @@ -128,7 +128,7 @@ var typeRegexp = regexp.MustCompile(`^[a-zA-Z][0-9a-zA-Z_]*$`) // A type must // - have at least one character, // - start with an ASCII alphabetic character and -// - can only contain ASCII alphanumeric characters, '-' and '_'. +// - can only contain ASCII alphanumeric characters and '_'. func newType(ty string) (Type, error) { if len(ty) == 0 { return Type(""), fmt.Errorf("id must not be empty") @@ -143,7 +143,7 @@ func newType(ty string) (Type, error) { // A type must // - have at least one character, // - start with an ASCII alphabetic character and -// - can only contain ASCII alphanumeric characters, '-' and '_'. +// - can only contain ASCII alphanumeric characters and '_'. func MustType(strType string) Type { ty, err := newType(strType) if err != nil { From 80e289da11cab73789131f767596220708e3db83 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Tue, 30 Jan 2024 13:22:47 +0100 Subject: [PATCH 07/13] Rename MustType to MustNewType --- .../internal/metadata/generated_status.go | 2 +- cmd/mdatagen/main_test.go | 4 +- cmd/mdatagen/templates/status.go.tmpl | 2 +- component/componenttest/nop_host_test.go | 2 +- .../otelprometheuschecker_test.go | 8 +- component/config.go | 4 +- component/identifiable_test.go | 4 +- config/configauth/configauth_test.go | 6 +- config/configgrpc/configgrpc_test.go | 8 +- config/confighttp/confighttp_test.go | 8 +- connector/connector_test.go | 38 +- connector/connectortest/connector.go | 2 +- connector/connectortest/connector_test.go | 2 +- .../internal/metadata/generated_status.go | 2 +- connector/logs_router_test.go | 8 +- connector/metrics_router_test.go | 8 +- connector/traces_router_test.go | 8 +- exporter/debugexporter/factory.go | 2 +- .../internal/metadata/generated_status.go | 2 +- exporter/exporter_test.go | 34 +- exporter/exporterhelper/common_test.go | 2 +- .../internal/persistent_queue_test.go | 10 +- exporter/exporterhelper/logs_test.go | 6 +- exporter/exporterhelper/metrics_test.go | 6 +- exporter/exporterhelper/obsexporter_test.go | 2 +- exporter/exporterhelper/obsreport_test.go | 2 +- exporter/exporterhelper/queue_sender_test.go | 6 +- exporter/exporterhelper/traces_test.go | 6 +- .../exportertest/contract_checker_test.go | 4 +- exporter/exportertest/nop_exporter.go | 2 +- exporter/exportertest/nop_exporter_test.go | 2 +- exporter/loggingexporter/factory.go | 2 +- .../internal/metadata/generated_status.go | 2 +- exporter/otlpexporter/config_test.go | 2 +- .../internal/metadata/generated_status.go | 2 +- .../internal/metadata/generated_status.go | 2 +- .../internal/metadata/generated_status.go | 2 +- extension/extension_test.go | 20 +- extension/extensiontest/nop_extension.go | 2 +- extension/extensiontest/nop_extension_test.go | 2 +- .../extensiontest/statuswatcher_extension.go | 2 +- .../statuswatcher_extension_test.go | 2 +- .../internal/metadata/generated_status.go | 2 +- .../internal/metadata/generated_status.go | 2 +- internal/memorylimiter/memorylimiter_test.go | 2 +- .../sharedcomponent/sharedcomponent_test.go | 2 +- otelcol/command_components_test.go | 2 +- otelcol/config_test.go | 72 +- .../configunmarshaler/configs_test.go | 2 +- otelcol/otelcoltest/config_test.go | 28 +- otelcol/otelcoltest/nop_factories_test.go | 2 +- .../internal/metadata/generated_status.go | 2 +- processor/batchprocessor/metrics_test.go | 2 +- .../internal/metadata/generated_status.go | 2 +- .../memorylimiter_test.go | 2 +- processor/processor_test.go | 34 +- processor/processorhelper/obsreport_test.go | 2 +- processor/processortest/nop_processor.go | 2 +- processor/processortest/nop_processor_test.go | 2 +- .../processortest/unhealthy_processor.go | 2 +- .../processortest/unhealthy_processor_test.go | 2 +- .../otlpreceiver/internal/logs/otlp_test.go | 2 +- .../internal/metadata/generated_status.go | 2 +- .../internal/metrics/otlp_test.go | 2 +- .../otlpreceiver/internal/trace/otlp_test.go | 2 +- receiver/otlpreceiver/otlp_test.go | 2 +- receiver/receiver_test.go | 34 +- receiver/receiverhelper/obsreport_test.go | 2 +- .../receivertest/contract_checker_test.go | 2 +- receiver/receivertest/nop_receiver.go | 2 +- receiver/receivertest/nop_receiver_test.go | 2 +- receiver/scraperhelper/obsreport_test.go | 4 +- receiver/scraperhelper/scraper.go | 2 +- .../scraperhelper/scrapercontroller_test.go | 4 +- receiver/scraperhelper/settings_test.go | 2 +- service/config_test.go | 20 +- service/extensions/extensions_test.go | 52 +- service/internal/graph/graph_test.go | 1422 ++++++++--------- .../testcomponents/example_connector.go | 4 +- .../testcomponents/example_exporter.go | 2 +- .../testcomponents/example_processor.go | 2 +- .../testcomponents/example_receiver.go | 2 +- .../internal/testcomponents/example_router.go | 2 +- .../testcomponents/example_router_test.go | 12 +- service/pipelines/config_test.go | 22 +- service/service_test.go | 22 +- 86 files changed, 1017 insertions(+), 1017 deletions(-) diff --git a/cmd/mdatagen/internal/metadata/generated_status.go b/cmd/mdatagen/internal/metadata/generated_status.go index ac60a5ce31f..773067ac829 100644 --- a/cmd/mdatagen/internal/metadata/generated_status.go +++ b/cmd/mdatagen/internal/metadata/generated_status.go @@ -10,7 +10,7 @@ import ( ) var ( - Type = component.MustType("file") + Type = component.MustNewType("file") ) const ( diff --git a/cmd/mdatagen/main_test.go b/cmd/mdatagen/main_test.go index f00d7ca639e..3d4bd2b192b 100644 --- a/cmd/mdatagen/main_test.go +++ b/cmd/mdatagen/main_test.go @@ -329,7 +329,7 @@ import ( ) var ( - Type = component.MustType("foo") + Type = component.MustNewType("foo") ) const ( @@ -366,7 +366,7 @@ import ( ) var ( - Type = component.MustType("foo") + Type = component.MustNewType("foo") ) const ( diff --git a/cmd/mdatagen/templates/status.go.tmpl b/cmd/mdatagen/templates/status.go.tmpl index 886dde6dbf2..850058b9cfa 100644 --- a/cmd/mdatagen/templates/status.go.tmpl +++ b/cmd/mdatagen/templates/status.go.tmpl @@ -9,7 +9,7 @@ import ( ) var ( - Type = component.MustType("{{ .Type }}") + Type = component.MustNewType("{{ .Type }}") ) const ( diff --git a/component/componenttest/nop_host_test.go b/component/componenttest/nop_host_test.go index fa03c31e217..99d323681ca 100644 --- a/component/componenttest/nop_host_test.go +++ b/component/componenttest/nop_host_test.go @@ -21,5 +21,5 @@ func TestNewNopHost(t *testing.T) { nh.ReportFatalError(errors.New("TestError")) assert.Nil(t, nh.GetExporters()) // nolint: staticcheck assert.Nil(t, nh.GetExtensions()) - assert.Nil(t, nh.GetFactory(component.KindReceiver, component.MustType("test"))) + assert.Nil(t, nh.GetFactory(component.KindReceiver, component.MustNewType("test"))) } diff --git a/component/componenttest/otelprometheuschecker_test.go b/component/componenttest/otelprometheuschecker_test.go index ff95747dc9d..9c1691197f7 100644 --- a/component/componenttest/otelprometheuschecker_test.go +++ b/component/componenttest/otelprometheuschecker_test.go @@ -36,10 +36,10 @@ func TestPromChecker(t *testing.T) { pc, err := newStubPromChecker() require.NoError(t, err) - scraper := component.NewID(component.MustType("fakeScraper")) - receiver := component.NewID(component.MustType("fakeReceiver")) - processor := component.NewID(component.MustType("fakeProcessor")) - exporter := component.NewID(component.MustType("fakeExporter")) + scraper := component.NewID(component.MustNewType("fakeScraper")) + receiver := component.NewID(component.MustNewType("fakeReceiver")) + processor := component.NewID(component.MustNewType("fakeProcessor")) + exporter := component.NewID(component.MustNewType("fakeExporter")) transport := "fakeTransport" assert.NoError(t, diff --git a/component/config.go b/component/config.go index dc177a8c38d..ac346fbaa55 100644 --- a/component/config.go +++ b/component/config.go @@ -139,12 +139,12 @@ func newType(ty string) (Type, error) { return Type(ty), nil } -// MustType creates a type. It panics if the type is invalid. +// MustNewType creates a type. It panics if the type is invalid. // A type must // - have at least one character, // - start with an ASCII alphabetic character and // - can only contain ASCII alphanumeric characters and '_'. -func MustType(strType string) Type { +func MustNewType(strType string) Type { ty, err := newType(strType) if err != nil { panic(err) diff --git a/component/identifiable_test.go b/component/identifiable_test.go index e7786cf2bcf..25c449ef11c 100644 --- a/component/identifiable_test.go +++ b/component/identifiable_test.go @@ -10,14 +10,14 @@ import ( ) func TestMarshalText(t *testing.T) { - id := NewIDWithName(MustType("test"), "name") + id := NewIDWithName(MustNewType("test"), "name") got, err := id.MarshalText() assert.NoError(t, err) assert.Equal(t, id.String(), string(got)) } func TestUnmarshalText(t *testing.T) { - validType := MustType("valid_type") + validType := MustNewType("valid_type") var testCases = []struct { idStr string expectedErr bool diff --git a/config/configauth/configauth_test.go b/config/configauth/configauth_test.go index 0c85f6d25de..0383df9a8e1 100644 --- a/config/configauth/configauth_test.go +++ b/config/configauth/configauth_test.go @@ -13,7 +13,7 @@ import ( "go.opentelemetry.io/collector/extension/auth" ) -var mockID = component.NewID(component.MustType("mock")) +var mockID = component.NewID(component.MustNewType("mock")) func TestGetServer(t *testing.T) { testCases := []struct { @@ -58,7 +58,7 @@ func TestGetServer(t *testing.T) { func TestGetServerFails(t *testing.T) { cfg := &Authentication{ - AuthenticatorID: component.NewID(component.MustType("does_not_exist")), + AuthenticatorID: component.NewID(component.MustNewType("does_not_exist")), } authenticator, err := cfg.GetServerAuthenticator(map[component.ID]component.Component{}) @@ -109,7 +109,7 @@ func TestGetClient(t *testing.T) { func TestGetClientFails(t *testing.T) { cfg := &Authentication{ - AuthenticatorID: component.NewID(component.MustType("does_not_exist")), + AuthenticatorID: component.NewID(component.MustNewType("does_not_exist")), } authenticator, err := cfg.GetClientAuthenticator(map[component.ID]component.Component{}) assert.ErrorIs(t, err, errAuthenticatorNotFound) diff --git a/config/configgrpc/configgrpc_test.go b/config/configgrpc/configgrpc_test.go index 7cdd5552655..2a524ba6615 100644 --- a/config/configgrpc/configgrpc_test.go +++ b/config/configgrpc/configgrpc_test.go @@ -51,10 +51,10 @@ func init() { } var ( - componentID = component.NewID(component.MustType("component")) - testAuthID = component.NewID(component.MustType("testauth")) - mockID = component.NewID(component.MustType("mock")) - doesntExistID = component.NewID(component.MustType("doesntexist")) + componentID = component.NewID(component.MustNewType("component")) + testAuthID = component.NewID(component.MustNewType("testauth")) + mockID = component.NewID(component.MustNewType("mock")) + doesntExistID = component.NewID(component.MustNewType("doesntexist")) ) func TestDefaultGrpcClientSettings(t *testing.T) { diff --git a/config/confighttp/confighttp_test.go b/config/confighttp/confighttp_test.go index 68f7d7f24f2..44beebe9582 100644 --- a/config/confighttp/confighttp_test.go +++ b/config/confighttp/confighttp_test.go @@ -43,10 +43,10 @@ func (c *customRoundTripper) RoundTrip(_ *http.Request) (*http.Response, error) } var ( - testAuthID = component.NewID(component.MustType("testauth")) - mockID = component.NewID(component.MustType("mock")) - dummyID = component.NewID(component.MustType("dummy")) - nonExistingID = component.NewID(component.MustType("nonexisting")) + testAuthID = component.NewID(component.MustNewType("testauth")) + mockID = component.NewID(component.MustNewType("mock")) + dummyID = component.NewID(component.MustNewType("dummy")) + nonExistingID = component.NewID(component.MustNewType("nonexisting")) ) func TestAllHTTPClientSettings(t *testing.T) { diff --git a/connector/connector_test.go b/connector/connector_test.go index 86a337c3934..ee46b57312d 100644 --- a/connector/connector_test.go +++ b/connector/connector_test.go @@ -18,8 +18,8 @@ import ( ) var ( - testType = component.MustType("test") - testID = component.NewIDWithName(component.MustType("type"), "name") + testType = component.MustNewType("test") + testID = component.NewIDWithName(component.MustNewType("type"), "name") ) func TestNewFactoryNoOptions(t *testing.T) { @@ -184,8 +184,8 @@ func TestMakeFactoryMap(t *testing.T) { out map[component.Type]Factory } - p1 := NewFactory(component.MustType("p1"), nil) - p2 := NewFactory(component.MustType("p2"), nil) + p1 := NewFactory(component.MustNewType("p1"), nil) + p2 := NewFactory(component.MustNewType("p2"), nil) testCases := []testCase{ { name: "different names", @@ -197,7 +197,7 @@ func TestMakeFactoryMap(t *testing.T) { }, { name: "same name", - in: []Factory{p1, p2, NewFactory(component.MustType("p1"), nil)}, + in: []Factory{p1, p2, NewFactory(component.MustNewType("p1"), nil)}, }, } @@ -218,9 +218,9 @@ func TestMakeFactoryMap(t *testing.T) { func TestBuilder(t *testing.T) { defaultCfg := struct{}{} factories, err := MakeFactoryMap([]Factory{ - NewFactory(component.MustType("err"), nil), + NewFactory(component.MustNewType("err"), nil), NewFactory( - component.MustType("all"), + component.MustNewType("all"), func() component.Config { return &defaultCfg }, WithTracesToTraces(createTracesToTraces, component.StabilityLevelDevelopment), WithTracesToMetrics(createTracesToMetrics, component.StabilityLevelDevelopment), @@ -242,28 +242,28 @@ func TestBuilder(t *testing.T) { }{ { name: "unknown", - id: component.NewID(component.MustType("unknown")), + id: component.NewID(component.MustNewType("unknown")), err: func(_, _ component.DataType) string { return "connector factory not available for: \"unknown\"" }, }, { name: "err", - id: component.NewID(component.MustType("err")), + id: component.NewID(component.MustNewType("err")), err: func(expType, rcvType component.DataType) string { return fmt.Sprintf("connector \"err\" cannot connect from %s to %s: telemetry type is not supported", expType, rcvType) }, }, { name: "all", - id: component.NewID(component.MustType("all")), + id: component.NewID(component.MustNewType("all")), err: func(_, _ component.DataType) string { return "" }, }, { name: "all/named", - id: component.NewIDWithName(component.MustType("all"), "named"), + id: component.NewIDWithName(component.MustNewType("all"), "named"), err: func(_, _ component.DataType) string { return "" }, @@ -361,7 +361,7 @@ func TestBuilderMissingConfig(t *testing.T) { defaultCfg := struct{}{} factories, err := MakeFactoryMap([]Factory{ NewFactory( - component.MustType("all"), + component.MustNewType("all"), func() component.Config { return &defaultCfg }, WithTracesToTraces(createTracesToTraces, component.StabilityLevelDevelopment), WithTracesToMetrics(createTracesToMetrics, component.StabilityLevelDevelopment), @@ -378,7 +378,7 @@ func TestBuilderMissingConfig(t *testing.T) { require.NoError(t, err) bErr := NewBuilder(map[component.ID]component.Config{}, factories) - missingID := component.NewIDWithName(component.MustType("all"), "missing") + missingID := component.NewIDWithName(component.MustNewType("all"), "missing") t2t, err := bErr.CreateTracesToTraces(context.Background(), createSettings(missingID), nil) assert.EqualError(t, err, "connector \"all/missing\" is not configured") @@ -418,17 +418,17 @@ func TestBuilderMissingConfig(t *testing.T) { } func TestBuilderGetters(t *testing.T) { - factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustType("foo"), nil)}...) + factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustNewType("foo"), nil)}...) require.NoError(t, err) - cfgs := map[component.ID]component.Config{component.NewID(component.MustType("foo")): struct{}{}} + cfgs := map[component.ID]component.Config{component.NewID(component.MustNewType("foo")): struct{}{}} b := NewBuilder(cfgs, factories) - assert.True(t, b.IsConfigured(component.NewID(component.MustType("foo")))) - assert.False(t, b.IsConfigured(component.NewID(component.MustType("bar")))) + assert.True(t, b.IsConfigured(component.NewID(component.MustNewType("foo")))) + assert.False(t, b.IsConfigured(component.NewID(component.MustNewType("bar")))) - assert.NotNil(t, b.Factory(component.NewID(component.MustType("foo")).Type())) - assert.Nil(t, b.Factory(component.NewID(component.MustType("bar")).Type())) + assert.NotNil(t, b.Factory(component.NewID(component.MustNewType("foo")).Type())) + assert.Nil(t, b.Factory(component.NewID(component.MustNewType("bar")).Type())) } var nopInstance = &nopConnector{ diff --git a/connector/connectortest/connector.go b/connector/connectortest/connector.go index c1eb2456f39..34570029483 100644 --- a/connector/connectortest/connector.go +++ b/connector/connectortest/connector.go @@ -13,7 +13,7 @@ import ( "go.opentelemetry.io/collector/consumer/consumertest" ) -var nopType = component.MustType("nop") +var nopType = component.MustNewType("nop") // NewNopCreateSettings returns a new nop settings for Create* functions. func NewNopCreateSettings() connector.CreateSettings { diff --git a/connector/connectortest/connector_test.go b/connector/connectortest/connector_test.go index e2fca0d67a2..4a2894f8544 100644 --- a/connector/connectortest/connector_test.go +++ b/connector/connectortest/connector_test.go @@ -21,7 +21,7 @@ import ( func TestNewNopConnectorFactory(t *testing.T) { factory := NewNopFactory() require.NotNil(t, factory) - assert.Equal(t, component.MustType("nop"), factory.Type()) + assert.Equal(t, component.MustNewType("nop"), factory.Type()) cfg := factory.CreateDefaultConfig() assert.Equal(t, &nopConfig{}, cfg) diff --git a/connector/forwardconnector/internal/metadata/generated_status.go b/connector/forwardconnector/internal/metadata/generated_status.go index a2ee29fd254..9505adb84d7 100644 --- a/connector/forwardconnector/internal/metadata/generated_status.go +++ b/connector/forwardconnector/internal/metadata/generated_status.go @@ -10,7 +10,7 @@ import ( ) var ( - Type = component.MustType("forward") + Type = component.MustNewType("forward") ) const ( diff --git a/connector/logs_router_test.go b/connector/logs_router_test.go index d84f0d36814..c4be9f2d205 100644 --- a/connector/logs_router_test.go +++ b/connector/logs_router_test.go @@ -48,7 +48,7 @@ func fuzzLogs(numIDs, numCons, numLogs int) func(*testing.T) { // If any consumer is mutating, the router must report mutating for i := 0; i < numCons; i++ { - allIDs = append(allIDs, component.NewIDWithName(component.MustType("sink"), strconv.Itoa(numCons))) + allIDs = append(allIDs, component.NewIDWithName(component.MustNewType("sink"), strconv.Itoa(numCons))) // Random chance for each consumer to be mutating if (numCons+numLogs+i)%4 == 0 { allCons = append(allCons, &mutatingLogsSink{LogsSink: new(consumertest.LogsSink)}) @@ -108,8 +108,8 @@ func TestLogsRouterConsumers(t *testing.T) { ctx := context.Background() ld := testdata.GenerateLogs(1) - fooID := component.NewID(component.MustType("foo")) - barID := component.NewID(component.MustType("bar")) + fooID := component.NewID(component.MustNewType("foo")) + barID := component.NewID(component.MustNewType("bar")) foo := new(consumertest.LogsSink) bar := new(consumertest.LogsSink) @@ -150,7 +150,7 @@ func TestLogsRouterConsumers(t *testing.T) { assert.Nil(t, none) assert.Error(t, err) - fake, err := r.Consumer(component.NewID(component.MustType("fake"))) + fake, err := r.Consumer(component.NewID(component.MustNewType("fake"))) assert.Nil(t, fake) assert.Error(t, err) } diff --git a/connector/metrics_router_test.go b/connector/metrics_router_test.go index 9a059d1444e..196d5214868 100644 --- a/connector/metrics_router_test.go +++ b/connector/metrics_router_test.go @@ -48,7 +48,7 @@ func fuzzMetrics(numIDs, numCons, numMetrics int) func(*testing.T) { // If any consumer is mutating, the router must report mutating for i := 0; i < numCons; i++ { - allIDs = append(allIDs, component.NewIDWithName(component.MustType("sink"), strconv.Itoa(numCons))) + allIDs = append(allIDs, component.NewIDWithName(component.MustNewType("sink"), strconv.Itoa(numCons))) // Random chance for each consumer to be mutating if (numCons+numMetrics+i)%4 == 0 { allCons = append(allCons, &mutatingMetricsSink{MetricsSink: new(consumertest.MetricsSink)}) @@ -108,8 +108,8 @@ func TestMetricsRouterConsumers(t *testing.T) { ctx := context.Background() md := testdata.GenerateMetrics(1) - fooID := component.NewID(component.MustType("foo")) - barID := component.NewID(component.MustType("bar")) + fooID := component.NewID(component.MustNewType("foo")) + barID := component.NewID(component.MustNewType("bar")) foo := new(consumertest.MetricsSink) bar := new(consumertest.MetricsSink) @@ -150,7 +150,7 @@ func TestMetricsRouterConsumers(t *testing.T) { assert.Nil(t, none) assert.Error(t, err) - fake, err := r.Consumer(component.NewID(component.MustType("fake"))) + fake, err := r.Consumer(component.NewID(component.MustNewType("fake"))) assert.Nil(t, fake) assert.Error(t, err) } diff --git a/connector/traces_router_test.go b/connector/traces_router_test.go index 134cb058a2a..3e7822fbfdc 100644 --- a/connector/traces_router_test.go +++ b/connector/traces_router_test.go @@ -48,7 +48,7 @@ func fuzzTraces(numIDs, numCons, numTraces int) func(*testing.T) { // If any consumer is mutating, the router must report mutating for i := 0; i < numCons; i++ { - allIDs = append(allIDs, component.NewIDWithName(component.MustType("sink"), strconv.Itoa(numCons))) + allIDs = append(allIDs, component.NewIDWithName(component.MustNewType("sink"), strconv.Itoa(numCons))) // Random chance for each consumer to be mutating if (numCons+numTraces+i)%4 == 0 { allCons = append(allCons, &mutatingTracesSink{TracesSink: new(consumertest.TracesSink)}) @@ -108,8 +108,8 @@ func TestTracesRouterConsumer(t *testing.T) { ctx := context.Background() td := testdata.GenerateTraces(1) - fooID := component.NewID(component.MustType("foo")) - barID := component.NewID(component.MustType("bar")) + fooID := component.NewID(component.MustNewType("foo")) + barID := component.NewID(component.MustNewType("bar")) foo := new(consumertest.TracesSink) bar := new(consumertest.TracesSink) @@ -150,7 +150,7 @@ func TestTracesRouterConsumer(t *testing.T) { assert.Nil(t, none) assert.Error(t, err) - fake, err := r.Consumer(component.NewID(component.MustType("fake"))) + fake, err := r.Consumer(component.NewID(component.MustNewType("fake"))) assert.Nil(t, fake) assert.Error(t, err) } diff --git a/exporter/debugexporter/factory.go b/exporter/debugexporter/factory.go index 3d4baa22e36..e9e75130dd6 100644 --- a/exporter/debugexporter/factory.go +++ b/exporter/debugexporter/factory.go @@ -14,7 +14,7 @@ import ( ) // The value of "type" key in configuration. -var componentType = component.MustType("debug") +var componentType = component.MustNewType("debug") const ( defaultSamplingInitial = 2 diff --git a/exporter/debugexporter/internal/metadata/generated_status.go b/exporter/debugexporter/internal/metadata/generated_status.go index ffdb48a1b73..53acecdba3c 100644 --- a/exporter/debugexporter/internal/metadata/generated_status.go +++ b/exporter/debugexporter/internal/metadata/generated_status.go @@ -10,7 +10,7 @@ import ( ) var ( - Type = component.MustType("debug") + Type = component.MustNewType("debug") ) const ( diff --git a/exporter/exporter_test.go b/exporter/exporter_test.go index 51e29c6f6cc..45fb0f7d2ad 100644 --- a/exporter/exporter_test.go +++ b/exporter/exporter_test.go @@ -16,7 +16,7 @@ import ( ) func TestNewFactory(t *testing.T) { - var testType = component.MustType("test") + var testType = component.MustNewType("test") defaultCfg := struct{}{} factory := NewFactory( testType, @@ -32,7 +32,7 @@ func TestNewFactory(t *testing.T) { } func TestNewFactoryWithOptions(t *testing.T) { - var testType = component.MustType("test") + var testType = component.MustNewType("test") defaultCfg := struct{}{} factory := NewFactory( testType, @@ -63,8 +63,8 @@ func TestMakeFactoryMap(t *testing.T) { out map[component.Type]Factory } - p1 := NewFactory(component.MustType("p1"), nil) - p2 := NewFactory(component.MustType("p2"), nil) + p1 := NewFactory(component.MustNewType("p1"), nil) + p2 := NewFactory(component.MustNewType("p2"), nil) testCases := []testCase{ { name: "different names", @@ -76,7 +76,7 @@ func TestMakeFactoryMap(t *testing.T) { }, { name: "same name", - in: []Factory{p1, p2, NewFactory(component.MustType("p1"), nil)}, + in: []Factory{p1, p2, NewFactory(component.MustNewType("p1"), nil)}, }, } @@ -97,9 +97,9 @@ func TestMakeFactoryMap(t *testing.T) { func TestBuilder(t *testing.T) { defaultCfg := struct{}{} factories, err := MakeFactoryMap([]Factory{ - NewFactory(component.MustType("err"), nil), + NewFactory(component.MustNewType("err"), nil), NewFactory( - component.MustType("all"), + component.MustNewType("all"), func() component.Config { return &defaultCfg }, WithTraces(createTraces, component.StabilityLevelDevelopment), WithMetrics(createMetrics, component.StabilityLevelAlpha), @@ -115,21 +115,21 @@ func TestBuilder(t *testing.T) { }{ { name: "unknown", - id: component.NewID(component.MustType("unknown")), + id: component.NewID(component.MustNewType("unknown")), err: "exporter factory not available for: \"unknown\"", }, { name: "err", - id: component.NewID(component.MustType("err")), + id: component.NewID(component.MustNewType("err")), err: "telemetry type is not supported", }, { name: "all", - id: component.NewID(component.MustType("all")), + id: component.NewID(component.MustNewType("all")), }, { name: "all/named", - id: component.NewIDWithName(component.MustType("all"), "named"), + id: component.NewIDWithName(component.MustNewType("all"), "named"), }, } @@ -172,7 +172,7 @@ func TestBuilderMissingConfig(t *testing.T) { defaultCfg := struct{}{} factories, err := MakeFactoryMap([]Factory{ NewFactory( - component.MustType("all"), + component.MustNewType("all"), func() component.Config { return &defaultCfg }, WithTraces(createTraces, component.StabilityLevelDevelopment), WithMetrics(createMetrics, component.StabilityLevelAlpha), @@ -183,7 +183,7 @@ func TestBuilderMissingConfig(t *testing.T) { require.NoError(t, err) bErr := NewBuilder(map[component.ID]component.Config{}, factories) - missingID := component.NewIDWithName(component.MustType("all"), "missing") + missingID := component.NewIDWithName(component.MustNewType("all"), "missing") te, err := bErr.CreateTraces(context.Background(), createSettings(missingID)) assert.EqualError(t, err, "exporter \"all/missing\" is not configured") @@ -199,14 +199,14 @@ func TestBuilderMissingConfig(t *testing.T) { } func TestBuilderFactory(t *testing.T) { - factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustType("foo"), nil)}...) + factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustNewType("foo"), nil)}...) require.NoError(t, err) - cfgs := map[component.ID]component.Config{component.NewID(component.MustType("foo")): struct{}{}} + cfgs := map[component.ID]component.Config{component.NewID(component.MustNewType("foo")): struct{}{}} b := NewBuilder(cfgs, factories) - assert.NotNil(t, b.Factory(component.NewID(component.MustType("foo")).Type())) - assert.Nil(t, b.Factory(component.NewID(component.MustType("bar")).Type())) + assert.NotNil(t, b.Factory(component.NewID(component.MustNewType("foo")).Type())) + assert.Nil(t, b.Factory(component.NewID(component.MustNewType("bar")).Type())) } var nopInstance = &nopExporter{ diff --git a/exporter/exporterhelper/common_test.go b/exporter/exporterhelper/common_test.go index 9f40472b7e7..5ed2c5a1dc2 100644 --- a/exporter/exporterhelper/common_test.go +++ b/exporter/exporterhelper/common_test.go @@ -22,7 +22,7 @@ import ( ) var ( - defaultType = component.MustType("test") + defaultType = component.MustNewType("test") defaultID = component.NewID(defaultType) defaultSettings = func() exporter.CreateSettings { set := exportertest.NewNopCreateSettings() diff --git a/exporter/exporterhelper/internal/persistent_queue_test.go b/exporter/exporterhelper/internal/persistent_queue_test.go index e10e70a4c04..b92e3c325b6 100644 --- a/exporter/exporterhelper/internal/persistent_queue_test.go +++ b/exporter/exporterhelper/internal/persistent_queue_test.go @@ -293,14 +293,14 @@ func TestToStorageClient(t *testing.T) { for _, tC := range testCases { t.Run(tC.desc, func(t *testing.T) { - storageID := component.NewIDWithName(component.MustType("file_storage"), strconv.Itoa(tC.storageIndex)) + storageID := component.NewIDWithName(component.MustNewType("file_storage"), strconv.Itoa(tC.storageIndex)) var extensions = map[component.ID]component.Component{} for i := 0; i < tC.numStorages; i++ { - extensions[component.NewIDWithName(component.MustType("file_storage"), strconv.Itoa(i))] = NewMockStorageExtension(tC.getClientError) + extensions[component.NewIDWithName(component.MustNewType("file_storage"), strconv.Itoa(i))] = NewMockStorageExtension(tC.getClientError) } host := &mockHost{ext: extensions} - ownerID := component.NewID(component.MustType("foo_exporter")) + ownerID := component.NewID(component.MustNewType("foo_exporter")) // execute client, err := toStorageClient(context.Background(), storageID, host, ownerID, component.DataTypeTraces) @@ -318,7 +318,7 @@ func TestToStorageClient(t *testing.T) { } func TestInvalidStorageExtensionType(t *testing.T) { - storageID := component.NewIDWithName(component.MustType("extension"), "extension") + storageID := component.NewIDWithName(component.MustNewType("extension"), "extension") // make a test extension factory := extensiontest.NewNopFactory() @@ -330,7 +330,7 @@ func TestInvalidStorageExtensionType(t *testing.T) { storageID: extension, } host := &mockHost{ext: extensions} - ownerID := component.NewID(component.MustType("foo_exporter")) + ownerID := component.NewID(component.MustNewType("foo_exporter")) // execute client, err := toStorageClient(context.Background(), storageID, host, ownerID, component.DataTypeTraces) diff --git a/exporter/exporterhelper/logs_test.go b/exporter/exporterhelper/logs_test.go index a867beda7a8..e4e9f2306d0 100644 --- a/exporter/exporterhelper/logs_test.go +++ b/exporter/exporterhelper/logs_test.go @@ -37,7 +37,7 @@ const ( ) var ( - fakeLogsExporterName = component.NewIDWithName(component.MustType("fake_logs_exporter"), "with_name") + fakeLogsExporterName = component.NewIDWithName(component.MustNewType("fake_logs_exporter"), "with_name") fakeLogsExporterConfig = struct{}{} ) @@ -157,12 +157,12 @@ func TestLogsRequestExporter_Default_ExportError(t *testing.T) { func TestLogsExporter_WithPersistentQueue(t *testing.T) { qCfg := NewDefaultQueueSettings() - storageID := component.NewIDWithName(component.MustType("file_storage"), "storage") + storageID := component.NewIDWithName(component.MustNewType("file_storage"), "storage") qCfg.StorageID = &storageID rCfg := configretry.NewDefaultBackOffConfig() ts := consumertest.LogsSink{} set := exportertest.NewNopCreateSettings() - set.ID = component.NewIDWithName(component.MustType("test_logs"), "with_persistent_queue") + set.ID = component.NewIDWithName(component.MustNewType("test_logs"), "with_persistent_queue") te, err := NewLogsExporter(context.Background(), set, &fakeLogsExporterConfig, ts.ConsumeLogs, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) diff --git a/exporter/exporterhelper/metrics_test.go b/exporter/exporterhelper/metrics_test.go index 84677313481..e4c2b8b8fc4 100644 --- a/exporter/exporterhelper/metrics_test.go +++ b/exporter/exporterhelper/metrics_test.go @@ -37,7 +37,7 @@ const ( ) var ( - fakeMetricsExporterName = component.NewIDWithName(component.MustType("fake_metrics_exporter"), "with_name") + fakeMetricsExporterName = component.NewIDWithName(component.MustNewType("fake_metrics_exporter"), "with_name") fakeMetricsExporterConfig = struct{}{} ) @@ -158,12 +158,12 @@ func TestMetricsRequestExporter_Default_ExportError(t *testing.T) { func TestMetricsExporter_WithPersistentQueue(t *testing.T) { qCfg := NewDefaultQueueSettings() - storageID := component.NewIDWithName(component.MustType("file_storage"), "storage") + storageID := component.NewIDWithName(component.MustNewType("file_storage"), "storage") qCfg.StorageID = &storageID rCfg := configretry.NewDefaultBackOffConfig() ms := consumertest.MetricsSink{} set := exportertest.NewNopCreateSettings() - set.ID = component.NewIDWithName(component.MustType("test_metrics"), "with_persistent_queue") + set.ID = component.NewIDWithName(component.MustNewType("test_metrics"), "with_persistent_queue") te, err := NewMetricsExporter(context.Background(), set, &fakeTracesExporterConfig, ms.ConsumeMetrics, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) diff --git a/exporter/exporterhelper/obsexporter_test.go b/exporter/exporterhelper/obsexporter_test.go index 350fccff426..f4c1be6df2a 100644 --- a/exporter/exporterhelper/obsexporter_test.go +++ b/exporter/exporterhelper/obsexporter_test.go @@ -20,7 +20,7 @@ import ( ) var ( - exporterID = component.NewID(component.MustType("fakeExporter")) + exporterID = component.NewID(component.MustNewType("fakeExporter")) errFake = errors.New("errFake") ) diff --git a/exporter/exporterhelper/obsreport_test.go b/exporter/exporterhelper/obsreport_test.go index 4a6aca7cca2..fdd28dd623b 100644 --- a/exporter/exporterhelper/obsreport_test.go +++ b/exporter/exporterhelper/obsreport_test.go @@ -15,7 +15,7 @@ import ( ) func TestExportEnqueueFailure(t *testing.T) { - exporterID := component.NewID(component.MustType("fakeExporter")) + exporterID := component.NewID(component.MustNewType("fakeExporter")) tt, err := componenttest.SetupTelemetry(exporterID) require.NoError(t, err) t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) diff --git a/exporter/exporterhelper/queue_sender_test.go b/exporter/exporterhelper/queue_sender_test.go index 537d54a281c..2bb3b9602b0 100644 --- a/exporter/exporterhelper/queue_sender_test.go +++ b/exporter/exporterhelper/queue_sender_test.go @@ -237,7 +237,7 @@ func TestQueuedRetryPersistenceEnabled(t *testing.T) { t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) qCfg := NewDefaultQueueSettings() - storageID := component.NewIDWithName(component.MustType("file_storage"), "storage") + storageID := component.NewIDWithName(component.MustNewType("file_storage"), "storage") qCfg.StorageID = &storageID // enable persistence rCfg := configretry.NewDefaultBackOffConfig() set := exporter.CreateSettings{ID: defaultID, TelemetrySettings: tt.TelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo()} @@ -261,7 +261,7 @@ func TestQueuedRetryPersistenceEnabledStorageError(t *testing.T) { t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) qCfg := NewDefaultQueueSettings() - storageID := component.NewIDWithName(component.MustType("file_storage"), "storage") + storageID := component.NewIDWithName(component.MustNewType("file_storage"), "storage") qCfg.StorageID = &storageID // enable persistence rCfg := configretry.NewDefaultBackOffConfig() set := exporter.CreateSettings{ID: defaultID, TelemetrySettings: tt.TelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo()} @@ -280,7 +280,7 @@ func TestQueuedRetryPersistenceEnabledStorageError(t *testing.T) { func TestQueuedRetryPersistentEnabled_NoDataLossOnShutdown(t *testing.T) { qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 1 - storageID := component.NewIDWithName(component.MustType("file_storage"), "storage") + storageID := component.NewIDWithName(component.MustNewType("file_storage"), "storage") qCfg.StorageID = &storageID // enable persistence to ensure data is re-queued on shutdown rCfg := configretry.NewDefaultBackOffConfig() diff --git a/exporter/exporterhelper/traces_test.go b/exporter/exporterhelper/traces_test.go index d1579f9150f..4faa868092d 100644 --- a/exporter/exporterhelper/traces_test.go +++ b/exporter/exporterhelper/traces_test.go @@ -37,7 +37,7 @@ const ( ) var ( - fakeTracesExporterName = component.NewIDWithName(component.MustType("fake_traces_exporter"), "with_name") + fakeTracesExporterName = component.NewIDWithName(component.MustNewType("fake_traces_exporter"), "with_name") fakeTracesExporterConfig = struct{}{} ) @@ -155,12 +155,12 @@ func TestTracesRequestExporter_Default_ExportError(t *testing.T) { func TestTracesExporter_WithPersistentQueue(t *testing.T) { qCfg := NewDefaultQueueSettings() - storageID := component.NewIDWithName(component.MustType("file_storage"), "storage") + storageID := component.NewIDWithName(component.MustNewType("file_storage"), "storage") qCfg.StorageID = &storageID rCfg := configretry.NewDefaultBackOffConfig() ts := consumertest.TracesSink{} set := exportertest.NewNopCreateSettings() - set.ID = component.NewIDWithName(component.MustType("test_traces"), "with_persistent_queue") + set.ID = component.NewIDWithName(component.MustNewType("test_traces"), "with_persistent_queue") te, err := NewTracesExporter(context.Background(), set, &fakeTracesExporterConfig, ts.ConsumeTraces, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) diff --git a/exporter/exportertest/contract_checker_test.go b/exporter/exportertest/contract_checker_test.go index 580ef9adb71..7b0a6d5abb3 100644 --- a/exporter/exportertest/contract_checker_test.go +++ b/exporter/exportertest/contract_checker_test.go @@ -78,7 +78,7 @@ func (mef *mockExporterFactory) createMockLogsExporter( func newMockExporterFactory(mr *mockReceiver) exporter.Factory { mef := &mockExporterFactory{mr: mr} return exporter.NewFactory( - component.MustType("pass_through_exporter"), + component.MustNewType("pass_through_exporter"), func() component.Config { return &nopConfig{} }, exporter.WithTraces(mef.createMockTracesExporter, component.StabilityLevelBeta), exporter.WithMetrics(mef.createMockMetricsExporter, component.StabilityLevelBeta), @@ -87,7 +87,7 @@ func newMockExporterFactory(mr *mockReceiver) exporter.Factory { } func newMockReceiverFactory(mr *mockReceiver) receiver.Factory { - return receiver.NewFactory(component.MustType("pass_through_receiver"), + return receiver.NewFactory(component.MustNewType("pass_through_receiver"), func() component.Config { return &nopConfig{} }, receiver.WithTraces(func(_ context.Context, _ receiver.CreateSettings, _ component.Config, c consumer.Traces) (receiver.Traces, error) { mr.Traces = c diff --git a/exporter/exportertest/nop_exporter.go b/exporter/exportertest/nop_exporter.go index 708b1a9a1a0..dc3bb83ef07 100644 --- a/exporter/exportertest/nop_exporter.go +++ b/exporter/exportertest/nop_exporter.go @@ -12,7 +12,7 @@ import ( "go.opentelemetry.io/collector/exporter" ) -var nopType = component.MustType("nop") +var nopType = component.MustNewType("nop") // NewNopCreateSettings returns a new nop settings for Create*Exporter functions. func NewNopCreateSettings() exporter.CreateSettings { diff --git a/exporter/exportertest/nop_exporter_test.go b/exporter/exportertest/nop_exporter_test.go index b86e8a42298..6ae95efc08d 100644 --- a/exporter/exportertest/nop_exporter_test.go +++ b/exporter/exportertest/nop_exporter_test.go @@ -20,7 +20,7 @@ import ( func TestNewNopFactory(t *testing.T) { factory := NewNopFactory() require.NotNil(t, factory) - assert.Equal(t, component.MustType("nop"), factory.Type()) + assert.Equal(t, component.MustNewType("nop"), factory.Type()) cfg := factory.CreateDefaultConfig() assert.Equal(t, &nopConfig{}, cfg) diff --git a/exporter/loggingexporter/factory.go b/exporter/loggingexporter/factory.go index 4abf50ef042..1f38b315db0 100644 --- a/exporter/loggingexporter/factory.go +++ b/exporter/loggingexporter/factory.go @@ -16,7 +16,7 @@ import ( ) // The value of "type" key in configuration. -var componentType = component.MustType("logging") +var componentType = component.MustNewType("logging") const ( defaultSamplingInitial = 2 diff --git a/exporter/loggingexporter/internal/metadata/generated_status.go b/exporter/loggingexporter/internal/metadata/generated_status.go index d510359663e..dc0bf4e123d 100644 --- a/exporter/loggingexporter/internal/metadata/generated_status.go +++ b/exporter/loggingexporter/internal/metadata/generated_status.go @@ -10,7 +10,7 @@ import ( ) var ( - Type = component.MustType("logging") + Type = component.MustNewType("logging") ) const ( diff --git a/exporter/otlpexporter/config_test.go b/exporter/otlpexporter/config_test.go index 214f43e1ffd..d236e41776c 100644 --- a/exporter/otlpexporter/config_test.go +++ b/exporter/otlpexporter/config_test.go @@ -74,7 +74,7 @@ func TestUnmarshalConfig(t *testing.T) { }, WriteBufferSize: 512 * 1024, BalancerName: "round_robin", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID(component.MustType("nop"))}, + Auth: &configauth.Authentication{AuthenticatorID: component.NewID(component.MustNewType("nop"))}, }, }, cfg) } diff --git a/exporter/otlpexporter/internal/metadata/generated_status.go b/exporter/otlpexporter/internal/metadata/generated_status.go index d5fff19b086..f4222df7521 100644 --- a/exporter/otlpexporter/internal/metadata/generated_status.go +++ b/exporter/otlpexporter/internal/metadata/generated_status.go @@ -10,7 +10,7 @@ import ( ) var ( - Type = component.MustType("otlp") + Type = component.MustNewType("otlp") ) const ( diff --git a/exporter/otlphttpexporter/internal/metadata/generated_status.go b/exporter/otlphttpexporter/internal/metadata/generated_status.go index 7f96dea72b5..8917eb822f7 100644 --- a/exporter/otlphttpexporter/internal/metadata/generated_status.go +++ b/exporter/otlphttpexporter/internal/metadata/generated_status.go @@ -10,7 +10,7 @@ import ( ) var ( - Type = component.MustType("otlphttp") + Type = component.MustNewType("otlphttp") ) const ( diff --git a/extension/ballastextension/internal/metadata/generated_status.go b/extension/ballastextension/internal/metadata/generated_status.go index 6949900abae..02205c5623e 100644 --- a/extension/ballastextension/internal/metadata/generated_status.go +++ b/extension/ballastextension/internal/metadata/generated_status.go @@ -10,7 +10,7 @@ import ( ) var ( - Type = component.MustType("memory_ballast") + Type = component.MustNewType("memory_ballast") ) const ( diff --git a/extension/extension_test.go b/extension/extension_test.go index 30a3579bd94..fc1c1857ae8 100644 --- a/extension/extension_test.go +++ b/extension/extension_test.go @@ -21,7 +21,7 @@ type nopExtension struct { } func TestNewFactory(t *testing.T) { - var testType = component.MustType("test") + var testType = component.MustNewType("test") defaultCfg := struct{}{} nopExtensionInstance := new(nopExtension) @@ -48,8 +48,8 @@ func TestMakeFactoryMap(t *testing.T) { out map[component.Type]Factory } - p1 := NewFactory(component.MustType("p1"), nil, nil, component.StabilityLevelAlpha) - p2 := NewFactory(component.MustType("p2"), nil, nil, component.StabilityLevelAlpha) + p1 := NewFactory(component.MustNewType("p1"), nil, nil, component.StabilityLevelAlpha) + p2 := NewFactory(component.MustNewType("p2"), nil, nil, component.StabilityLevelAlpha) testCases := []testCase{ { name: "different names", @@ -61,7 +61,7 @@ func TestMakeFactoryMap(t *testing.T) { }, { name: "same name", - in: []Factory{p1, p2, NewFactory(component.MustType("p1"), nil, nil, component.StabilityLevelAlpha)}, + in: []Factory{p1, p2, NewFactory(component.MustNewType("p1"), nil, nil, component.StabilityLevelAlpha)}, }, } for i := range testCases { @@ -79,10 +79,10 @@ func TestMakeFactoryMap(t *testing.T) { } func TestBuilder(t *testing.T) { - var testType = component.MustType("test") + var testType = component.MustNewType("test") defaultCfg := struct{}{} testID := component.NewID(testType) - unknownID := component.NewID(component.MustType("unknown")) + unknownID := component.NewID(component.MustNewType("unknown")) factories, err := MakeFactoryMap([]Factory{ NewFactory( @@ -117,14 +117,14 @@ func TestBuilder(t *testing.T) { } func TestBuilderFactory(t *testing.T) { - factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustType("foo"), nil, nil, component.StabilityLevelDevelopment)}...) + factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustNewType("foo"), nil, nil, component.StabilityLevelDevelopment)}...) require.NoError(t, err) - cfgs := map[component.ID]component.Config{component.NewID(component.MustType("foo")): struct{}{}} + cfgs := map[component.ID]component.Config{component.NewID(component.MustNewType("foo")): struct{}{}} b := NewBuilder(cfgs, factories) - assert.NotNil(t, b.Factory(component.NewID(component.MustType("foo")).Type())) - assert.Nil(t, b.Factory(component.NewID(component.MustType("bar")).Type())) + assert.NotNil(t, b.Factory(component.NewID(component.MustNewType("foo")).Type())) + assert.Nil(t, b.Factory(component.NewID(component.MustNewType("bar")).Type())) } func createSettings(id component.ID) CreateSettings { diff --git a/extension/extensiontest/nop_extension.go b/extension/extensiontest/nop_extension.go index a2408de1575..37a4ec91d27 100644 --- a/extension/extensiontest/nop_extension.go +++ b/extension/extensiontest/nop_extension.go @@ -11,7 +11,7 @@ import ( "go.opentelemetry.io/collector/extension" ) -var nopType = component.MustType("nop") +var nopType = component.MustNewType("nop") // NewNopCreateSettings returns a new nop settings for extension.Factory Create* functions. func NewNopCreateSettings() extension.CreateSettings { diff --git a/extension/extensiontest/nop_extension_test.go b/extension/extensiontest/nop_extension_test.go index 5a2ad65b207..7ebda6195ae 100644 --- a/extension/extensiontest/nop_extension_test.go +++ b/extension/extensiontest/nop_extension_test.go @@ -17,7 +17,7 @@ import ( func TestNewNopFactory(t *testing.T) { factory := NewNopFactory() require.NotNil(t, factory) - assert.Equal(t, component.MustType("nop"), factory.Type()) + assert.Equal(t, component.MustNewType("nop"), factory.Type()) cfg := factory.CreateDefaultConfig() assert.Equal(t, &nopConfig{}, cfg) diff --git a/extension/extensiontest/statuswatcher_extension.go b/extension/extensiontest/statuswatcher_extension.go index d4c18e5a196..eee0db94165 100644 --- a/extension/extensiontest/statuswatcher_extension.go +++ b/extension/extensiontest/statuswatcher_extension.go @@ -24,7 +24,7 @@ func NewStatusWatcherExtensionFactory( onStatusChanged func(source *component.InstanceID, event *component.StatusEvent), ) extension.Factory { return extension.NewFactory( - component.MustType("statuswatcher"), + component.MustNewType("statuswatcher"), func() component.Config { return &struct{}{} }, diff --git a/extension/extensiontest/statuswatcher_extension_test.go b/extension/extensiontest/statuswatcher_extension_test.go index 4fc00e1f9a0..14f9859e354 100644 --- a/extension/extensiontest/statuswatcher_extension_test.go +++ b/extension/extensiontest/statuswatcher_extension_test.go @@ -23,7 +23,7 @@ func TestStatusWatcherExtension(t *testing.T) { }, ) require.NotNil(t, factory) - assert.Equal(t, component.MustType("statuswatcher"), factory.Type()) + assert.Equal(t, component.MustNewType("statuswatcher"), factory.Type()) cfg := factory.CreateDefaultConfig() assert.Equal(t, &struct{}{}, cfg) diff --git a/extension/memorylimiterextension/internal/metadata/generated_status.go b/extension/memorylimiterextension/internal/metadata/generated_status.go index 14c76c773b4..c5131e1f7a7 100644 --- a/extension/memorylimiterextension/internal/metadata/generated_status.go +++ b/extension/memorylimiterextension/internal/metadata/generated_status.go @@ -10,7 +10,7 @@ import ( ) var ( - Type = component.MustType("memory_limiter") + Type = component.MustNewType("memory_limiter") ) const ( diff --git a/extension/zpagesextension/internal/metadata/generated_status.go b/extension/zpagesextension/internal/metadata/generated_status.go index eea2d1bfde1..5460b8c79f9 100644 --- a/extension/zpagesextension/internal/metadata/generated_status.go +++ b/extension/zpagesextension/internal/metadata/generated_status.go @@ -10,7 +10,7 @@ import ( ) var ( - Type = component.MustType("zpages") + Type = component.MustNewType("zpages") ) const ( diff --git a/internal/memorylimiter/memorylimiter_test.go b/internal/memorylimiter/memorylimiter_test.go index 0be8265e41d..bab557f0d74 100644 --- a/internal/memorylimiter/memorylimiter_test.go +++ b/internal/memorylimiter/memorylimiter_test.go @@ -173,7 +173,7 @@ type host struct { func (h *host) GetExtensions() map[component.ID]component.Component { ret := make(map[component.ID]component.Component) - ret[component.NewID(component.MustType("ballast"))] = &ballastExtension{ballastSize: h.ballastSize} + ret[component.NewID(component.MustNewType("ballast"))] = &ballastExtension{ballastSize: h.ballastSize} return ret } diff --git a/internal/sharedcomponent/sharedcomponent_test.go b/internal/sharedcomponent/sharedcomponent_test.go index 2f448ef7526..6519e456089 100644 --- a/internal/sharedcomponent/sharedcomponent_test.go +++ b/internal/sharedcomponent/sharedcomponent_test.go @@ -15,7 +15,7 @@ import ( "go.opentelemetry.io/collector/component/componenttest" ) -var id = component.NewID(component.MustType("test")) +var id = component.NewID(component.MustNewType("test")) type baseComponent struct { component.StartFunc diff --git a/otelcol/command_components_test.go b/otelcol/command_components_test.go index 1326098da8c..141fb586010 100644 --- a/otelcol/command_components_test.go +++ b/otelcol/command_components_test.go @@ -16,7 +16,7 @@ import ( "go.opentelemetry.io/collector/component" ) -var nopType = component.MustType("nop") +var nopType = component.MustNewType("nop") func TestNewBuildSubCommand(t *testing.T) { cfgProvider, err := NewConfigProvider(newDefaultConfigProviderSettings([]string{filepath.Join("testdata", "otelcol-nop.yaml")})) diff --git a/otelcol/config_test.go b/otelcol/config_test.go index 408050229b4..db0ab6e2058 100644 --- a/otelcol/config_test.go +++ b/otelcol/config_test.go @@ -76,7 +76,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-extension-reference", cfgFn: func() *Config { cfg := generateConfig() - cfg.Service.Extensions = append(cfg.Service.Extensions, component.NewIDWithName(component.MustType("nop"), "2")) + cfg.Service.Extensions = append(cfg.Service.Extensions, component.NewIDWithName(component.MustNewType("nop"), "2")) return cfg }, expected: errors.New(`service::extensions: references extension "nop/2" which is not configured`), @@ -85,8 +85,8 @@ func TestConfigValidate(t *testing.T) { name: "invalid-receiver-reference", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.NewID(component.MustType("traces"))] - pipe.Receivers = append(pipe.Receivers, component.NewIDWithName(component.MustType("nop"), "2")) + pipe := cfg.Service.Pipelines[component.NewID(component.MustNewType("traces"))] + pipe.Receivers = append(pipe.Receivers, component.NewIDWithName(component.MustNewType("nop"), "2")) return cfg }, expected: errors.New(`service::pipelines::traces: references receiver "nop/2" which is not configured`), @@ -95,8 +95,8 @@ func TestConfigValidate(t *testing.T) { name: "invalid-processor-reference", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.NewID(component.MustType("traces"))] - pipe.Processors = append(pipe.Processors, component.NewIDWithName(component.MustType("nop"), "2")) + pipe := cfg.Service.Pipelines[component.NewID(component.MustNewType("traces"))] + pipe.Processors = append(pipe.Processors, component.NewIDWithName(component.MustNewType("nop"), "2")) return cfg }, expected: errors.New(`service::pipelines::traces: references processor "nop/2" which is not configured`), @@ -105,8 +105,8 @@ func TestConfigValidate(t *testing.T) { name: "invalid-exporter-reference", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.NewID(component.MustType("traces"))] - pipe.Exporters = append(pipe.Exporters, component.NewIDWithName(component.MustType("nop"), "2")) + pipe := cfg.Service.Pipelines[component.NewID(component.MustNewType("traces"))] + pipe.Exporters = append(pipe.Exporters, component.NewIDWithName(component.MustNewType("nop"), "2")) return cfg }, expected: errors.New(`service::pipelines::traces: references exporter "nop/2" which is not configured`), @@ -115,7 +115,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-receiver-config", cfgFn: func() *Config { cfg := generateConfig() - cfg.Receivers[component.NewID(component.MustType("nop"))] = &errConfig{ + cfg.Receivers[component.NewID(component.MustNewType("nop"))] = &errConfig{ validateErr: errInvalidRecvConfig, } return cfg @@ -126,7 +126,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-exporter-config", cfgFn: func() *Config { cfg := generateConfig() - cfg.Exporters[component.NewID(component.MustType("nop"))] = &errConfig{ + cfg.Exporters[component.NewID(component.MustNewType("nop"))] = &errConfig{ validateErr: errInvalidExpConfig, } return cfg @@ -137,7 +137,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-processor-config", cfgFn: func() *Config { cfg := generateConfig() - cfg.Processors[component.NewID(component.MustType("nop"))] = &errConfig{ + cfg.Processors[component.NewID(component.MustNewType("nop"))] = &errConfig{ validateErr: errInvalidProcConfig, } return cfg @@ -148,7 +148,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-extension-config", cfgFn: func() *Config { cfg := generateConfig() - cfg.Extensions[component.NewID(component.MustType("nop"))] = &errConfig{ + cfg.Extensions[component.NewID(component.MustNewType("nop"))] = &errConfig{ validateErr: errInvalidExtConfig, } return cfg @@ -159,7 +159,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-connector-config", cfgFn: func() *Config { cfg := generateConfig() - cfg.Connectors[component.NewIDWithName(component.MustType("nop"), "conn")] = &errConfig{ + cfg.Connectors[component.NewIDWithName(component.MustNewType("nop"), "conn")] = &errConfig{ validateErr: errInvalidConnConfig, } return cfg @@ -170,11 +170,11 @@ func TestConfigValidate(t *testing.T) { name: "ambiguous-connector-name-as-receiver", cfgFn: func() *Config { cfg := generateConfig() - cfg.Receivers[component.NewID(component.MustType("nop2"))] = &errConfig{} - cfg.Connectors[component.NewID(component.MustType("nop2"))] = &errConfig{} - pipe := cfg.Service.Pipelines[component.NewID(component.MustType("traces"))] - pipe.Receivers = append(pipe.Receivers, component.NewIDWithName(component.MustType("nop"), "2")) - pipe.Exporters = append(pipe.Exporters, component.NewIDWithName(component.MustType("nop"), "2")) + cfg.Receivers[component.NewID(component.MustNewType("nop2"))] = &errConfig{} + cfg.Connectors[component.NewID(component.MustNewType("nop2"))] = &errConfig{} + pipe := cfg.Service.Pipelines[component.NewID(component.MustNewType("traces"))] + pipe.Receivers = append(pipe.Receivers, component.NewIDWithName(component.MustNewType("nop"), "2")) + pipe.Exporters = append(pipe.Exporters, component.NewIDWithName(component.MustNewType("nop"), "2")) return cfg }, expected: errors.New(`connectors::nop2: ambiguous ID: Found both "nop2" receiver and "nop2" connector. Change one of the components' IDs to eliminate ambiguity (e.g. rename "nop2" connector to "nop2/connector")`), @@ -183,11 +183,11 @@ func TestConfigValidate(t *testing.T) { name: "ambiguous-connector-name-as-exporter", cfgFn: func() *Config { cfg := generateConfig() - cfg.Exporters[component.NewID(component.MustType("nop2"))] = &errConfig{} - cfg.Connectors[component.NewID(component.MustType("nop2"))] = &errConfig{} - pipe := cfg.Service.Pipelines[component.NewID(component.MustType("traces"))] - pipe.Receivers = append(pipe.Receivers, component.NewIDWithName(component.MustType("nop"), "2")) - pipe.Exporters = append(pipe.Exporters, component.NewIDWithName(component.MustType("nop"), "2")) + cfg.Exporters[component.NewID(component.MustNewType("nop2"))] = &errConfig{} + cfg.Connectors[component.NewID(component.MustNewType("nop2"))] = &errConfig{} + pipe := cfg.Service.Pipelines[component.NewID(component.MustNewType("traces"))] + pipe.Receivers = append(pipe.Receivers, component.NewIDWithName(component.MustNewType("nop"), "2")) + pipe.Exporters = append(pipe.Exporters, component.NewIDWithName(component.MustNewType("nop"), "2")) return cfg }, expected: errors.New(`connectors::nop2: ambiguous ID: Found both "nop2" exporter and "nop2" connector. Change one of the components' IDs to eliminate ambiguity (e.g. rename "nop2" connector to "nop2/connector")`), @@ -196,8 +196,8 @@ func TestConfigValidate(t *testing.T) { name: "invalid-connector-reference-as-receiver", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.NewID(component.MustType("traces"))] - pipe.Receivers = append(pipe.Receivers, component.NewIDWithName(component.MustType("nop"), "conn2")) + pipe := cfg.Service.Pipelines[component.NewID(component.MustNewType("traces"))] + pipe.Receivers = append(pipe.Receivers, component.NewIDWithName(component.MustNewType("nop"), "conn2")) return cfg }, expected: errors.New(`service::pipelines::traces: references receiver "nop/conn2" which is not configured`), @@ -206,8 +206,8 @@ func TestConfigValidate(t *testing.T) { name: "invalid-connector-reference-as-receiver", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.NewID(component.MustType("traces"))] - pipe.Exporters = append(pipe.Exporters, component.NewIDWithName(component.MustType("nop"), "conn2")) + pipe := cfg.Service.Pipelines[component.NewID(component.MustNewType("traces"))] + pipe.Exporters = append(pipe.Exporters, component.NewIDWithName(component.MustNewType("nop"), "conn2")) return cfg }, expected: errors.New(`service::pipelines::traces: references exporter "nop/conn2" which is not configured`), @@ -234,19 +234,19 @@ func TestConfigValidate(t *testing.T) { func generateConfig() *Config { return &Config{ Receivers: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): &errConfig{}, + component.NewID(component.MustNewType("nop")): &errConfig{}, }, Exporters: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): &errConfig{}, + component.NewID(component.MustNewType("nop")): &errConfig{}, }, Processors: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): &errConfig{}, + component.NewID(component.MustNewType("nop")): &errConfig{}, }, Connectors: map[component.ID]component.Config{ - component.NewIDWithName(component.MustType("nop"), "conn"): &errConfig{}, + component.NewIDWithName(component.MustNewType("nop"), "conn"): &errConfig{}, }, Extensions: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): &errConfig{}, + component.NewID(component.MustNewType("nop")): &errConfig{}, }, Service: service.Config{ Telemetry: telemetry.Config{ @@ -265,12 +265,12 @@ func generateConfig() *Config { Address: ":8080", }, }, - Extensions: []component.ID{component.NewID(component.MustType("nop"))}, + Extensions: []component.ID{component.NewID(component.MustNewType("nop"))}, Pipelines: pipelines.Config{ - component.NewID(component.MustType("traces")): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewID(component.MustNewType("traces")): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, }, diff --git a/otelcol/internal/configunmarshaler/configs_test.go b/otelcol/internal/configunmarshaler/configs_test.go index ee269fc89b4..f6cd2865281 100644 --- a/otelcol/internal/configunmarshaler/configs_test.go +++ b/otelcol/internal/configunmarshaler/configs_test.go @@ -18,7 +18,7 @@ import ( "go.opentelemetry.io/collector/receiver/receivertest" ) -var nopType = component.MustType("nop") +var nopType = component.MustNewType("nop") var testKinds = []struct { kind string diff --git a/otelcol/otelcoltest/config_test.go b/otelcol/otelcoltest/config_test.go index d6396ff782b..b6caff4321a 100644 --- a/otelcol/otelcoltest/config_test.go +++ b/otelcol/otelcoltest/config_test.go @@ -23,39 +23,39 @@ func TestLoadConfig(t *testing.T) { // Verify extensions. require.Len(t, cfg.Extensions, 2) - assert.Contains(t, cfg.Extensions, component.NewID(component.MustType("nop"))) - assert.Contains(t, cfg.Extensions, component.NewIDWithName(component.MustType("nop"), "myextension")) + assert.Contains(t, cfg.Extensions, component.NewID(component.MustNewType("nop"))) + assert.Contains(t, cfg.Extensions, component.NewIDWithName(component.MustNewType("nop"), "myextension")) // Verify receivers require.Len(t, cfg.Receivers, 2) - assert.Contains(t, cfg.Receivers, component.NewID(component.MustType("nop"))) - assert.Contains(t, cfg.Receivers, component.NewIDWithName(component.MustType("nop"), "myreceiver")) + assert.Contains(t, cfg.Receivers, component.NewID(component.MustNewType("nop"))) + assert.Contains(t, cfg.Receivers, component.NewIDWithName(component.MustNewType("nop"), "myreceiver")) // Verify exporters assert.Len(t, cfg.Exporters, 2) - assert.Contains(t, cfg.Exporters, component.NewID(component.MustType("nop"))) - assert.Contains(t, cfg.Exporters, component.NewIDWithName(component.MustType("nop"), "myexporter")) + assert.Contains(t, cfg.Exporters, component.NewID(component.MustNewType("nop"))) + assert.Contains(t, cfg.Exporters, component.NewIDWithName(component.MustNewType("nop"), "myexporter")) // Verify procs assert.Len(t, cfg.Processors, 2) - assert.Contains(t, cfg.Processors, component.NewID(component.MustType("nop"))) - assert.Contains(t, cfg.Processors, component.NewIDWithName(component.MustType("nop"), "myprocessor")) + assert.Contains(t, cfg.Processors, component.NewID(component.MustNewType("nop"))) + assert.Contains(t, cfg.Processors, component.NewIDWithName(component.MustNewType("nop"), "myprocessor")) // Verify connectors assert.Len(t, cfg.Connectors, 1) - assert.Contains(t, cfg.Connectors, component.NewIDWithName(component.MustType("nop"), "myconnector")) + assert.Contains(t, cfg.Connectors, component.NewIDWithName(component.MustNewType("nop"), "myconnector")) // Verify service. require.Len(t, cfg.Service.Extensions, 1) - assert.Contains(t, cfg.Service.Extensions, component.NewID(component.MustType("nop"))) + assert.Contains(t, cfg.Service.Extensions, component.NewID(component.MustNewType("nop"))) require.Len(t, cfg.Service.Pipelines, 1) assert.Equal(t, &pipelines.PipelineConfig{ - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, - cfg.Service.Pipelines[component.NewID(component.MustType("traces"))], + cfg.Service.Pipelines[component.NewID(component.MustNewType("traces"))], "Did not load pipeline config correctly") } diff --git a/otelcol/otelcoltest/nop_factories_test.go b/otelcol/otelcoltest/nop_factories_test.go index a0f018cfe44..1f77ecdd68e 100644 --- a/otelcol/otelcoltest/nop_factories_test.go +++ b/otelcol/otelcoltest/nop_factories_test.go @@ -11,7 +11,7 @@ import ( "go.opentelemetry.io/collector/component" ) -var nopType = component.MustType("nop") +var nopType = component.MustNewType("nop") func TestNopFactories(t *testing.T) { nopFactories, err := NopFactories() diff --git a/processor/batchprocessor/internal/metadata/generated_status.go b/processor/batchprocessor/internal/metadata/generated_status.go index a3bf4bcc8e0..2ccbff8e2b3 100644 --- a/processor/batchprocessor/internal/metadata/generated_status.go +++ b/processor/batchprocessor/internal/metadata/generated_status.go @@ -10,7 +10,7 @@ import ( ) var ( - Type = component.MustType("batch") + Type = component.MustNewType("batch") ) const ( diff --git a/processor/batchprocessor/metrics_test.go b/processor/batchprocessor/metrics_test.go index ebf60bb6eec..14bb7e277df 100644 --- a/processor/batchprocessor/metrics_test.go +++ b/processor/batchprocessor/metrics_test.go @@ -97,7 +97,7 @@ func setupTelemetry(t *testing.T) testTelemetry { func (tt *testTelemetry) NewProcessorCreateSettings() processor.CreateSettings { settings := processortest.NewNopCreateSettings() settings.MeterProvider = tt.meterProvider - settings.ID = component.NewID(component.MustType("batch")) + settings.ID = component.NewID(component.MustNewType("batch")) return settings } diff --git a/processor/memorylimiterprocessor/internal/metadata/generated_status.go b/processor/memorylimiterprocessor/internal/metadata/generated_status.go index 75e6b866094..5fd2a9e9bc0 100644 --- a/processor/memorylimiterprocessor/internal/metadata/generated_status.go +++ b/processor/memorylimiterprocessor/internal/metadata/generated_status.go @@ -10,7 +10,7 @@ import ( ) var ( - Type = component.MustType("memory_limiter") + Type = component.MustNewType("memory_limiter") ) const ( diff --git a/processor/memorylimiterprocessor/memorylimiter_test.go b/processor/memorylimiterprocessor/memorylimiter_test.go index bf372943a25..f98554830ac 100644 --- a/processor/memorylimiterprocessor/memorylimiter_test.go +++ b/processor/memorylimiterprocessor/memorylimiter_test.go @@ -467,7 +467,7 @@ type host struct { func (h *host) GetExtensions() map[component.ID]component.Component { ret := make(map[component.ID]component.Component) - ret[component.NewID(component.MustType("ballast"))] = &ballastExtension{ballastSize: h.ballastSize} + ret[component.NewID(component.MustNewType("ballast"))] = &ballastExtension{ballastSize: h.ballastSize} return ret } diff --git a/processor/processor_test.go b/processor/processor_test.go index 4095e9d7001..dc3377b0a39 100644 --- a/processor/processor_test.go +++ b/processor/processor_test.go @@ -17,7 +17,7 @@ import ( ) func TestNewFactory(t *testing.T) { - var testType = component.MustType("test") + var testType = component.MustNewType("test") defaultCfg := struct{}{} factory := NewFactory( testType, @@ -33,7 +33,7 @@ func TestNewFactory(t *testing.T) { } func TestNewFactoryWithOptions(t *testing.T) { - var testType = component.MustType("test") + var testType = component.MustNewType("test") defaultCfg := struct{}{} factory := NewFactory( testType, @@ -64,8 +64,8 @@ func TestMakeFactoryMap(t *testing.T) { out map[component.Type]Factory } - p1 := NewFactory(component.MustType("p1"), nil) - p2 := NewFactory(component.MustType("p2"), nil) + p1 := NewFactory(component.MustNewType("p1"), nil) + p2 := NewFactory(component.MustNewType("p2"), nil) testCases := []testCase{ { name: "different names", @@ -77,7 +77,7 @@ func TestMakeFactoryMap(t *testing.T) { }, { name: "same name", - in: []Factory{p1, p2, NewFactory(component.MustType("p1"), nil)}, + in: []Factory{p1, p2, NewFactory(component.MustNewType("p1"), nil)}, }, } @@ -98,9 +98,9 @@ func TestMakeFactoryMap(t *testing.T) { func TestBuilder(t *testing.T) { defaultCfg := struct{}{} factories, err := MakeFactoryMap([]Factory{ - NewFactory(component.MustType("err"), nil), + NewFactory(component.MustNewType("err"), nil), NewFactory( - component.MustType("all"), + component.MustNewType("all"), func() component.Config { return &defaultCfg }, WithTraces(createTraces, component.StabilityLevelDevelopment), WithMetrics(createMetrics, component.StabilityLevelAlpha), @@ -116,21 +116,21 @@ func TestBuilder(t *testing.T) { }{ { name: "unknown", - id: component.NewID(component.MustType("unknown")), + id: component.NewID(component.MustNewType("unknown")), err: "processor factory not available for: \"unknown\"", }, { name: "err", - id: component.NewID(component.MustType("err")), + id: component.NewID(component.MustNewType("err")), err: "telemetry type is not supported", }, { name: "all", - id: component.NewID(component.MustType("all")), + id: component.NewID(component.MustNewType("all")), }, { name: "all/named", - id: component.NewIDWithName(component.MustType("all"), "named"), + id: component.NewIDWithName(component.MustNewType("all"), "named"), }, } @@ -173,7 +173,7 @@ func TestBuilderMissingConfig(t *testing.T) { defaultCfg := struct{}{} factories, err := MakeFactoryMap([]Factory{ NewFactory( - component.MustType("all"), + component.MustNewType("all"), func() component.Config { return &defaultCfg }, WithTraces(createTraces, component.StabilityLevelDevelopment), WithMetrics(createMetrics, component.StabilityLevelAlpha), @@ -184,7 +184,7 @@ func TestBuilderMissingConfig(t *testing.T) { require.NoError(t, err) bErr := NewBuilder(map[component.ID]component.Config{}, factories) - missingID := component.NewIDWithName(component.MustType("all"), "missing") + missingID := component.NewIDWithName(component.MustNewType("all"), "missing") te, err := bErr.CreateTraces(context.Background(), createSettings(missingID), nil) assert.EqualError(t, err, "processor \"all/missing\" is not configured") @@ -200,14 +200,14 @@ func TestBuilderMissingConfig(t *testing.T) { } func TestBuilderFactory(t *testing.T) { - factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustType("foo"), nil)}...) + factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustNewType("foo"), nil)}...) require.NoError(t, err) - cfgs := map[component.ID]component.Config{component.NewID(component.MustType("foo")): struct{}{}} + cfgs := map[component.ID]component.Config{component.NewID(component.MustNewType("foo")): struct{}{}} b := NewBuilder(cfgs, factories) - assert.NotNil(t, b.Factory(component.NewID(component.MustType("foo")).Type())) - assert.Nil(t, b.Factory(component.NewID(component.MustType("bar")).Type())) + assert.NotNil(t, b.Factory(component.NewID(component.MustNewType("foo")).Type())) + assert.Nil(t, b.Factory(component.NewID(component.MustNewType("bar")).Type())) } var nopInstance = &nopProcessor{ diff --git a/processor/processorhelper/obsreport_test.go b/processor/processorhelper/obsreport_test.go index 23c803c5caf..249af85d86c 100644 --- a/processor/processorhelper/obsreport_test.go +++ b/processor/processorhelper/obsreport_test.go @@ -16,7 +16,7 @@ import ( ) var ( - processorID = component.NewID(component.MustType("fakeProcessor")) + processorID = component.NewID(component.MustNewType("fakeProcessor")) ) func TestProcessorTraceData(t *testing.T) { diff --git a/processor/processortest/nop_processor.go b/processor/processortest/nop_processor.go index 9a0ab35463f..52d57c33373 100644 --- a/processor/processortest/nop_processor.go +++ b/processor/processortest/nop_processor.go @@ -13,7 +13,7 @@ import ( "go.opentelemetry.io/collector/processor" ) -var nopType = component.MustType("nop") +var nopType = component.MustNewType("nop") // NewNopCreateSettings returns a new nop settings for Create* functions. func NewNopCreateSettings() processor.CreateSettings { diff --git a/processor/processortest/nop_processor_test.go b/processor/processortest/nop_processor_test.go index 8f8a4365f67..77e9131ed62 100644 --- a/processor/processortest/nop_processor_test.go +++ b/processor/processortest/nop_processor_test.go @@ -22,7 +22,7 @@ import ( func TestNewNopFactory(t *testing.T) { factory := NewNopFactory() require.NotNil(t, factory) - assert.Equal(t, component.MustType("nop"), factory.Type()) + assert.Equal(t, component.MustNewType("nop"), factory.Type()) cfg := factory.CreateDefaultConfig() assert.Equal(t, &nopConfig{}, cfg) diff --git a/processor/processortest/unhealthy_processor.go b/processor/processortest/unhealthy_processor.go index c0e3d7b9c16..99269e3bae0 100644 --- a/processor/processortest/unhealthy_processor.go +++ b/processor/processortest/unhealthy_processor.go @@ -24,7 +24,7 @@ func NewUnhealthyProcessorCreateSettings() processor.CreateSettings { // NewUnhealthyProcessorFactory returns a component.ProcessorFactory that constructs nop processors. func NewUnhealthyProcessorFactory() processor.Factory { return processor.NewFactory( - component.MustType("unhealthy"), + component.MustNewType("unhealthy"), func() component.Config { return &struct{}{} }, diff --git a/processor/processortest/unhealthy_processor_test.go b/processor/processortest/unhealthy_processor_test.go index bdac70236f5..f00c4236a19 100644 --- a/processor/processortest/unhealthy_processor_test.go +++ b/processor/processortest/unhealthy_processor_test.go @@ -22,7 +22,7 @@ import ( func TestNewUnhealthyProcessorFactory(t *testing.T) { factory := NewUnhealthyProcessorFactory() require.NotNil(t, factory) - assert.Equal(t, component.MustType("unhealthy"), factory.Type()) + assert.Equal(t, component.MustNewType("unhealthy"), factory.Type()) cfg := factory.CreateDefaultConfig() assert.Equal(t, &struct{}{}, cfg) diff --git a/receiver/otlpreceiver/internal/logs/otlp_test.go b/receiver/otlpreceiver/internal/logs/otlp_test.go index 3541095b0da..41f00caea09 100644 --- a/receiver/otlpreceiver/internal/logs/otlp_test.go +++ b/receiver/otlpreceiver/internal/logs/otlp_test.go @@ -92,7 +92,7 @@ func otlpReceiverOnGRPCServer(t *testing.T, lc consumer.Logs) net.Addr { }) set := receivertest.NewNopCreateSettings() - set.ID = component.NewIDWithName(component.MustType("otlp"), "log") + set.ID = component.NewIDWithName(component.MustNewType("otlp"), "log") obsreport, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{ ReceiverID: set.ID, Transport: "grpc", diff --git a/receiver/otlpreceiver/internal/metadata/generated_status.go b/receiver/otlpreceiver/internal/metadata/generated_status.go index d67e10166a4..8a7bc0b7be0 100644 --- a/receiver/otlpreceiver/internal/metadata/generated_status.go +++ b/receiver/otlpreceiver/internal/metadata/generated_status.go @@ -10,7 +10,7 @@ import ( ) var ( - Type = component.MustType("otlp") + Type = component.MustNewType("otlp") ) const ( diff --git a/receiver/otlpreceiver/internal/metrics/otlp_test.go b/receiver/otlpreceiver/internal/metrics/otlp_test.go index f655de45a48..4f72f0fa0d7 100644 --- a/receiver/otlpreceiver/internal/metrics/otlp_test.go +++ b/receiver/otlpreceiver/internal/metrics/otlp_test.go @@ -93,7 +93,7 @@ func otlpReceiverOnGRPCServer(t *testing.T, mc consumer.Metrics) net.Addr { }) set := receivertest.NewNopCreateSettings() - set.ID = component.NewIDWithName(component.MustType("otlp"), "metrics") + set.ID = component.NewIDWithName(component.MustNewType("otlp"), "metrics") obsreport, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{ ReceiverID: set.ID, Transport: "grpc", diff --git a/receiver/otlpreceiver/internal/trace/otlp_test.go b/receiver/otlpreceiver/internal/trace/otlp_test.go index 84b3c018d75..dbfb831c866 100644 --- a/receiver/otlpreceiver/internal/trace/otlp_test.go +++ b/receiver/otlpreceiver/internal/trace/otlp_test.go @@ -89,7 +89,7 @@ func otlpReceiverOnGRPCServer(t *testing.T, tc consumer.Traces) net.Addr { }) set := receivertest.NewNopCreateSettings() - set.ID = component.NewIDWithName(component.MustType("otlp"), "trace") + set.ID = component.NewIDWithName(component.MustNewType("otlp"), "trace") obsreport, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{ ReceiverID: set.ID, Transport: "grpc", diff --git a/receiver/otlpreceiver/otlp_test.go b/receiver/otlpreceiver/otlp_test.go index 37287a78e54..0e8916db695 100644 --- a/receiver/otlpreceiver/otlp_test.go +++ b/receiver/otlpreceiver/otlp_test.go @@ -48,7 +48,7 @@ import ( const otlpReceiverName = "receiver_test" -var otlpReceiverID = component.NewIDWithName(component.MustType("otlp"), otlpReceiverName) +var otlpReceiverID = component.NewIDWithName(component.MustNewType("otlp"), otlpReceiverName) func TestJsonHttp(t *testing.T) { tests := []struct { diff --git a/receiver/receiver_test.go b/receiver/receiver_test.go index 228611e536d..a74f9307331 100644 --- a/receiver/receiver_test.go +++ b/receiver/receiver_test.go @@ -17,7 +17,7 @@ import ( ) func TestNewFactory(t *testing.T) { - var testType = component.MustType("test") + var testType = component.MustNewType("test") defaultCfg := struct{}{} factory := NewFactory( testType, @@ -33,7 +33,7 @@ func TestNewFactory(t *testing.T) { } func TestNewFactoryWithOptions(t *testing.T) { - var testType = component.MustType("test") + var testType = component.MustNewType("test") defaultCfg := struct{}{} factory := NewFactory( testType, @@ -64,8 +64,8 @@ func TestMakeFactoryMap(t *testing.T) { out map[component.Type]Factory } - p1 := NewFactory(component.MustType("p1"), nil) - p2 := NewFactory(component.MustType("p2"), nil) + p1 := NewFactory(component.MustNewType("p1"), nil) + p2 := NewFactory(component.MustNewType("p2"), nil) testCases := []testCase{ { name: "different names", @@ -77,7 +77,7 @@ func TestMakeFactoryMap(t *testing.T) { }, { name: "same name", - in: []Factory{p1, p2, NewFactory(component.MustType("p1"), nil)}, + in: []Factory{p1, p2, NewFactory(component.MustNewType("p1"), nil)}, }, } @@ -98,9 +98,9 @@ func TestMakeFactoryMap(t *testing.T) { func TestBuilder(t *testing.T) { defaultCfg := struct{}{} factories, err := MakeFactoryMap([]Factory{ - NewFactory(component.MustType("err"), nil), + NewFactory(component.MustNewType("err"), nil), NewFactory( - component.MustType("all"), + component.MustNewType("all"), func() component.Config { return &defaultCfg }, WithTraces(createTraces, component.StabilityLevelDevelopment), WithMetrics(createMetrics, component.StabilityLevelAlpha), @@ -116,21 +116,21 @@ func TestBuilder(t *testing.T) { }{ { name: "unknown", - id: component.NewID(component.MustType("unknown")), + id: component.NewID(component.MustNewType("unknown")), err: "receiver factory not available for: \"unknown\"", }, { name: "err", - id: component.NewID(component.MustType("err")), + id: component.NewID(component.MustNewType("err")), err: "telemetry type is not supported", }, { name: "all", - id: component.NewID(component.MustType("all")), + id: component.NewID(component.MustNewType("all")), }, { name: "all/named", - id: component.NewIDWithName(component.MustType("all"), "named"), + id: component.NewIDWithName(component.MustNewType("all"), "named"), }, } @@ -173,7 +173,7 @@ func TestBuilderMissingConfig(t *testing.T) { defaultCfg := struct{}{} factories, err := MakeFactoryMap([]Factory{ NewFactory( - component.MustType("all"), + component.MustNewType("all"), func() component.Config { return &defaultCfg }, WithTraces(createTraces, component.StabilityLevelDevelopment), WithMetrics(createMetrics, component.StabilityLevelAlpha), @@ -184,7 +184,7 @@ func TestBuilderMissingConfig(t *testing.T) { require.NoError(t, err) bErr := NewBuilder(map[component.ID]component.Config{}, factories) - missingID := component.NewIDWithName(component.MustType("all"), "missing") + missingID := component.NewIDWithName(component.MustNewType("all"), "missing") te, err := bErr.CreateTraces(context.Background(), createSettings(missingID), nil) assert.EqualError(t, err, "receiver \"all/missing\" is not configured") @@ -200,14 +200,14 @@ func TestBuilderMissingConfig(t *testing.T) { } func TestBuilderFactory(t *testing.T) { - factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustType("foo"), nil)}...) + factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustNewType("foo"), nil)}...) require.NoError(t, err) - cfgs := map[component.ID]component.Config{component.NewID(component.MustType("foo")): struct{}{}} + cfgs := map[component.ID]component.Config{component.NewID(component.MustNewType("foo")): struct{}{}} b := NewBuilder(cfgs, factories) - assert.NotNil(t, b.Factory(component.NewID(component.MustType("foo")).Type())) - assert.Nil(t, b.Factory(component.NewID(component.MustType("bar")).Type())) + assert.NotNil(t, b.Factory(component.NewID(component.MustNewType("foo")).Type())) + assert.Nil(t, b.Factory(component.NewID(component.MustNewType("bar")).Type())) } var nopInstance = &nopReceiver{ diff --git a/receiver/receiverhelper/obsreport_test.go b/receiver/receiverhelper/obsreport_test.go index 4bb7a564edd..d6d75946f60 100644 --- a/receiver/receiverhelper/obsreport_test.go +++ b/receiver/receiverhelper/obsreport_test.go @@ -25,7 +25,7 @@ const ( ) var ( - receiverID = component.NewID(component.MustType("fakeReceiver")) + receiverID = component.NewID(component.MustNewType("fakeReceiver")) errFake = errors.New("errFake") ) diff --git a/receiver/receivertest/contract_checker_test.go b/receiver/receivertest/contract_checker_test.go index 2ca16c1e341..359d40015df 100644 --- a/receiver/receivertest/contract_checker_test.go +++ b/receiver/receivertest/contract_checker_test.go @@ -83,7 +83,7 @@ func (g *exampleGenerator) Generate() []UniqueIDAttrVal { func newExampleFactory() receiver.Factory { return receiver.NewFactory( - component.MustType("example_receiver"), + component.MustNewType("example_receiver"), func() component.Config { return &exampleReceiverConfig{} }, diff --git a/receiver/receivertest/nop_receiver.go b/receiver/receivertest/nop_receiver.go index 09590781abe..d1143b471e4 100644 --- a/receiver/receivertest/nop_receiver.go +++ b/receiver/receivertest/nop_receiver.go @@ -12,7 +12,7 @@ import ( "go.opentelemetry.io/collector/receiver" ) -var componentType = component.MustType("nop") +var componentType = component.MustNewType("nop") // NewNopCreateSettings returns a new nop settings for Create* functions. func NewNopCreateSettings() receiver.CreateSettings { diff --git a/receiver/receivertest/nop_receiver_test.go b/receiver/receivertest/nop_receiver_test.go index 0feee2262b6..d384e6b1fb7 100644 --- a/receiver/receivertest/nop_receiver_test.go +++ b/receiver/receivertest/nop_receiver_test.go @@ -15,7 +15,7 @@ import ( "go.opentelemetry.io/collector/consumer/consumertest" ) -var nopType = component.MustType("nop") +var nopType = component.MustNewType("nop") func TestNewNopFactory(t *testing.T) { factory := NewNopFactory() diff --git a/receiver/scraperhelper/obsreport_test.go b/receiver/scraperhelper/obsreport_test.go index b26a228400b..767a392fcbf 100644 --- a/receiver/scraperhelper/obsreport_test.go +++ b/receiver/scraperhelper/obsreport_test.go @@ -21,8 +21,8 @@ import ( ) var ( - receiverID = component.NewID(component.MustType("fakeReceiver")) - scraperID = component.NewID(component.MustType("fakeScraper")) + receiverID = component.NewID(component.MustNewType("fakeReceiver")) + scraperID = component.NewID(component.MustNewType("fakeScraper")) errFake = errors.New("errFake") partialErrFake = scrapererror.NewPartialScrapeError(errFake, 1) diff --git a/receiver/scraperhelper/scraper.go b/receiver/scraperhelper/scraper.go index 9326e89e518..f97eb65a403 100644 --- a/receiver/scraperhelper/scraper.go +++ b/receiver/scraperhelper/scraper.go @@ -67,7 +67,7 @@ func NewScraper(name string, scrape ScrapeFunc, options ...ScraperOption) (Scrap } bs := &baseScraper{ ScrapeFunc: scrape, - id: component.NewID(component.MustType(name)), + id: component.NewID(component.MustNewType(name)), } for _, op := range options { op(bs) diff --git a/receiver/scraperhelper/scrapercontroller_test.go b/receiver/scraperhelper/scrapercontroller_test.go index 3b3a880cc37..d104a415912 100644 --- a/receiver/scraperhelper/scrapercontroller_test.go +++ b/receiver/scraperhelper/scrapercontroller_test.go @@ -134,7 +134,7 @@ func TestScrapeController(t *testing.T) { for _, test := range testCases { test := test t.Run(test.name, func(t *testing.T) { - receiverID := component.NewID(component.MustType("receiver")) + receiverID := component.NewID(component.MustNewType("receiver")) tt, err := componenttest.SetupTelemetry(receiverID) require.NoError(t, err) t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) @@ -326,7 +326,7 @@ func assertScraperViews(t *testing.T, tt componenttest.TestTelemetry, expectedEr } } - require.NoError(t, tt.CheckScraperMetrics(component.NewID(component.MustType("receiver")), component.NewID(component.MustType("scraper")), expectedScraped, expectedErrored)) + require.NoError(t, tt.CheckScraperMetrics(component.NewID(component.MustNewType("receiver")), component.NewID(component.MustNewType("scraper")), expectedScraped, expectedErrored)) } func TestSingleScrapePerInterval(t *testing.T) { diff --git a/receiver/scraperhelper/settings_test.go b/receiver/scraperhelper/settings_test.go index 57570181ea5..64a5cd67300 100644 --- a/receiver/scraperhelper/settings_test.go +++ b/receiver/scraperhelper/settings_test.go @@ -22,7 +22,7 @@ func TestScrapeControllerSettings(t *testing.T) { }{ { name: "default configuration", - set: NewDefaultScraperControllerSettings(component.MustType("test")), + set: NewDefaultScraperControllerSettings(component.MustNewType("test")), errVal: "", }, { diff --git a/service/config_test.go b/service/config_test.go index a2488896a1f..cef01975ff3 100644 --- a/service/config_test.go +++ b/service/config_test.go @@ -42,7 +42,7 @@ func TestConfigValidate(t *testing.T) { name: "duplicate-processor-reference", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Pipelines[component.NewID(component.MustType("traces"))] + pipe := cfg.Pipelines[component.NewID(component.MustNewType("traces"))] pipe.Processors = append(pipe.Processors, pipe.Processors...) return cfg }, @@ -52,10 +52,10 @@ func TestConfigValidate(t *testing.T) { name: "invalid-service-pipeline-type", cfgFn: func() *Config { cfg := generateConfig() - cfg.Pipelines[component.NewID(component.MustType("wrongtype"))] = &pipelines.PipelineConfig{ - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + cfg.Pipelines[component.NewID(component.MustNewType("wrongtype"))] = &pipelines.PipelineConfig{ + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, } return cfg }, @@ -99,12 +99,12 @@ func generateConfig() *Config { Address: ":8080", }, }, - Extensions: extensions.Config{component.NewID(component.MustType("nop"))}, + Extensions: extensions.Config{component.NewID(component.MustNewType("nop"))}, Pipelines: pipelines.Config{ - component.NewID(component.MustType("traces")): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewID(component.MustNewType("traces")): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, } diff --git a/service/extensions/extensions_test.go b/service/extensions/extensions_test.go index cb44a4f2f99..b82147b6054 100644 --- a/service/extensions/extensions_test.go +++ b/service/extensions/extensions_test.go @@ -38,17 +38,17 @@ func TestBuildExtensions(t *testing.T) { { name: "extension_not_configured", config: Config{ - component.NewID(component.MustType("myextension")), + component.NewID(component.MustNewType("myextension")), }, wantErrMsg: "failed to create extension \"myextension\": extension \"myextension\" is not configured", }, { name: "missing_extension_factory", extensionsConfigs: map[component.ID]component.Config{ - component.NewID(component.MustType("unknown")): nopExtensionConfig, + component.NewID(component.MustNewType("unknown")): nopExtensionConfig, }, config: Config{ - component.NewID(component.MustType("unknown")), + component.NewID(component.MustNewType("unknown")), }, wantErrMsg: "failed to create extension \"unknown\": extension factory not available for: \"unknown\"", }, @@ -212,11 +212,11 @@ func TestNotifyConfig(t *testing.T) { notificationError := errors.New("Error processing config") nopExtensionFactory := extensiontest.NewNopFactory() nopExtensionConfig := nopExtensionFactory.CreateDefaultConfig() - n1ExtensionFactory := newConfigWatcherExtensionFactory(component.MustType("notifiable1"), func() error { return nil }) + n1ExtensionFactory := newConfigWatcherExtensionFactory(component.MustNewType("notifiable1"), func() error { return nil }) n1ExtensionConfig := n1ExtensionFactory.CreateDefaultConfig() - n2ExtensionFactory := newConfigWatcherExtensionFactory(component.MustType("notifiable2"), func() error { return nil }) + n2ExtensionFactory := newConfigWatcherExtensionFactory(component.MustNewType("notifiable2"), func() error { return nil }) n2ExtensionConfig := n1ExtensionFactory.CreateDefaultConfig() - nErrExtensionFactory := newConfigWatcherExtensionFactory(component.MustType("notifiableErr"), func() error { return notificationError }) + nErrExtensionFactory := newConfigWatcherExtensionFactory(component.MustNewType("notifiableErr"), func() error { return notificationError }) nErrExtensionConfig := nErrExtensionFactory.CreateDefaultConfig() tests := []struct { @@ -230,52 +230,52 @@ func TestNotifyConfig(t *testing.T) { { name: "No notifiable extensions", factories: map[component.Type]extension.Factory{ - component.MustType("nop"): nopExtensionFactory, + component.MustNewType("nop"): nopExtensionFactory, }, extensionsConfigs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExtensionConfig, + component.NewID(component.MustNewType("nop")): nopExtensionConfig, }, serviceExtensions: []component.ID{ - component.NewID(component.MustType("nop")), + component.NewID(component.MustNewType("nop")), }, }, { name: "One notifiable extension", factories: map[component.Type]extension.Factory{ - component.MustType("notifiable1"): n1ExtensionFactory, + component.MustNewType("notifiable1"): n1ExtensionFactory, }, extensionsConfigs: map[component.ID]component.Config{ - component.NewID(component.MustType("notifiable1")): n1ExtensionConfig, + component.NewID(component.MustNewType("notifiable1")): n1ExtensionConfig, }, serviceExtensions: []component.ID{ - component.NewID(component.MustType("notifiable1")), + component.NewID(component.MustNewType("notifiable1")), }, }, { name: "Multiple notifiable extensions", factories: map[component.Type]extension.Factory{ - component.MustType("notifiable1"): n1ExtensionFactory, - component.MustType("notifiable2"): n2ExtensionFactory, + component.MustNewType("notifiable1"): n1ExtensionFactory, + component.MustNewType("notifiable2"): n2ExtensionFactory, }, extensionsConfigs: map[component.ID]component.Config{ - component.NewID(component.MustType("notifiable1")): n1ExtensionConfig, - component.NewID(component.MustType("notifiable2")): n2ExtensionConfig, + component.NewID(component.MustNewType("notifiable1")): n1ExtensionConfig, + component.NewID(component.MustNewType("notifiable2")): n2ExtensionConfig, }, serviceExtensions: []component.ID{ - component.NewID(component.MustType("notifiable1")), - component.NewID(component.MustType("notifiable2")), + component.NewID(component.MustNewType("notifiable1")), + component.NewID(component.MustNewType("notifiable2")), }, }, { name: "Errors in extension notification", factories: map[component.Type]extension.Factory{ - component.MustType("notifiableErr"): nErrExtensionFactory, + component.MustNewType("notifiableErr"): nErrExtensionFactory, }, extensionsConfigs: map[component.ID]component.Config{ - component.NewID(component.MustType("notifiableErr")): nErrExtensionConfig, + component.NewID(component.MustNewType("notifiableErr")): nErrExtensionConfig, }, serviceExtensions: []component.ID{ - component.NewID(component.MustType("notifiableErr")), + component.NewID(component.MustNewType("notifiableErr")), }, want: notificationError, }, @@ -335,7 +335,7 @@ func newConfigWatcherExtensionFactory(name component.Type, fn func() error) exte func newBadExtensionFactory() extension.Factory { return extension.NewFactory( - component.MustType("bf"), + component.MustNewType("bf"), func() component.Config { return &struct{}{} }, @@ -348,7 +348,7 @@ func newBadExtensionFactory() extension.Factory { func newCreateErrorExtensionFactory() extension.Factory { return extension.NewFactory( - component.MustType("err"), + component.MustNewType("err"), func() component.Config { return &struct{}{} }, @@ -410,7 +410,7 @@ func TestStatusReportedOnStartupShutdown(t *testing.T) { }, } { t.Run(tc.name, func(t *testing.T) { - statusType := component.MustType("statustest") + statusType := component.MustNewType("statustest") compID := component.NewID(statusType) factory := newStatusTestExtensionFactory(statusType, tc.startErr, tc.shutdownErr) config := factory.CreateDefaultConfig() @@ -485,7 +485,7 @@ func newStatusTestExtensionFactory(name component.Type, startErr, shutdownErr er func newRecordingExtensionFactory(startCallback func(set extension.CreateSettings, host component.Host) error, shutdownCallback func(set extension.CreateSettings) error) extension.Factory { return extension.NewFactory( - component.MustType("recording"), + component.MustNewType("recording"), func() component.Config { return &recordingExtensionConfig{} }, @@ -520,7 +520,7 @@ func (ext *recordingExtension) Dependencies() []component.ID { } deps := make([]component.ID, len(ext.config.dependencies)) for i, dep := range ext.config.dependencies { - deps[i] = component.NewIDWithName(component.MustType("recording"), dep) + deps[i] = component.NewIDWithName(component.MustNewType("recording"), dep) } return deps } diff --git a/service/internal/graph/graph_test.go b/service/internal/graph/graph_test.go index 7867d67e1c7..df611a00954 100644 --- a/service/internal/graph/graph_test.go +++ b/service/internal/graph/graph_test.go @@ -90,48 +90,48 @@ func TestGraphStartStop(t *testing.T) { { name: "single", edges: [][2]component.ID{ - {component.NewIDWithName(component.MustType("r"), "1"), component.NewIDWithName(component.MustType("p"), "1")}, - {component.NewIDWithName(component.MustType("r"), "2"), component.NewIDWithName(component.MustType("p"), "1")}, - {component.NewIDWithName(component.MustType("p"), "1"), component.NewIDWithName(component.MustType("p"), "2")}, - {component.NewIDWithName(component.MustType("p"), "2"), component.NewIDWithName(component.MustType("e"), "1")}, - {component.NewIDWithName(component.MustType("p"), "1"), component.NewIDWithName(component.MustType("e"), "2")}, + {component.NewIDWithName(component.MustNewType("r"), "1"), component.NewIDWithName(component.MustNewType("p"), "1")}, + {component.NewIDWithName(component.MustNewType("r"), "2"), component.NewIDWithName(component.MustNewType("p"), "1")}, + {component.NewIDWithName(component.MustNewType("p"), "1"), component.NewIDWithName(component.MustNewType("p"), "2")}, + {component.NewIDWithName(component.MustNewType("p"), "2"), component.NewIDWithName(component.MustNewType("e"), "1")}, + {component.NewIDWithName(component.MustNewType("p"), "1"), component.NewIDWithName(component.MustNewType("e"), "2")}, }, }, { name: "multi", edges: [][2]component.ID{ // Pipeline 1 - {component.NewIDWithName(component.MustType("r"), "1"), component.NewIDWithName(component.MustType("p"), "1")}, - {component.NewIDWithName(component.MustType("r"), "2"), component.NewIDWithName(component.MustType("p"), "1")}, - {component.NewIDWithName(component.MustType("p"), "1"), component.NewIDWithName(component.MustType("p"), "2")}, - {component.NewIDWithName(component.MustType("p"), "2"), component.NewIDWithName(component.MustType("e"), "1")}, - {component.NewIDWithName(component.MustType("p"), "1"), component.NewIDWithName(component.MustType("e"), "2")}, + {component.NewIDWithName(component.MustNewType("r"), "1"), component.NewIDWithName(component.MustNewType("p"), "1")}, + {component.NewIDWithName(component.MustNewType("r"), "2"), component.NewIDWithName(component.MustNewType("p"), "1")}, + {component.NewIDWithName(component.MustNewType("p"), "1"), component.NewIDWithName(component.MustNewType("p"), "2")}, + {component.NewIDWithName(component.MustNewType("p"), "2"), component.NewIDWithName(component.MustNewType("e"), "1")}, + {component.NewIDWithName(component.MustNewType("p"), "1"), component.NewIDWithName(component.MustNewType("e"), "2")}, // Pipeline 2, shares r1 and e2 - {component.NewIDWithName(component.MustType("r"), "1"), component.NewIDWithName(component.MustType("p"), "3")}, - {component.NewIDWithName(component.MustType("p"), "3"), component.NewIDWithName(component.MustType("e"), "2")}, + {component.NewIDWithName(component.MustNewType("r"), "1"), component.NewIDWithName(component.MustNewType("p"), "3")}, + {component.NewIDWithName(component.MustNewType("p"), "3"), component.NewIDWithName(component.MustNewType("e"), "2")}, }, }, { name: "connected", edges: [][2]component.ID{ // Pipeline 1 - {component.NewIDWithName(component.MustType("r"), "1"), component.NewIDWithName(component.MustType("p"), "1")}, - {component.NewIDWithName(component.MustType("r"), "2"), component.NewIDWithName(component.MustType("p"), "1")}, - {component.NewIDWithName(component.MustType("p"), "1"), component.NewIDWithName(component.MustType("p"), "2")}, - {component.NewIDWithName(component.MustType("p"), "2"), component.NewIDWithName(component.MustType("e"), "1")}, - {component.NewIDWithName(component.MustType("p"), "1"), component.NewIDWithName(component.MustType("c"), "1")}, + {component.NewIDWithName(component.MustNewType("r"), "1"), component.NewIDWithName(component.MustNewType("p"), "1")}, + {component.NewIDWithName(component.MustNewType("r"), "2"), component.NewIDWithName(component.MustNewType("p"), "1")}, + {component.NewIDWithName(component.MustNewType("p"), "1"), component.NewIDWithName(component.MustNewType("p"), "2")}, + {component.NewIDWithName(component.MustNewType("p"), "2"), component.NewIDWithName(component.MustNewType("e"), "1")}, + {component.NewIDWithName(component.MustNewType("p"), "1"), component.NewIDWithName(component.MustNewType("c"), "1")}, // Pipeline 2, shares r1 and c1 - {component.NewIDWithName(component.MustType("r"), "1"), component.NewIDWithName(component.MustType("p"), "3")}, - {component.NewIDWithName(component.MustType("p"), "3"), component.NewIDWithName(component.MustType("c"), "1")}, + {component.NewIDWithName(component.MustNewType("r"), "1"), component.NewIDWithName(component.MustNewType("p"), "3")}, + {component.NewIDWithName(component.MustNewType("p"), "3"), component.NewIDWithName(component.MustNewType("c"), "1")}, // Pipeline 3, emits to e2 and c2 - {component.NewIDWithName(component.MustType("c"), "1"), component.NewIDWithName(component.MustType("e"), "2")}, - {component.NewIDWithName(component.MustType("c"), "1"), component.NewIDWithName(component.MustType("c"), "2")}, + {component.NewIDWithName(component.MustNewType("c"), "1"), component.NewIDWithName(component.MustNewType("e"), "2")}, + {component.NewIDWithName(component.MustNewType("c"), "1"), component.NewIDWithName(component.MustNewType("c"), "2")}, // Pipeline 4, also emits to e2 - {component.NewIDWithName(component.MustType("c"), "2"), component.NewIDWithName(component.MustType("e"), "2")}, + {component.NewIDWithName(component.MustNewType("c"), "2"), component.NewIDWithName(component.MustNewType("e"), "2")}, }, }, } @@ -171,10 +171,10 @@ func TestGraphStartStop(t *testing.T) { func TestGraphStartStopCycle(t *testing.T) { pg := &Graph{componentGraph: simple.NewDirectedGraph()} - r1 := &testNode{id: component.NewIDWithName(component.MustType("r"), "1")} - p1 := &testNode{id: component.NewIDWithName(component.MustType("p"), "1")} - c1 := &testNode{id: component.NewIDWithName(component.MustType("c"), "1")} - e1 := &testNode{id: component.NewIDWithName(component.MustType("e"), "1")} + r1 := &testNode{id: component.NewIDWithName(component.MustNewType("r"), "1")} + p1 := &testNode{id: component.NewIDWithName(component.MustNewType("p"), "1")} + c1 := &testNode{id: component.NewIDWithName(component.MustNewType("c"), "1")} + e1 := &testNode{id: component.NewIDWithName(component.MustNewType("e"), "1")} pg.instanceIDs = map[int64]*component.InstanceID{ r1.ID(): {}, @@ -201,11 +201,11 @@ func TestGraphStartStopComponentError(t *testing.T) { pg := &Graph{componentGraph: simple.NewDirectedGraph()} pg.telemetry = servicetelemetry.NewNopTelemetrySettings() r1 := &testNode{ - id: component.NewIDWithName(component.MustType("r"), "1"), + id: component.NewIDWithName(component.MustNewType("r"), "1"), startErr: errors.New("foo"), } e1 := &testNode{ - id: component.NewIDWithName(component.MustType("e"), "1"), + id: component.NewIDWithName(component.MustNewType("e"), "1"), shutdownErr: errors.New("bar"), } pg.instanceIDs = map[int64]*component.InstanceID{ @@ -229,20 +229,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_simple.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustType("traces")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("traces")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewID(component.MustType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewID(component.MustType("logs")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("logs")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -250,20 +250,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_simple_mutate.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustType("traces")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("traces")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewID(component.MustType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewID(component.MustType("logs")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("logs")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -271,20 +271,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_simple_multi_proc.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustType("traces")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor")), component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("traces")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor")), component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewID(component.MustType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor")), component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor")), component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewID(component.MustType("logs")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor")), component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("logs")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor")), component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -292,17 +292,17 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_simple_no_proc.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustType("traces")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("traces")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewID(component.MustType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewID(component.MustType("logs")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("logs")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -310,20 +310,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_multi.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustType("traces")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver")), component.NewIDWithName(component.MustType("examplereceiver"), "1")}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate"), component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter")), component.NewIDWithName(component.MustType("exampleexporter"), "1")}, + component.NewID(component.MustNewType("traces")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver")), component.NewIDWithName(component.MustNewType("examplereceiver"), "1")}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate"), component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter")), component.NewIDWithName(component.MustNewType("exampleexporter"), "1")}, }, - component.NewID(component.MustType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver")), component.NewIDWithName(component.MustType("examplereceiver"), "1")}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate"), component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter")), component.NewIDWithName(component.MustType("exampleexporter"), "1")}, + component.NewID(component.MustNewType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver")), component.NewIDWithName(component.MustNewType("examplereceiver"), "1")}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate"), component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter")), component.NewIDWithName(component.MustNewType("exampleexporter"), "1")}, }, - component.NewID(component.MustType("logs")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver")), component.NewIDWithName(component.MustType("examplereceiver"), "1")}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate"), component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter")), component.NewIDWithName(component.MustType("exampleexporter"), "1")}, + component.NewID(component.MustNewType("logs")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver")), component.NewIDWithName(component.MustNewType("examplereceiver"), "1")}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate"), component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter")), component.NewIDWithName(component.MustNewType("exampleexporter"), "1")}, }, }, expectedPerExporter: 2, @@ -331,17 +331,17 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_multi_no_proc.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustType("traces")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver")), component.NewIDWithName(component.MustType("examplereceiver"), "1")}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter")), component.NewIDWithName(component.MustType("exampleexporter"), "1")}, + component.NewID(component.MustNewType("traces")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver")), component.NewIDWithName(component.MustNewType("examplereceiver"), "1")}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter")), component.NewIDWithName(component.MustNewType("exampleexporter"), "1")}, }, - component.NewID(component.MustType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver")), component.NewIDWithName(component.MustType("examplereceiver"), "1")}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter")), component.NewIDWithName(component.MustType("exampleexporter"), "1")}, + component.NewID(component.MustNewType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver")), component.NewIDWithName(component.MustNewType("examplereceiver"), "1")}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter")), component.NewIDWithName(component.MustNewType("exampleexporter"), "1")}, }, - component.NewID(component.MustType("logs")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver")), component.NewIDWithName(component.MustType("examplereceiver"), "1")}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter")), component.NewIDWithName(component.MustType("exampleexporter"), "1")}, + component.NewID(component.MustNewType("logs")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver")), component.NewIDWithName(component.MustNewType("examplereceiver"), "1")}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter")), component.NewIDWithName(component.MustNewType("exampleexporter"), "1")}, }, }, expectedPerExporter: 2, @@ -349,32 +349,32 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "multi_pipeline_receivers_and_exporters.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustType("traces")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("traces")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewIDWithName(component.MustType("traces"), "1"): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("traces"), "1"): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewID(component.MustType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewIDWithName(component.MustType("metrics"), "1"): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("metrics"), "1"): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewID(component.MustType("logs")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("logs")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewIDWithName(component.MustType("logs"), "1"): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("logs"), "1"): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, }, expectedPerExporter: 2, @@ -382,15 +382,15 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_simple_traces.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + component.NewIDWithName(component.MustNewType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName(component.MustType("traces"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("traces"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -398,15 +398,15 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_simple_metrics.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + component.NewIDWithName(component.MustNewType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName(component.MustType("metrics"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("metrics"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -414,15 +414,15 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_simple_logs.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustType("logs"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + component.NewIDWithName(component.MustNewType("logs"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName(component.MustType("logs"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("logs"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -430,25 +430,25 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_fork_merge_traces.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + component.NewIDWithName(component.MustNewType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName(component.MustType("traces"), "type0"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "merge")}, + component.NewIDWithName(component.MustNewType("traces"), "type0"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "merge")}, }, - component.NewIDWithName(component.MustType("traces"), "type1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "merge")}, + component.NewIDWithName(component.MustNewType("traces"), "type1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "merge")}, }, - component.NewIDWithName(component.MustType("traces"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "merge")}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("traces"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "merge")}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, }, expectedPerExporter: 2, @@ -456,25 +456,25 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_fork_merge_metrics.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + component.NewIDWithName(component.MustNewType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName(component.MustType("metrics"), "type0"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "merge")}, + component.NewIDWithName(component.MustNewType("metrics"), "type0"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "merge")}, }, - component.NewIDWithName(component.MustType("metrics"), "type1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "merge")}, + component.NewIDWithName(component.MustNewType("metrics"), "type1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "merge")}, }, - component.NewIDWithName(component.MustType("metrics"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "merge")}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("metrics"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "merge")}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, }, expectedPerExporter: 2, @@ -482,25 +482,25 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_fork_merge_logs.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustType("logs"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + component.NewIDWithName(component.MustNewType("logs"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName(component.MustType("logs"), "type0"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "merge")}, + component.NewIDWithName(component.MustNewType("logs"), "type0"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "merge")}, }, - component.NewIDWithName(component.MustType("logs"), "type1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "merge")}, + component.NewIDWithName(component.MustNewType("logs"), "type1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "merge")}, }, - component.NewIDWithName(component.MustType("logs"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "merge")}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("logs"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "merge")}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, }, expectedPerExporter: 2, @@ -508,20 +508,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_translate_from_traces.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustType("traces")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleconnector"))}, + component.NewID(component.MustNewType("traces")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleconnector"))}, }, - component.NewID(component.MustType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustType("exampleconnector"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustNewType("exampleconnector"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewID(component.MustType("logs")): { - Receivers: []component.ID{component.NewID(component.MustType("exampleconnector"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("logs")): { + Receivers: []component.ID{component.NewID(component.MustNewType("exampleconnector"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -529,20 +529,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_translate_from_metrics.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleconnector"))}, + component.NewID(component.MustNewType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleconnector"))}, }, - component.NewID(component.MustType("traces")): { - Receivers: []component.ID{component.NewID(component.MustType("exampleconnector"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("traces")): { + Receivers: []component.ID{component.NewID(component.MustNewType("exampleconnector"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewID(component.MustType("logs")): { - Receivers: []component.ID{component.NewID(component.MustType("exampleconnector"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("logs")): { + Receivers: []component.ID{component.NewID(component.MustNewType("exampleconnector"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -550,20 +550,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_translate_from_logs.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustType("logs")): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleconnector"))}, + component.NewID(component.MustNewType("logs")): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleconnector"))}, }, - component.NewID(component.MustType("traces")): { - Receivers: []component.ID{component.NewID(component.MustType("exampleconnector"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("traces")): { + Receivers: []component.ID{component.NewID(component.MustNewType("exampleconnector"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewID(component.MustType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustType("exampleconnector"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewID(component.MustNewType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustNewType("exampleconnector"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -571,35 +571,35 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_matrix.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + component.NewIDWithName(component.MustNewType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName(component.MustType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + component.NewIDWithName(component.MustNewType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName(component.MustType("logs"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + component.NewIDWithName(component.MustNewType("logs"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName(component.MustType("traces"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("traces"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewIDWithName(component.MustType("metrics"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("metrics"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewIDWithName(component.MustType("logs"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName(component.MustType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("logs"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, }, expectedPerExporter: 3, @@ -607,29 +607,29 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_lanes.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Exporters: []component.ID{component.NewID(component.MustType("mockforward"))}, + component.NewIDWithName(component.MustNewType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("mockforward"))}, }, - component.NewIDWithName(component.MustType("traces"), "out"): { - Receivers: []component.ID{component.NewID(component.MustType("mockforward"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("traces"), "out"): { + Receivers: []component.ID{component.NewID(component.MustNewType("mockforward"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewIDWithName(component.MustType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Exporters: []component.ID{component.NewID(component.MustType("mockforward"))}, + component.NewIDWithName(component.MustNewType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("mockforward"))}, }, - component.NewIDWithName(component.MustType("metrics"), "out"): { - Receivers: []component.ID{component.NewID(component.MustType("mockforward"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("metrics"), "out"): { + Receivers: []component.ID{component.NewID(component.MustNewType("mockforward"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewIDWithName(component.MustType("logs"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Exporters: []component.ID{component.NewID(component.MustType("mockforward"))}, + component.NewIDWithName(component.MustNewType("logs"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("mockforward"))}, }, - component.NewIDWithName(component.MustType("logs"), "out"): { - Receivers: []component.ID{component.NewID(component.MustType("mockforward"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("logs"), "out"): { + Receivers: []component.ID{component.NewID(component.MustNewType("mockforward"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, }, expectedPerExporter: 1, @@ -637,25 +637,25 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_mutate_traces.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + component.NewIDWithName(component.MustNewType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName(component.MustType("traces"), "out0"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("traces"), "out0"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewIDWithName(component.MustType("traces"), "middle"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "mutate")}, + component.NewIDWithName(component.MustNewType("traces"), "middle"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "mutate")}, }, - component.NewIDWithName(component.MustType("traces"), "out1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "mutate")}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("traces"), "out1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "mutate")}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, }, expectedPerExporter: 2, @@ -663,25 +663,25 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_mutate_metrics.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + component.NewIDWithName(component.MustNewType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName(component.MustType("metrics"), "out0"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("metrics"), "out0"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewIDWithName(component.MustType("metrics"), "middle"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "mutate")}, + component.NewIDWithName(component.MustNewType("metrics"), "middle"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "mutate")}, }, - component.NewIDWithName(component.MustType("metrics"), "out1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "mutate")}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("metrics"), "out1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "mutate")}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, }, expectedPerExporter: 2, @@ -689,25 +689,25 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_mutate_logs.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustType("logs"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, + component.NewIDWithName(component.MustNewType("logs"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, }, - component.NewIDWithName(component.MustType("logs"), "out0"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("logs"), "out0"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, - component.NewIDWithName(component.MustType("logs"), "middle"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "mutate")}, + component.NewIDWithName(component.MustNewType("logs"), "middle"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "mutate")}, }, - component.NewIDWithName(component.MustType("logs"), "out1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("exampleconnector"), "mutate")}, - Processors: []component.ID{component.NewID(component.MustType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustType("exampleexporter"))}, + component.NewIDWithName(component.MustNewType("logs"), "out1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "mutate")}, + Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, }, }, expectedPerExporter: 2, @@ -722,8 +722,8 @@ func TestConnectorPipelinesGraph(t *testing.T) { BuildInfo: component.NewDefaultBuildInfo(), ReceiverBuilder: receiver.NewBuilder( map[component.ID]component.Config{ - component.NewID(component.MustType("examplereceiver")): testcomponents.ExampleReceiverFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustType("examplereceiver"), "1"): testcomponents.ExampleReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("examplereceiver")): testcomponents.ExampleReceiverFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("examplereceiver"), "1"): testcomponents.ExampleReceiverFactory.CreateDefaultConfig(), }, map[component.Type]receiver.Factory{ testcomponents.ExampleReceiverFactory.Type(): testcomponents.ExampleReceiverFactory, @@ -731,8 +731,8 @@ func TestConnectorPipelinesGraph(t *testing.T) { ), ProcessorBuilder: processor.NewBuilder( map[component.ID]component.Config{ - component.NewID(component.MustType("exampleprocessor")): testcomponents.ExampleProcessorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustType("exampleprocessor"), "mutate"): testcomponents.ExampleProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("exampleprocessor")): testcomponents.ExampleProcessorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate"): testcomponents.ExampleProcessorFactory.CreateDefaultConfig(), }, map[component.Type]processor.Factory{ testcomponents.ExampleProcessorFactory.Type(): testcomponents.ExampleProcessorFactory, @@ -740,8 +740,8 @@ func TestConnectorPipelinesGraph(t *testing.T) { ), ExporterBuilder: exporter.NewBuilder( map[component.ID]component.Config{ - component.NewID(component.MustType("exampleexporter")): testcomponents.ExampleExporterFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustType("exampleexporter"), "1"): testcomponents.ExampleExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("exampleexporter")): testcomponents.ExampleExporterFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("exampleexporter"), "1"): testcomponents.ExampleExporterFactory.CreateDefaultConfig(), }, map[component.Type]exporter.Factory{ testcomponents.ExampleExporterFactory.Type(): testcomponents.ExampleExporterFactory, @@ -749,11 +749,11 @@ func TestConnectorPipelinesGraph(t *testing.T) { ), ConnectorBuilder: connector.NewBuilder( map[component.ID]component.Config{ - component.NewID(component.MustType("exampleconnector")): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustType("exampleconnector"), "merge"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustType("exampleconnector"), "mutate"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustType("exampleconnector"), "inherit_mutate"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), - component.NewID(component.MustType("mockforward")): testcomponents.MockForwardConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("exampleconnector")): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("exampleconnector"), "merge"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("exampleconnector"), "mutate"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("mockforward")): testcomponents.MockForwardConnectorFactory.CreateDefaultConfig(), }, map[component.Type]connector.Factory{ testcomponents.ExampleConnectorFactory.Type(): testcomponents.ExampleConnectorFactory, @@ -984,24 +984,24 @@ func TestConnectorPipelinesGraph(t *testing.T) { } func TestConnectorRouter(t *testing.T) { - rcvrID := component.NewID(component.MustType("examplereceiver")) - routeTracesID := component.NewIDWithName(component.MustType("examplerouter"), "traces") - routeMetricsID := component.NewIDWithName(component.MustType("examplerouter"), "metrics") - routeLogsID := component.NewIDWithName(component.MustType("examplerouter"), "logs") - expRightID := component.NewIDWithName(component.MustType("exampleexporter"), "right") - expLeftID := component.NewIDWithName(component.MustType("exampleexporter"), "left") + rcvrID := component.NewID(component.MustNewType("examplereceiver")) + routeTracesID := component.NewIDWithName(component.MustNewType("examplerouter"), "traces") + routeMetricsID := component.NewIDWithName(component.MustNewType("examplerouter"), "metrics") + routeLogsID := component.NewIDWithName(component.MustNewType("examplerouter"), "logs") + expRightID := component.NewIDWithName(component.MustNewType("exampleexporter"), "right") + expLeftID := component.NewIDWithName(component.MustNewType("exampleexporter"), "left") - tracesInID := component.NewIDWithName(component.MustType("traces"), "in") - tracesRightID := component.NewIDWithName(component.MustType("traces"), "right") - tracesLeftID := component.NewIDWithName(component.MustType("traces"), "left") + tracesInID := component.NewIDWithName(component.MustNewType("traces"), "in") + tracesRightID := component.NewIDWithName(component.MustNewType("traces"), "right") + tracesLeftID := component.NewIDWithName(component.MustNewType("traces"), "left") - metricsInID := component.NewIDWithName(component.MustType("metrics"), "in") - metricsRightID := component.NewIDWithName(component.MustType("metrics"), "right") - metricsLeftID := component.NewIDWithName(component.MustType("metrics"), "left") + metricsInID := component.NewIDWithName(component.MustNewType("metrics"), "in") + metricsRightID := component.NewIDWithName(component.MustNewType("metrics"), "right") + metricsLeftID := component.NewIDWithName(component.MustNewType("metrics"), "left") - logsInID := component.NewIDWithName(component.MustType("logs"), "in") - logsRightID := component.NewIDWithName(component.MustType("logs"), "right") - logsLeftID := component.NewIDWithName(component.MustType("logs"), "left") + logsInID := component.NewIDWithName(component.MustNewType("logs"), "in") + logsRightID := component.NewIDWithName(component.MustNewType("logs"), "right") + logsLeftID := component.NewIDWithName(component.MustNewType("logs"), "left") ctx := context.Background() set := Settings{ @@ -1188,15 +1188,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_exporter_logs", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("bf")): badExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("bf")): badExporterFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustType("logs")): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("bf"))}, + component.NewID(component.MustNewType("logs")): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, }, }, expected: "failed to create \"bf\" exporter for data type \"logs\": telemetry type is not supported", @@ -1204,15 +1204,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_exporter_metrics", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("bf")): badExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("bf")): badExporterFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("bf"))}, + component.NewID(component.MustNewType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, }, }, expected: "failed to create \"bf\" exporter for data type \"metrics\": telemetry type is not supported", @@ -1220,15 +1220,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_exporter_traces", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("bf")): badExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("bf")): badExporterFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustType("traces")): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("bf"))}, + component.NewID(component.MustNewType("traces")): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, }, }, expected: "failed to create \"bf\" exporter for data type \"traces\": telemetry type is not supported", @@ -1236,19 +1236,19 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_processor_logs", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("bf")): badProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("bf")): badProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustType("logs")): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Processors: []component.ID{component.NewID(component.MustType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewID(component.MustNewType("logs")): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Processors: []component.ID{component.NewID(component.MustNewType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "failed to create \"bf\" processor, in pipeline \"logs\": telemetry type is not supported", @@ -1256,19 +1256,19 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_processor_metrics", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("bf")): badProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("bf")): badProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Processors: []component.ID{component.NewID(component.MustType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewID(component.MustNewType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Processors: []component.ID{component.NewID(component.MustNewType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "failed to create \"bf\" processor, in pipeline \"metrics\": telemetry type is not supported", @@ -1276,19 +1276,19 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_processor_traces", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("bf")): badProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("bf")): badProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustType("traces")): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Processors: []component.ID{component.NewID(component.MustType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewID(component.MustNewType("traces")): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Processors: []component.ID{component.NewID(component.MustNewType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "failed to create \"bf\" processor, in pipeline \"traces\": telemetry type is not supported", @@ -1296,15 +1296,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_receiver_logs", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("bf")): badReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("bf")): badReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustType("logs")): { - Receivers: []component.ID{component.NewID(component.MustType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewID(component.MustNewType("logs")): { + Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "failed to create \"bf\" receiver for data type \"logs\": telemetry type is not supported", @@ -1312,15 +1312,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_receiver_metrics", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("bf")): badReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("bf")): badReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewID(component.MustNewType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "failed to create \"bf\" receiver for data type \"metrics\": telemetry type is not supported", @@ -1328,15 +1328,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_receiver_traces", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("bf")): badReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("bf")): badReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustType("traces")): { - Receivers: []component.ID{component.NewID(component.MustType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewID(component.MustNewType("traces")): { + Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "failed to create \"bf\" receiver for data type \"traces\": telemetry type is not supported", @@ -1344,22 +1344,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_traces_traces.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("bf")): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("bf")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("bf"))}, + component.NewIDWithName(component.MustNewType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, }, - component.NewIDWithName(component.MustType("traces"), "out"): { - Receivers: []component.ID{component.NewID(component.MustType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewIDWithName(component.MustNewType("traces"), "out"): { + Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "connector \"bf\" used as exporter in traces pipeline but not used in any supported receiver pipeline", @@ -1367,22 +1367,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_traces_metrics.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("bf")): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("bf")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("bf"))}, + component.NewIDWithName(component.MustNewType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, }, - component.NewIDWithName(component.MustType("metrics"), "out"): { - Receivers: []component.ID{component.NewID(component.MustType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewIDWithName(component.MustNewType("metrics"), "out"): { + Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "connector \"bf\" used as exporter in traces pipeline but not used in any supported receiver pipeline", @@ -1390,22 +1390,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_traces_logs.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("bf")): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("bf")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("bf"))}, + component.NewIDWithName(component.MustNewType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, }, - component.NewIDWithName(component.MustType("logs"), "out"): { - Receivers: []component.ID{component.NewID(component.MustType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewIDWithName(component.MustNewType("logs"), "out"): { + Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "connector \"bf\" used as exporter in traces pipeline but not used in any supported receiver pipeline", @@ -1413,22 +1413,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_metrics_traces.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("bf")): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("bf")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("bf"))}, + component.NewIDWithName(component.MustNewType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, }, - component.NewIDWithName(component.MustType("traces"), "out"): { - Receivers: []component.ID{component.NewID(component.MustType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewIDWithName(component.MustNewType("traces"), "out"): { + Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "connector \"bf\" used as exporter in metrics pipeline but not used in any supported receiver pipeline", @@ -1436,22 +1436,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_metrics_metrics.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("bf")): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("bf")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("bf"))}, + component.NewIDWithName(component.MustNewType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, }, - component.NewIDWithName(component.MustType("metrics"), "out"): { - Receivers: []component.ID{component.NewID(component.MustType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewIDWithName(component.MustNewType("metrics"), "out"): { + Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "connector \"bf\" used as exporter in metrics pipeline but not used in any supported receiver pipeline", @@ -1459,22 +1459,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_metrics_logs.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("bf")): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("bf")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("bf"))}, + component.NewIDWithName(component.MustNewType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, }, - component.NewIDWithName(component.MustType("logs"), "out"): { - Receivers: []component.ID{component.NewID(component.MustType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewIDWithName(component.MustNewType("logs"), "out"): { + Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "connector \"bf\" used as exporter in metrics pipeline but not used in any supported receiver pipeline", @@ -1482,22 +1482,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_logs_traces.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("bf")): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("bf")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustType("logs"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("bf"))}, + component.NewIDWithName(component.MustNewType("logs"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, }, - component.NewIDWithName(component.MustType("traces"), "out"): { - Receivers: []component.ID{component.NewID(component.MustType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewIDWithName(component.MustNewType("traces"), "out"): { + Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "connector \"bf\" used as exporter in logs pipeline but not used in any supported receiver pipeline", @@ -1505,22 +1505,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_logs_metrics.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("bf")): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("bf")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustType("logs"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("bf"))}, + component.NewIDWithName(component.MustNewType("logs"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, }, - component.NewIDWithName(component.MustType("metrics"), "out"): { - Receivers: []component.ID{component.NewID(component.MustType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewIDWithName(component.MustNewType("metrics"), "out"): { + Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "connector \"bf\" used as exporter in logs pipeline but not used in any supported receiver pipeline", @@ -1528,22 +1528,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_logs_logs.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("bf")): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("bf")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustType("logs"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("bf"))}, + component.NewIDWithName(component.MustNewType("logs"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, }, - component.NewIDWithName(component.MustType("logs"), "out"): { - Receivers: []component.ID{component.NewID(component.MustType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewIDWithName(component.MustNewType("logs"), "out"): { + Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "connector \"bf\" used as exporter in logs pipeline but not used in any supported receiver pipeline", @@ -1551,18 +1551,18 @@ func TestGraphBuildErrors(t *testing.T) { { name: "orphaned-connector-use-as-exporter", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName(component.MustType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, + component.NewIDWithName(component.MustNewType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, }, }, expected: `connector "nop/conn" used as exporter in metrics pipeline but not used in any supported receiver pipeline`, @@ -1570,18 +1570,18 @@ func TestGraphBuildErrors(t *testing.T) { { name: "orphaned-connector-use-as-receiver", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName(component.MustType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustType("traces"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewIDWithName(component.MustNewType("traces"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: `connector "nop/conn" used as receiver in traces pipeline but not used in any supported exporter pipeline`, @@ -1589,26 +1589,26 @@ func TestGraphBuildErrors(t *testing.T) { { name: "partially-orphaned-connector-use-as-exporter", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("mockforward")): mfConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("mockforward")): mfConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("mockforward"))}, + component.NewIDWithName(component.MustNewType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("mockforward"))}, }, - component.NewIDWithName(component.MustType("traces"), "out"): { - Receivers: []component.ID{component.NewID(component.MustType("mockforward"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewIDWithName(component.MustNewType("traces"), "out"): { + Receivers: []component.ID{component.NewID(component.MustNewType("mockforward"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, - component.NewIDWithName(component.MustType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("mockforward"))}, + component.NewIDWithName(component.MustNewType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("mockforward"))}, }, }, expected: `connector "mockforward" used as exporter in metrics pipeline but not used in any supported receiver pipeline`, @@ -1616,26 +1616,26 @@ func TestGraphBuildErrors(t *testing.T) { { name: "partially-orphaned-connector-use-as-receiver", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("mockforward")): mfConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("mockforward")): mfConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("mockforward"))}, + component.NewIDWithName(component.MustNewType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("mockforward"))}, }, - component.NewIDWithName(component.MustType("metrics"), "out"): { - Receivers: []component.ID{component.NewID(component.MustType("mockforward"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewIDWithName(component.MustNewType("metrics"), "out"): { + Receivers: []component.ID{component.NewID(component.MustNewType("mockforward"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, - component.NewIDWithName(component.MustType("traces"), "out"): { - Receivers: []component.ID{component.NewID(component.MustType("mockforward"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewIDWithName(component.MustNewType("traces"), "out"): { + Receivers: []component.ID{component.NewID(component.MustNewType("mockforward"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: `connector "mockforward" used as receiver in traces pipeline but not used in any supported exporter pipeline`, @@ -1643,22 +1643,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_simple_cycle_traces.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName(component.MustType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustType("traces")): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, + component.NewID(component.MustNewType("traces")): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, }, }, expected: `cycle detected: ` + @@ -1669,22 +1669,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_simple_cycle_metrics.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName(component.MustType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustType("metrics")): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, + component.NewID(component.MustNewType("metrics")): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, }, }, expected: `cycle detected: ` + @@ -1695,22 +1695,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_simple_cycle_logs.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName(component.MustType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustType("logs")): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, + component.NewID(component.MustNewType("logs")): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, }, }, expected: `cycle detected: ` + @@ -1721,39 +1721,39 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_deep_cycle_traces.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName(component.MustType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustType("nop"), "conn1"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustType("nop"), "conn2"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("nop"), "conn1"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("nop"), "conn2"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, + component.NewIDWithName(component.MustNewType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, }, - component.NewIDWithName(component.MustType("traces"), "1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn1")}, + component.NewIDWithName(component.MustNewType("traces"), "1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn1")}, }, - component.NewIDWithName(component.MustType("traces"), "2"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn1")}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn2"), component.NewIDWithName(component.MustType("nop"), "conn")}, + component.NewIDWithName(component.MustNewType("traces"), "2"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn1")}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn2"), component.NewIDWithName(component.MustNewType("nop"), "conn")}, }, - component.NewIDWithName(component.MustType("traces"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn2")}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewIDWithName(component.MustNewType("traces"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn2")}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: `cycle detected: ` + @@ -1766,39 +1766,39 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_deep_cycle_metrics.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName(component.MustType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustType("nop"), "conn1"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustType("nop"), "conn2"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("nop"), "conn1"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("nop"), "conn2"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, + component.NewIDWithName(component.MustNewType("metrics"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, }, - component.NewIDWithName(component.MustType("metrics"), "1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn1")}, + component.NewIDWithName(component.MustNewType("metrics"), "1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn1")}, }, - component.NewIDWithName(component.MustType("metrics"), "2"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn1")}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn2"), component.NewIDWithName(component.MustType("nop"), "conn")}, + component.NewIDWithName(component.MustNewType("metrics"), "2"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn1")}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn2"), component.NewIDWithName(component.MustNewType("nop"), "conn")}, }, - component.NewIDWithName(component.MustType("metrics"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn2")}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewIDWithName(component.MustNewType("metrics"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn2")}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: `cycle detected: ` + @@ -1811,39 +1811,39 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_deep_cycle_logs.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName(component.MustType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustType("nop"), "conn1"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustType("nop"), "conn2"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("nop"), "conn1"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("nop"), "conn2"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustType("logs"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, + component.NewIDWithName(component.MustNewType("logs"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, }, - component.NewIDWithName(component.MustType("logs"), "1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn")}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn1")}, + component.NewIDWithName(component.MustNewType("logs"), "1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn1")}, }, - component.NewIDWithName(component.MustType("logs"), "2"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn1")}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn2"), component.NewIDWithName(component.MustType("nop"), "conn")}, + component.NewIDWithName(component.MustNewType("logs"), "2"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn1")}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn2"), component.NewIDWithName(component.MustNewType("nop"), "conn")}, }, - component.NewIDWithName(component.MustType("logs"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "conn2")}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewIDWithName(component.MustNewType("logs"), "out"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn2")}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: `cycle detected: ` + @@ -1856,55 +1856,55 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_deep_cycle_multi_signal.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName(component.MustType("nop"), "fork"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustType("nop"), "count"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustType("nop"), "forkagain"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustType("nop"), "rawlog"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("nop"), "fork"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("nop"), "count"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("nop"), "forkagain"): nopConnectorFactory.CreateDefaultConfig(), + component.NewIDWithName(component.MustNewType("nop"), "rawlog"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "fork")}, - }, - component.NewIDWithName(component.MustType("traces"), "copy1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "fork")}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "count")}, - }, - component.NewIDWithName(component.MustType("traces"), "copy2"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "fork")}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "forkagain")}, - }, - component.NewIDWithName(component.MustType("traces"), "copy2a"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "forkagain")}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "count")}, - }, - component.NewIDWithName(component.MustType("traces"), "copy2b"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "forkagain")}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "rawlog")}, - }, - component.NewIDWithName(component.MustType("metrics"), "count"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "count")}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, - }, - component.NewIDWithName(component.MustType("logs"), "raw"): { - Receivers: []component.ID{component.NewIDWithName(component.MustType("nop"), "rawlog")}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustType("nop"), "fork")}, // cannot loop back to "nop/fork" + component.NewIDWithName(component.MustNewType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "fork")}, + }, + component.NewIDWithName(component.MustNewType("traces"), "copy1"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "fork")}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "count")}, + }, + component.NewIDWithName(component.MustNewType("traces"), "copy2"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "fork")}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "forkagain")}, + }, + component.NewIDWithName(component.MustNewType("traces"), "copy2a"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "forkagain")}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "count")}, + }, + component.NewIDWithName(component.MustNewType("traces"), "copy2b"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "forkagain")}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "rawlog")}, + }, + component.NewIDWithName(component.MustNewType("metrics"), "count"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "count")}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + }, + component.NewIDWithName(component.MustNewType("logs"), "raw"): { + Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "rawlog")}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "fork")}, // cannot loop back to "nop/fork" }, }, expected: `cycle detected: ` + @@ -1919,15 +1919,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_exporter_config", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustType("traces")): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop")), component.NewIDWithName(component.MustType("nop"), "1")}, + component.NewID(component.MustNewType("traces")): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop")), component.NewIDWithName(component.MustNewType("nop"), "1")}, }, }, expected: "failed to create \"nop/1\" exporter for data type \"traces\": exporter \"nop/1\" is not configured", @@ -1935,15 +1935,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_exporter_factory", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("unknown")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("unknown")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustType("traces")): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("unknown"))}, + component.NewID(component.MustNewType("traces")): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("unknown"))}, }, }, expected: "failed to create \"unknown\" exporter for data type \"traces\": exporter factory not available for: \"unknown\"", @@ -1951,19 +1951,19 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_processor_config", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Processors: []component.ID{component.NewID(component.MustType("nop")), component.NewIDWithName(component.MustType("nop"), "1")}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewID(component.MustNewType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Processors: []component.ID{component.NewID(component.MustNewType("nop")), component.NewIDWithName(component.MustNewType("nop"), "1")}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "failed to create \"nop/1\" processor, in pipeline \"metrics\": processor \"nop/1\" is not configured", @@ -1971,19 +1971,19 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_processor_factory", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("unknown")): nopProcessorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("unknown")): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Processors: []component.ID{component.NewID(component.MustType("unknown"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewID(component.MustNewType("metrics")): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Processors: []component.ID{component.NewID(component.MustNewType("unknown"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "failed to create \"unknown\" processor, in pipeline \"metrics\": processor factory not available for: \"unknown\"", @@ -1991,15 +1991,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_receiver_config", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustType("logs")): { - Receivers: []component.ID{component.NewID(component.MustType("nop")), component.NewIDWithName(component.MustType("nop"), "1")}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewID(component.MustNewType("logs")): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop")), component.NewIDWithName(component.MustNewType("nop"), "1")}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "failed to create \"nop/1\" receiver for data type \"logs\": receiver \"nop/1\" is not configured", @@ -2007,15 +2007,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_receiver_factory", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("unknown")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("unknown")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustType("logs")): { - Receivers: []component.ID{component.NewID(component.MustType("unknown"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewID(component.MustNewType("logs")): { + Receivers: []component.ID{component.NewID(component.MustNewType("unknown"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "failed to create \"unknown\" receiver for data type \"logs\": receiver factory not available for: \"unknown\"", @@ -2023,22 +2023,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_connector_factory", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustType("unknown")): nopConnectorFactory.CreateDefaultConfig(), + component.NewID(component.MustNewType("unknown")): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("unknown"))}, + component.NewIDWithName(component.MustNewType("traces"), "in"): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("unknown"))}, }, - component.NewIDWithName(component.MustType("traces"), "out"): { - Receivers: []component.ID{component.NewID(component.MustType("unknown"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewIDWithName(component.MustNewType("traces"), "out"): { + Receivers: []component.ID{component.NewID(component.MustNewType("unknown"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, }, expected: "connector factory not available for: \"unknown\"", @@ -2141,9 +2141,9 @@ func TestGraphFailToStartAndShutdown(t *testing.T) { t.Run(dt.String()+"/receiver", func(t *testing.T) { set.PipelineConfigs = pipelines.Config{ component.NewID(dt): { - Receivers: []component.ID{component.NewID(component.MustType("nop")), component.NewID(component.MustType("err"))}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + Receivers: []component.ID{component.NewID(component.MustNewType("nop")), component.NewID(component.MustNewType("err"))}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, } pipelines, err := Build(context.Background(), set) @@ -2155,9 +2155,9 @@ func TestGraphFailToStartAndShutdown(t *testing.T) { t.Run(dt.String()+"/processor", func(t *testing.T) { set.PipelineConfigs = pipelines.Config{ component.NewID(dt): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Processors: []component.ID{component.NewID(component.MustType("nop")), component.NewID(component.MustType("err"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Processors: []component.ID{component.NewID(component.MustNewType("nop")), component.NewID(component.MustNewType("err"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, } pipelines, err := Build(context.Background(), set) @@ -2169,9 +2169,9 @@ func TestGraphFailToStartAndShutdown(t *testing.T) { t.Run(dt.String()+"/exporter", func(t *testing.T) { set.PipelineConfigs = pipelines.Config{ component.NewID(dt): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop")), component.NewID(component.MustType("err"))}, + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop")), component.NewID(component.MustNewType("err"))}, }, } pipelines, err := Build(context.Background(), set) @@ -2184,14 +2184,14 @@ func TestGraphFailToStartAndShutdown(t *testing.T) { t.Run(dt.String()+"/"+dt2.String()+"/connector", func(t *testing.T) { set.PipelineConfigs = pipelines.Config{ component.NewIDWithName(dt, "in"): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop")), component.NewIDWithName(component.MustType("err"), "conn")}, + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop")), component.NewIDWithName(component.MustNewType("err"), "conn")}, }, component.NewIDWithName(dt2, "out"): { - Receivers: []component.ID{component.NewID(component.MustType("nop")), component.NewIDWithName(component.MustType("err"), "conn")}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + Receivers: []component.ID{component.NewID(component.MustNewType("nop")), component.NewIDWithName(component.MustNewType("err"), "conn")}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, } pipelines, err := Build(context.Background(), set) @@ -2205,13 +2205,13 @@ func TestGraphFailToStartAndShutdown(t *testing.T) { func TestStatusReportedOnStartupShutdown(t *testing.T) { - rNoErr := &testNode{id: component.NewIDWithName(component.MustType("r_no_err"), "1")} - rStErr := &testNode{id: component.NewIDWithName(component.MustType("r_st_err"), "1"), startErr: assert.AnError} - rSdErr := &testNode{id: component.NewIDWithName(component.MustType("r_sd_err"), "1"), shutdownErr: assert.AnError} + rNoErr := &testNode{id: component.NewIDWithName(component.MustNewType("r_no_err"), "1")} + rStErr := &testNode{id: component.NewIDWithName(component.MustNewType("r_st_err"), "1"), startErr: assert.AnError} + rSdErr := &testNode{id: component.NewIDWithName(component.MustNewType("r_sd_err"), "1"), shutdownErr: assert.AnError} - eNoErr := &testNode{id: component.NewIDWithName(component.MustType("e_no_err"), "1")} - eStErr := &testNode{id: component.NewIDWithName(component.MustType("e_st_err"), "1"), startErr: assert.AnError} - eSdErr := &testNode{id: component.NewIDWithName(component.MustType("e_sd_err"), "1"), shutdownErr: assert.AnError} + eNoErr := &testNode{id: component.NewIDWithName(component.MustNewType("e_no_err"), "1")} + eStErr := &testNode{id: component.NewIDWithName(component.MustNewType("e_st_err"), "1"), startErr: assert.AnError} + eSdErr := &testNode{id: component.NewIDWithName(component.MustNewType("e_sd_err"), "1"), shutdownErr: assert.AnError} instanceIDs := map[*testNode]*component.InstanceID{ rNoErr: {ID: rNoErr.id}, @@ -2390,7 +2390,7 @@ func (g *Graph) getReceivers() map[component.DataType]map[component.ID]component // - E instances of the connector as a receiver. // - R instances of the connector as an exporter. func expectedInstances(m pipelines.Config, pID component.ID) (int, int) { - exConnectorType := component.MustType("exampleconnector") + exConnectorType := component.MustNewType("exampleconnector") var r, e int for _, rID := range m[pID].Receivers { if rID.Type() != exConnectorType { @@ -2430,31 +2430,31 @@ func expectedInstances(m pipelines.Config, pID component.ID) (int, int) { } func newBadReceiverFactory() receiver.Factory { - return receiver.NewFactory(component.MustType("bf"), func() component.Config { + return receiver.NewFactory(component.MustNewType("bf"), func() component.Config { return &struct{}{} }) } func newBadProcessorFactory() processor.Factory { - return processor.NewFactory(component.MustType("bf"), func() component.Config { + return processor.NewFactory(component.MustNewType("bf"), func() component.Config { return &struct{}{} }) } func newBadExporterFactory() exporter.Factory { - return exporter.NewFactory(component.MustType("bf"), func() component.Config { + return exporter.NewFactory(component.MustNewType("bf"), func() component.Config { return &struct{}{} }) } func newBadConnectorFactory() connector.Factory { - return connector.NewFactory(component.MustType("bf"), func() component.Config { + return connector.NewFactory(component.MustNewType("bf"), func() component.Config { return &struct{}{} }) } func newErrReceiverFactory() receiver.Factory { - return receiver.NewFactory(component.MustType("err"), + return receiver.NewFactory(component.MustNewType("err"), func() component.Config { return &struct{}{} }, receiver.WithTraces(func(context.Context, receiver.CreateSettings, component.Config, consumer.Traces) (receiver.Traces, error) { return &errComponent{}, nil @@ -2469,7 +2469,7 @@ func newErrReceiverFactory() receiver.Factory { } func newErrProcessorFactory() processor.Factory { - return processor.NewFactory(component.MustType("err"), + return processor.NewFactory(component.MustNewType("err"), func() component.Config { return &struct{}{} }, processor.WithTraces(func(context.Context, processor.CreateSettings, component.Config, consumer.Traces) (processor.Traces, error) { return &errComponent{}, nil @@ -2484,7 +2484,7 @@ func newErrProcessorFactory() processor.Factory { } func newErrExporterFactory() exporter.Factory { - return exporter.NewFactory(component.MustType("err"), + return exporter.NewFactory(component.MustNewType("err"), func() component.Config { return &struct{}{} }, exporter.WithTraces(func(context.Context, exporter.CreateSettings, component.Config) (exporter.Traces, error) { return &errComponent{}, nil @@ -2499,7 +2499,7 @@ func newErrExporterFactory() exporter.Factory { } func newErrConnectorFactory() connector.Factory { - return connector.NewFactory(component.MustType("err"), func() component.Config { + return connector.NewFactory(component.MustNewType("err"), func() component.Config { return &struct{}{} }, connector.WithTracesToTraces(func(context.Context, connector.CreateSettings, component.Config, consumer.Traces) (connector.Traces, error) { diff --git a/service/internal/testcomponents/example_connector.go b/service/internal/testcomponents/example_connector.go index d5dde3d8e93..75c5145cf7b 100644 --- a/service/internal/testcomponents/example_connector.go +++ b/service/internal/testcomponents/example_connector.go @@ -15,7 +15,7 @@ import ( "go.opentelemetry.io/collector/pdata/ptrace" ) -var connType = component.MustType("exampleconnector") +var connType = component.MustNewType("exampleconnector") // ExampleConnectorFactory is factory for ExampleConnector. var ExampleConnectorFactory = connector.NewFactory( @@ -36,7 +36,7 @@ var ExampleConnectorFactory = connector.NewFactory( ) var MockForwardConnectorFactory = connector.NewFactory( - component.MustType("mockforward"), + component.MustNewType("mockforward"), createExampleConnectorDefaultConfig, connector.WithTracesToTraces(createExampleTracesToTraces, component.StabilityLevelDevelopment), connector.WithMetricsToMetrics(createExampleMetricsToMetrics, component.StabilityLevelDevelopment), diff --git a/service/internal/testcomponents/example_exporter.go b/service/internal/testcomponents/example_exporter.go index f6bc66d8456..653a2ad4a47 100644 --- a/service/internal/testcomponents/example_exporter.go +++ b/service/internal/testcomponents/example_exporter.go @@ -14,7 +14,7 @@ import ( "go.opentelemetry.io/collector/pdata/ptrace" ) -var testType = component.MustType("exampleexporter") +var testType = component.MustNewType("exampleexporter") const stability = component.StabilityLevelDevelopment diff --git a/service/internal/testcomponents/example_processor.go b/service/internal/testcomponents/example_processor.go index bf245d6bea0..9f73611853b 100644 --- a/service/internal/testcomponents/example_processor.go +++ b/service/internal/testcomponents/example_processor.go @@ -11,7 +11,7 @@ import ( "go.opentelemetry.io/collector/processor" ) -var procType = component.MustType("exampleprocessor") +var procType = component.MustNewType("exampleprocessor") // ExampleProcessorFactory is factory for ExampleProcessor. var ExampleProcessorFactory = processor.NewFactory( diff --git a/service/internal/testcomponents/example_receiver.go b/service/internal/testcomponents/example_receiver.go index 5091513fab2..34b0372b03b 100644 --- a/service/internal/testcomponents/example_receiver.go +++ b/service/internal/testcomponents/example_receiver.go @@ -11,7 +11,7 @@ import ( "go.opentelemetry.io/collector/receiver" ) -var receiverType = component.MustType("examplereceiver") +var receiverType = component.MustNewType("examplereceiver") // ExampleReceiverFactory is factory for ExampleReceiver. var ExampleReceiverFactory = receiver.NewFactory( diff --git a/service/internal/testcomponents/example_router.go b/service/internal/testcomponents/example_router.go index e3c5d7ed8f5..3eafbf13cb6 100644 --- a/service/internal/testcomponents/example_router.go +++ b/service/internal/testcomponents/example_router.go @@ -14,7 +14,7 @@ import ( "go.opentelemetry.io/collector/pdata/ptrace" ) -var routerType = component.MustType("examplerouter") +var routerType = component.MustNewType("examplerouter") // ExampleRouterFactory is factory for ExampleRouter. var ExampleRouterFactory = connector.NewFactory( diff --git a/service/internal/testcomponents/example_router_test.go b/service/internal/testcomponents/example_router_test.go index 8f011641a6a..71e368a4c5f 100644 --- a/service/internal/testcomponents/example_router_test.go +++ b/service/internal/testcomponents/example_router_test.go @@ -31,8 +31,8 @@ func TestExampleRouter(t *testing.T) { } func TestTracesRouter(t *testing.T) { - leftID := component.NewIDWithName(component.MustType("sink"), "left") - rightID := component.NewIDWithName(component.MustType("sink"), "right") + leftID := component.NewIDWithName(component.MustNewType("sink"), "left") + rightID := component.NewIDWithName(component.MustNewType("sink"), "right") sinkLeft := new(consumertest.TracesSink) sinkRight := new(consumertest.TracesSink) @@ -70,8 +70,8 @@ func TestTracesRouter(t *testing.T) { } func TestMetricsRouter(t *testing.T) { - leftID := component.NewIDWithName(component.MustType("sink"), "left") - rightID := component.NewIDWithName(component.MustType("sink"), "right") + leftID := component.NewIDWithName(component.MustNewType("sink"), "left") + rightID := component.NewIDWithName(component.MustNewType("sink"), "right") sinkLeft := new(consumertest.MetricsSink) sinkRight := new(consumertest.MetricsSink) @@ -109,8 +109,8 @@ func TestMetricsRouter(t *testing.T) { } func TestLogsRouter(t *testing.T) { - leftID := component.NewIDWithName(component.MustType("sink"), "left") - rightID := component.NewIDWithName(component.MustType("sink"), "right") + leftID := component.NewIDWithName(component.MustNewType("sink"), "left") + rightID := component.NewIDWithName(component.MustNewType("sink"), "right") sinkLeft := new(consumertest.LogsSink) sinkRight := new(consumertest.LogsSink) diff --git a/service/pipelines/config_test.go b/service/pipelines/config_test.go index c5cbc73aff5..c9aa6d7b3fa 100644 --- a/service/pipelines/config_test.go +++ b/service/pipelines/config_test.go @@ -28,7 +28,7 @@ func TestConfigValidate(t *testing.T) { name: "duplicate-processor-reference", cfgFn: func() Config { cfg := generateConfig() - pipe := cfg[component.NewID(component.MustType("traces"))] + pipe := cfg[component.NewID(component.MustNewType("traces"))] pipe.Processors = append(pipe.Processors, pipe.Processors...) return cfg }, @@ -38,7 +38,7 @@ func TestConfigValidate(t *testing.T) { name: "missing-pipeline-receivers", cfgFn: func() Config { cfg := generateConfig() - cfg[component.NewID(component.MustType("traces"))].Receivers = nil + cfg[component.NewID(component.MustNewType("traces"))].Receivers = nil return cfg }, expected: fmt.Errorf(`pipeline "traces": %w`, errMissingServicePipelineReceivers), @@ -47,7 +47,7 @@ func TestConfigValidate(t *testing.T) { name: "missing-pipeline-exporters", cfgFn: func() Config { cfg := generateConfig() - cfg[component.NewID(component.MustType("traces"))].Exporters = nil + cfg[component.NewID(component.MustNewType("traces"))].Exporters = nil return cfg }, expected: fmt.Errorf(`pipeline "traces": %w`, errMissingServicePipelineExporters), @@ -63,10 +63,10 @@ func TestConfigValidate(t *testing.T) { name: "invalid-service-pipeline-type", cfgFn: func() Config { cfg := generateConfig() - cfg[component.NewID(component.MustType("wrongtype"))] = &PipelineConfig{ - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + cfg[component.NewID(component.MustNewType("wrongtype"))] = &PipelineConfig{ + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, } return cfg }, @@ -84,10 +84,10 @@ func TestConfigValidate(t *testing.T) { func generateConfig() Config { return map[component.ID]*PipelineConfig{ - component.NewID(component.MustType("traces")): { - Receivers: []component.ID{component.NewID(component.MustType("nop"))}, - Processors: []component.ID{component.NewID(component.MustType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustType("nop"))}, + component.NewID(component.MustNewType("traces")): { + Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, + Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, + Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, }, } } diff --git a/service/service_test.go b/service/service_test.go index 16e9a2bda11..b26a4d2926d 100644 --- a/service/service_test.go +++ b/service/service_test.go @@ -169,8 +169,8 @@ func ownMetricsTestCases() []ownMetricsTestCase { } var ( - nopType = component.MustType("nop") - wrongType = component.MustType("wrong") + nopType = component.MustNewType("nop") + wrongType = component.MustNewType("wrong") ) func TestServiceGetFactory(t *testing.T) { @@ -240,7 +240,7 @@ func TestServiceGetExporters(t *testing.T) { // and another service with a valid config can be started right after. func TestServiceTelemetryCleanupOnError(t *testing.T) { invalidCfg := newNopConfig() - invalidCfg.Pipelines[component.NewID(component.MustType("traces"))].Processors[0] = component.NewID(component.MustType("invalid")) + invalidCfg.Pipelines[component.NewID(component.MustNewType("traces"))].Processors[0] = component.NewID(component.MustNewType("invalid")) // Create a service with an invalid config and expect an error _, err := New(context.Background(), newNopSettings(), invalidCfg) require.Error(t, err) @@ -275,12 +275,12 @@ func testCollectorStartHelper(t *testing.T, tc ownMetricsTestCase) { set := newNopSettings() set.BuildInfo = component.BuildInfo{Version: "test version", Command: otelCommand} set.Extensions = extension.NewBuilder( - map[component.ID]component.Config{component.NewID(component.MustType("zpages")): &zpagesextension.Config{TCPAddr: confignet.TCPAddr{Endpoint: zpagesAddr}}}, - map[component.Type]extension.Factory{component.MustType("zpages"): zpagesextension.NewFactory()}) + map[component.ID]component.Config{component.NewID(component.MustNewType("zpages")): &zpagesextension.Config{TCPAddr: confignet.TCPAddr{Endpoint: zpagesAddr}}}, + map[component.Type]extension.Factory{component.MustNewType("zpages"): zpagesextension.NewFactory()}) set.LoggingOptions = []zap.Option{zap.Hooks(hook)} cfg := newNopConfig() - cfg.Extensions = []component.ID{component.NewID(component.MustType("zpages"))} + cfg.Extensions = []component.ID{component.NewID(component.MustNewType("zpages"))} cfg.Telemetry.Metrics.Address = metricsAddr cfg.Telemetry.Resource = make(map[string]*string) // Include resource attributes under the service::telemetry::resource key. @@ -356,7 +356,7 @@ func TestExtensionNotificationFailure(t *testing.T) { set := newNopSettings() cfg := newNopConfig() - var extName = component.MustType("configWatcher") + var extName = component.MustNewType("configWatcher") configWatcherExtensionFactory := newConfigWatcherExtensionFactory(extName) set.Extensions = extension.NewBuilder( map[component.ID]component.Config{component.NewID(extName): configWatcherExtensionFactory.CreateDefaultConfig()}, @@ -379,7 +379,7 @@ func TestNilCollectorEffectiveConfig(t *testing.T) { set.CollectorConf = nil cfg := newNopConfig() - var extName = component.MustType("configWatcher") + var extName = component.MustNewType("configWatcher") configWatcherExtensionFactory := newConfigWatcherExtensionFactory(extName) set.Extensions = extension.NewBuilder( map[component.ID]component.Config{component.NewID(extName): configWatcherExtensionFactory.CreateDefaultConfig()}, @@ -532,17 +532,17 @@ func newNopSettings() Settings { func newNopConfig() Config { return newNopConfigPipelineConfigs(pipelines.Config{ - component.NewID(component.MustType("traces")): { + component.NewID(component.MustNewType("traces")): { Receivers: []component.ID{component.NewID(nopType)}, Processors: []component.ID{component.NewID(nopType)}, Exporters: []component.ID{component.NewID(nopType)}, }, - component.NewID(component.MustType("metrics")): { + component.NewID(component.MustNewType("metrics")): { Receivers: []component.ID{component.NewID(nopType)}, Processors: []component.ID{component.NewID(nopType)}, Exporters: []component.ID{component.NewID(nopType)}, }, - component.NewID(component.MustType("logs")): { + component.NewID(component.MustNewType("logs")): { Receivers: []component.ID{component.NewID(nopType)}, Processors: []component.ID{component.NewID(nopType)}, Exporters: []component.ID{component.NewID(nopType)}, From 2367d4117283da7b7e5595b02e99b1b1b8d38544 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Tue, 30 Jan 2024 13:29:31 +0100 Subject: [PATCH 08/13] Add component.MustNewID and component.MustNewIDWithName To make the change I ran: - rg 'component.NewID\(component.MustNewType\(.*?\)\)' -l | xargs sd 'component.NewID\(component.MustNewType\((".*?")\)\)' 'component.MustNewID($1)' - rg 'component.NewIDWithName\(component.MustNewType\(.*?\), .*?\)' -l | xargs sd 'component.NewIDWithName\(component.MustNewType\((.*?)\), (.*?)\)' 'component.MustNewIDWithName($1, $2)' --- .../otelprometheuschecker_test.go | 8 +- component/identifiable.go | 12 + config/configauth/configauth_test.go | 6 +- config/configgrpc/configgrpc_test.go | 8 +- config/confighttp/confighttp_test.go | 8 +- connector/connector_test.go | 22 +- connector/logs_router_test.go | 8 +- connector/metrics_router_test.go | 8 +- connector/traces_router_test.go | 8 +- exporter/exporter_test.go | 16 +- .../internal/persistent_queue_test.go | 10 +- exporter/exporterhelper/logs_test.go | 6 +- exporter/exporterhelper/metrics_test.go | 6 +- exporter/exporterhelper/obsexporter_test.go | 2 +- exporter/exporterhelper/obsreport_test.go | 2 +- exporter/exporterhelper/queue_sender_test.go | 6 +- exporter/exporterhelper/traces_test.go | 6 +- exporter/otlpexporter/config_test.go | 2 +- extension/extension_test.go | 8 +- internal/memorylimiter/memorylimiter_test.go | 2 +- .../sharedcomponent/sharedcomponent_test.go | 2 +- otelcol/config_test.go | 72 +- otelcol/otelcoltest/config_test.go | 28 +- processor/batchprocessor/metrics_test.go | 2 +- .../memorylimiter_test.go | 2 +- processor/processor_test.go | 16 +- processor/processorhelper/obsreport_test.go | 2 +- .../otlpreceiver/internal/logs/otlp_test.go | 2 +- .../internal/metrics/otlp_test.go | 2 +- .../otlpreceiver/internal/trace/otlp_test.go | 2 +- receiver/otlpreceiver/otlp_test.go | 2 +- receiver/receiver_test.go | 16 +- receiver/receiverhelper/obsreport_test.go | 2 +- receiver/scraperhelper/obsreport_test.go | 4 +- .../scraperhelper/scrapercontroller_test.go | 4 +- service/config_test.go | 20 +- service/extensions/extensions_test.go | 28 +- service/internal/graph/graph_test.go | 1404 ++++++++--------- .../testcomponents/example_router_test.go | 12 +- service/pipelines/config_test.go | 22 +- service/service_test.go | 12 +- 41 files changed, 911 insertions(+), 899 deletions(-) diff --git a/component/componenttest/otelprometheuschecker_test.go b/component/componenttest/otelprometheuschecker_test.go index 9c1691197f7..d7176134f54 100644 --- a/component/componenttest/otelprometheuschecker_test.go +++ b/component/componenttest/otelprometheuschecker_test.go @@ -36,10 +36,10 @@ func TestPromChecker(t *testing.T) { pc, err := newStubPromChecker() require.NoError(t, err) - scraper := component.NewID(component.MustNewType("fakeScraper")) - receiver := component.NewID(component.MustNewType("fakeReceiver")) - processor := component.NewID(component.MustNewType("fakeProcessor")) - exporter := component.NewID(component.MustNewType("fakeExporter")) + scraper := component.MustNewID("fakeScraper") + receiver := component.MustNewID("fakeReceiver") + processor := component.MustNewID("fakeProcessor") + exporter := component.MustNewID("fakeExporter") transport := "fakeTransport" assert.NoError(t, diff --git a/component/identifiable.go b/component/identifiable.go index f57aa10c1af..90dc64c8dd1 100644 --- a/component/identifiable.go +++ b/component/identifiable.go @@ -26,11 +26,23 @@ func NewID(typeVal Type) ID { return ID{typeVal: typeVal} } +// NewID builds a Type and returns a new ID with the given Type and empty name. +// See MustNewType to check the valid values of typeVal. +func MustNewID(typeVal string) ID { + return ID{typeVal: MustNewType(typeVal)} +} + // NewIDWithName returns a new ID with the given Type and name. func NewIDWithName(typeVal Type, nameVal string) ID { return ID{typeVal: typeVal, nameVal: nameVal} } +// MustNewIDWithName builds a Type and returns a new ID with the given Type and name. +// See MustNewType to check the valid values of typeVal. +func MustNewIDWithName(typeVal string, nameVal string) ID { + return ID{typeVal: MustNewType(typeVal), nameVal: nameVal} +} + // Type returns the type of the component. func (id ID) Type() Type { return id.typeVal diff --git a/config/configauth/configauth_test.go b/config/configauth/configauth_test.go index 0383df9a8e1..43c84ceb497 100644 --- a/config/configauth/configauth_test.go +++ b/config/configauth/configauth_test.go @@ -13,7 +13,7 @@ import ( "go.opentelemetry.io/collector/extension/auth" ) -var mockID = component.NewID(component.MustNewType("mock")) +var mockID = component.MustNewID("mock") func TestGetServer(t *testing.T) { testCases := []struct { @@ -58,7 +58,7 @@ func TestGetServer(t *testing.T) { func TestGetServerFails(t *testing.T) { cfg := &Authentication{ - AuthenticatorID: component.NewID(component.MustNewType("does_not_exist")), + AuthenticatorID: component.MustNewID("does_not_exist"), } authenticator, err := cfg.GetServerAuthenticator(map[component.ID]component.Component{}) @@ -109,7 +109,7 @@ func TestGetClient(t *testing.T) { func TestGetClientFails(t *testing.T) { cfg := &Authentication{ - AuthenticatorID: component.NewID(component.MustNewType("does_not_exist")), + AuthenticatorID: component.MustNewID("does_not_exist"), } authenticator, err := cfg.GetClientAuthenticator(map[component.ID]component.Component{}) assert.ErrorIs(t, err, errAuthenticatorNotFound) diff --git a/config/configgrpc/configgrpc_test.go b/config/configgrpc/configgrpc_test.go index 2a524ba6615..74a5650c55f 100644 --- a/config/configgrpc/configgrpc_test.go +++ b/config/configgrpc/configgrpc_test.go @@ -51,10 +51,10 @@ func init() { } var ( - componentID = component.NewID(component.MustNewType("component")) - testAuthID = component.NewID(component.MustNewType("testauth")) - mockID = component.NewID(component.MustNewType("mock")) - doesntExistID = component.NewID(component.MustNewType("doesntexist")) + componentID = component.MustNewID("component") + testAuthID = component.MustNewID("testauth") + mockID = component.MustNewID("mock") + doesntExistID = component.MustNewID("doesntexist") ) func TestDefaultGrpcClientSettings(t *testing.T) { diff --git a/config/confighttp/confighttp_test.go b/config/confighttp/confighttp_test.go index 44beebe9582..0edc4e9aaf1 100644 --- a/config/confighttp/confighttp_test.go +++ b/config/confighttp/confighttp_test.go @@ -43,10 +43,10 @@ func (c *customRoundTripper) RoundTrip(_ *http.Request) (*http.Response, error) } var ( - testAuthID = component.NewID(component.MustNewType("testauth")) - mockID = component.NewID(component.MustNewType("mock")) - dummyID = component.NewID(component.MustNewType("dummy")) - nonExistingID = component.NewID(component.MustNewType("nonexisting")) + testAuthID = component.MustNewID("testauth") + mockID = component.MustNewID("mock") + dummyID = component.MustNewID("dummy") + nonExistingID = component.MustNewID("nonexisting") ) func TestAllHTTPClientSettings(t *testing.T) { diff --git a/connector/connector_test.go b/connector/connector_test.go index ee46b57312d..851add885d7 100644 --- a/connector/connector_test.go +++ b/connector/connector_test.go @@ -19,7 +19,7 @@ import ( var ( testType = component.MustNewType("test") - testID = component.NewIDWithName(component.MustNewType("type"), "name") + testID = component.MustNewIDWithName("type", "name") ) func TestNewFactoryNoOptions(t *testing.T) { @@ -242,28 +242,28 @@ func TestBuilder(t *testing.T) { }{ { name: "unknown", - id: component.NewID(component.MustNewType("unknown")), + id: component.MustNewID("unknown"), err: func(_, _ component.DataType) string { return "connector factory not available for: \"unknown\"" }, }, { name: "err", - id: component.NewID(component.MustNewType("err")), + id: component.MustNewID("err"), err: func(expType, rcvType component.DataType) string { return fmt.Sprintf("connector \"err\" cannot connect from %s to %s: telemetry type is not supported", expType, rcvType) }, }, { name: "all", - id: component.NewID(component.MustNewType("all")), + id: component.MustNewID("all"), err: func(_, _ component.DataType) string { return "" }, }, { name: "all/named", - id: component.NewIDWithName(component.MustNewType("all"), "named"), + id: component.MustNewIDWithName("all", "named"), err: func(_, _ component.DataType) string { return "" }, @@ -378,7 +378,7 @@ func TestBuilderMissingConfig(t *testing.T) { require.NoError(t, err) bErr := NewBuilder(map[component.ID]component.Config{}, factories) - missingID := component.NewIDWithName(component.MustNewType("all"), "missing") + missingID := component.MustNewIDWithName("all", "missing") t2t, err := bErr.CreateTracesToTraces(context.Background(), createSettings(missingID), nil) assert.EqualError(t, err, "connector \"all/missing\" is not configured") @@ -421,14 +421,14 @@ func TestBuilderGetters(t *testing.T) { factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustNewType("foo"), nil)}...) require.NoError(t, err) - cfgs := map[component.ID]component.Config{component.NewID(component.MustNewType("foo")): struct{}{}} + cfgs := map[component.ID]component.Config{component.MustNewID("foo"): struct{}{}} b := NewBuilder(cfgs, factories) - assert.True(t, b.IsConfigured(component.NewID(component.MustNewType("foo")))) - assert.False(t, b.IsConfigured(component.NewID(component.MustNewType("bar")))) + assert.True(t, b.IsConfigured(component.MustNewID("foo"))) + assert.False(t, b.IsConfigured(component.MustNewID("bar"))) - assert.NotNil(t, b.Factory(component.NewID(component.MustNewType("foo")).Type())) - assert.Nil(t, b.Factory(component.NewID(component.MustNewType("bar")).Type())) + assert.NotNil(t, b.Factory(component.MustNewID("foo").Type())) + assert.Nil(t, b.Factory(component.MustNewID("bar").Type())) } var nopInstance = &nopConnector{ diff --git a/connector/logs_router_test.go b/connector/logs_router_test.go index c4be9f2d205..accce0a03cd 100644 --- a/connector/logs_router_test.go +++ b/connector/logs_router_test.go @@ -48,7 +48,7 @@ func fuzzLogs(numIDs, numCons, numLogs int) func(*testing.T) { // If any consumer is mutating, the router must report mutating for i := 0; i < numCons; i++ { - allIDs = append(allIDs, component.NewIDWithName(component.MustNewType("sink"), strconv.Itoa(numCons))) + allIDs = append(allIDs, component.MustNewIDWithName("sink", strconv.Itoa(numCons))) // Random chance for each consumer to be mutating if (numCons+numLogs+i)%4 == 0 { allCons = append(allCons, &mutatingLogsSink{LogsSink: new(consumertest.LogsSink)}) @@ -108,8 +108,8 @@ func TestLogsRouterConsumers(t *testing.T) { ctx := context.Background() ld := testdata.GenerateLogs(1) - fooID := component.NewID(component.MustNewType("foo")) - barID := component.NewID(component.MustNewType("bar")) + fooID := component.MustNewID("foo") + barID := component.MustNewID("bar") foo := new(consumertest.LogsSink) bar := new(consumertest.LogsSink) @@ -150,7 +150,7 @@ func TestLogsRouterConsumers(t *testing.T) { assert.Nil(t, none) assert.Error(t, err) - fake, err := r.Consumer(component.NewID(component.MustNewType("fake"))) + fake, err := r.Consumer(component.MustNewID("fake")) assert.Nil(t, fake) assert.Error(t, err) } diff --git a/connector/metrics_router_test.go b/connector/metrics_router_test.go index 196d5214868..62dd54c11e0 100644 --- a/connector/metrics_router_test.go +++ b/connector/metrics_router_test.go @@ -48,7 +48,7 @@ func fuzzMetrics(numIDs, numCons, numMetrics int) func(*testing.T) { // If any consumer is mutating, the router must report mutating for i := 0; i < numCons; i++ { - allIDs = append(allIDs, component.NewIDWithName(component.MustNewType("sink"), strconv.Itoa(numCons))) + allIDs = append(allIDs, component.MustNewIDWithName("sink", strconv.Itoa(numCons))) // Random chance for each consumer to be mutating if (numCons+numMetrics+i)%4 == 0 { allCons = append(allCons, &mutatingMetricsSink{MetricsSink: new(consumertest.MetricsSink)}) @@ -108,8 +108,8 @@ func TestMetricsRouterConsumers(t *testing.T) { ctx := context.Background() md := testdata.GenerateMetrics(1) - fooID := component.NewID(component.MustNewType("foo")) - barID := component.NewID(component.MustNewType("bar")) + fooID := component.MustNewID("foo") + barID := component.MustNewID("bar") foo := new(consumertest.MetricsSink) bar := new(consumertest.MetricsSink) @@ -150,7 +150,7 @@ func TestMetricsRouterConsumers(t *testing.T) { assert.Nil(t, none) assert.Error(t, err) - fake, err := r.Consumer(component.NewID(component.MustNewType("fake"))) + fake, err := r.Consumer(component.MustNewID("fake")) assert.Nil(t, fake) assert.Error(t, err) } diff --git a/connector/traces_router_test.go b/connector/traces_router_test.go index 3e7822fbfdc..33a2124ed3e 100644 --- a/connector/traces_router_test.go +++ b/connector/traces_router_test.go @@ -48,7 +48,7 @@ func fuzzTraces(numIDs, numCons, numTraces int) func(*testing.T) { // If any consumer is mutating, the router must report mutating for i := 0; i < numCons; i++ { - allIDs = append(allIDs, component.NewIDWithName(component.MustNewType("sink"), strconv.Itoa(numCons))) + allIDs = append(allIDs, component.MustNewIDWithName("sink", strconv.Itoa(numCons))) // Random chance for each consumer to be mutating if (numCons+numTraces+i)%4 == 0 { allCons = append(allCons, &mutatingTracesSink{TracesSink: new(consumertest.TracesSink)}) @@ -108,8 +108,8 @@ func TestTracesRouterConsumer(t *testing.T) { ctx := context.Background() td := testdata.GenerateTraces(1) - fooID := component.NewID(component.MustNewType("foo")) - barID := component.NewID(component.MustNewType("bar")) + fooID := component.MustNewID("foo") + barID := component.MustNewID("bar") foo := new(consumertest.TracesSink) bar := new(consumertest.TracesSink) @@ -150,7 +150,7 @@ func TestTracesRouterConsumer(t *testing.T) { assert.Nil(t, none) assert.Error(t, err) - fake, err := r.Consumer(component.NewID(component.MustNewType("fake"))) + fake, err := r.Consumer(component.MustNewID("fake")) assert.Nil(t, fake) assert.Error(t, err) } diff --git a/exporter/exporter_test.go b/exporter/exporter_test.go index 45fb0f7d2ad..108e55fb582 100644 --- a/exporter/exporter_test.go +++ b/exporter/exporter_test.go @@ -115,21 +115,21 @@ func TestBuilder(t *testing.T) { }{ { name: "unknown", - id: component.NewID(component.MustNewType("unknown")), + id: component.MustNewID("unknown"), err: "exporter factory not available for: \"unknown\"", }, { name: "err", - id: component.NewID(component.MustNewType("err")), + id: component.MustNewID("err"), err: "telemetry type is not supported", }, { name: "all", - id: component.NewID(component.MustNewType("all")), + id: component.MustNewID("all"), }, { name: "all/named", - id: component.NewIDWithName(component.MustNewType("all"), "named"), + id: component.MustNewIDWithName("all", "named"), }, } @@ -183,7 +183,7 @@ func TestBuilderMissingConfig(t *testing.T) { require.NoError(t, err) bErr := NewBuilder(map[component.ID]component.Config{}, factories) - missingID := component.NewIDWithName(component.MustNewType("all"), "missing") + missingID := component.MustNewIDWithName("all", "missing") te, err := bErr.CreateTraces(context.Background(), createSettings(missingID)) assert.EqualError(t, err, "exporter \"all/missing\" is not configured") @@ -202,11 +202,11 @@ func TestBuilderFactory(t *testing.T) { factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustNewType("foo"), nil)}...) require.NoError(t, err) - cfgs := map[component.ID]component.Config{component.NewID(component.MustNewType("foo")): struct{}{}} + cfgs := map[component.ID]component.Config{component.MustNewID("foo"): struct{}{}} b := NewBuilder(cfgs, factories) - assert.NotNil(t, b.Factory(component.NewID(component.MustNewType("foo")).Type())) - assert.Nil(t, b.Factory(component.NewID(component.MustNewType("bar")).Type())) + assert.NotNil(t, b.Factory(component.MustNewID("foo").Type())) + assert.Nil(t, b.Factory(component.MustNewID("bar").Type())) } var nopInstance = &nopExporter{ diff --git a/exporter/exporterhelper/internal/persistent_queue_test.go b/exporter/exporterhelper/internal/persistent_queue_test.go index b92e3c325b6..8b74f9a5fac 100644 --- a/exporter/exporterhelper/internal/persistent_queue_test.go +++ b/exporter/exporterhelper/internal/persistent_queue_test.go @@ -293,14 +293,14 @@ func TestToStorageClient(t *testing.T) { for _, tC := range testCases { t.Run(tC.desc, func(t *testing.T) { - storageID := component.NewIDWithName(component.MustNewType("file_storage"), strconv.Itoa(tC.storageIndex)) + storageID := component.MustNewIDWithName("file_storage", strconv.Itoa(tC.storageIndex)) var extensions = map[component.ID]component.Component{} for i := 0; i < tC.numStorages; i++ { - extensions[component.NewIDWithName(component.MustNewType("file_storage"), strconv.Itoa(i))] = NewMockStorageExtension(tC.getClientError) + extensions[component.MustNewIDWithName("file_storage", strconv.Itoa(i))] = NewMockStorageExtension(tC.getClientError) } host := &mockHost{ext: extensions} - ownerID := component.NewID(component.MustNewType("foo_exporter")) + ownerID := component.MustNewID("foo_exporter") // execute client, err := toStorageClient(context.Background(), storageID, host, ownerID, component.DataTypeTraces) @@ -318,7 +318,7 @@ func TestToStorageClient(t *testing.T) { } func TestInvalidStorageExtensionType(t *testing.T) { - storageID := component.NewIDWithName(component.MustNewType("extension"), "extension") + storageID := component.MustNewIDWithName("extension", "extension") // make a test extension factory := extensiontest.NewNopFactory() @@ -330,7 +330,7 @@ func TestInvalidStorageExtensionType(t *testing.T) { storageID: extension, } host := &mockHost{ext: extensions} - ownerID := component.NewID(component.MustNewType("foo_exporter")) + ownerID := component.MustNewID("foo_exporter") // execute client, err := toStorageClient(context.Background(), storageID, host, ownerID, component.DataTypeTraces) diff --git a/exporter/exporterhelper/logs_test.go b/exporter/exporterhelper/logs_test.go index e4e9f2306d0..5349f767398 100644 --- a/exporter/exporterhelper/logs_test.go +++ b/exporter/exporterhelper/logs_test.go @@ -37,7 +37,7 @@ const ( ) var ( - fakeLogsExporterName = component.NewIDWithName(component.MustNewType("fake_logs_exporter"), "with_name") + fakeLogsExporterName = component.MustNewIDWithName("fake_logs_exporter", "with_name") fakeLogsExporterConfig = struct{}{} ) @@ -157,12 +157,12 @@ func TestLogsRequestExporter_Default_ExportError(t *testing.T) { func TestLogsExporter_WithPersistentQueue(t *testing.T) { qCfg := NewDefaultQueueSettings() - storageID := component.NewIDWithName(component.MustNewType("file_storage"), "storage") + storageID := component.MustNewIDWithName("file_storage", "storage") qCfg.StorageID = &storageID rCfg := configretry.NewDefaultBackOffConfig() ts := consumertest.LogsSink{} set := exportertest.NewNopCreateSettings() - set.ID = component.NewIDWithName(component.MustNewType("test_logs"), "with_persistent_queue") + set.ID = component.MustNewIDWithName("test_logs", "with_persistent_queue") te, err := NewLogsExporter(context.Background(), set, &fakeLogsExporterConfig, ts.ConsumeLogs, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) diff --git a/exporter/exporterhelper/metrics_test.go b/exporter/exporterhelper/metrics_test.go index e4c2b8b8fc4..65125b4469c 100644 --- a/exporter/exporterhelper/metrics_test.go +++ b/exporter/exporterhelper/metrics_test.go @@ -37,7 +37,7 @@ const ( ) var ( - fakeMetricsExporterName = component.NewIDWithName(component.MustNewType("fake_metrics_exporter"), "with_name") + fakeMetricsExporterName = component.MustNewIDWithName("fake_metrics_exporter", "with_name") fakeMetricsExporterConfig = struct{}{} ) @@ -158,12 +158,12 @@ func TestMetricsRequestExporter_Default_ExportError(t *testing.T) { func TestMetricsExporter_WithPersistentQueue(t *testing.T) { qCfg := NewDefaultQueueSettings() - storageID := component.NewIDWithName(component.MustNewType("file_storage"), "storage") + storageID := component.MustNewIDWithName("file_storage", "storage") qCfg.StorageID = &storageID rCfg := configretry.NewDefaultBackOffConfig() ms := consumertest.MetricsSink{} set := exportertest.NewNopCreateSettings() - set.ID = component.NewIDWithName(component.MustNewType("test_metrics"), "with_persistent_queue") + set.ID = component.MustNewIDWithName("test_metrics", "with_persistent_queue") te, err := NewMetricsExporter(context.Background(), set, &fakeTracesExporterConfig, ms.ConsumeMetrics, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) diff --git a/exporter/exporterhelper/obsexporter_test.go b/exporter/exporterhelper/obsexporter_test.go index f4c1be6df2a..f6f46ccbad2 100644 --- a/exporter/exporterhelper/obsexporter_test.go +++ b/exporter/exporterhelper/obsexporter_test.go @@ -20,7 +20,7 @@ import ( ) var ( - exporterID = component.NewID(component.MustNewType("fakeExporter")) + exporterID = component.MustNewID("fakeExporter") errFake = errors.New("errFake") ) diff --git a/exporter/exporterhelper/obsreport_test.go b/exporter/exporterhelper/obsreport_test.go index fdd28dd623b..e0101f112df 100644 --- a/exporter/exporterhelper/obsreport_test.go +++ b/exporter/exporterhelper/obsreport_test.go @@ -15,7 +15,7 @@ import ( ) func TestExportEnqueueFailure(t *testing.T) { - exporterID := component.NewID(component.MustNewType("fakeExporter")) + exporterID := component.MustNewID("fakeExporter") tt, err := componenttest.SetupTelemetry(exporterID) require.NoError(t, err) t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) diff --git a/exporter/exporterhelper/queue_sender_test.go b/exporter/exporterhelper/queue_sender_test.go index 2bb3b9602b0..58da1190e9a 100644 --- a/exporter/exporterhelper/queue_sender_test.go +++ b/exporter/exporterhelper/queue_sender_test.go @@ -237,7 +237,7 @@ func TestQueuedRetryPersistenceEnabled(t *testing.T) { t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) qCfg := NewDefaultQueueSettings() - storageID := component.NewIDWithName(component.MustNewType("file_storage"), "storage") + storageID := component.MustNewIDWithName("file_storage", "storage") qCfg.StorageID = &storageID // enable persistence rCfg := configretry.NewDefaultBackOffConfig() set := exporter.CreateSettings{ID: defaultID, TelemetrySettings: tt.TelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo()} @@ -261,7 +261,7 @@ func TestQueuedRetryPersistenceEnabledStorageError(t *testing.T) { t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) qCfg := NewDefaultQueueSettings() - storageID := component.NewIDWithName(component.MustNewType("file_storage"), "storage") + storageID := component.MustNewIDWithName("file_storage", "storage") qCfg.StorageID = &storageID // enable persistence rCfg := configretry.NewDefaultBackOffConfig() set := exporter.CreateSettings{ID: defaultID, TelemetrySettings: tt.TelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo()} @@ -280,7 +280,7 @@ func TestQueuedRetryPersistenceEnabledStorageError(t *testing.T) { func TestQueuedRetryPersistentEnabled_NoDataLossOnShutdown(t *testing.T) { qCfg := NewDefaultQueueSettings() qCfg.NumConsumers = 1 - storageID := component.NewIDWithName(component.MustNewType("file_storage"), "storage") + storageID := component.MustNewIDWithName("file_storage", "storage") qCfg.StorageID = &storageID // enable persistence to ensure data is re-queued on shutdown rCfg := configretry.NewDefaultBackOffConfig() diff --git a/exporter/exporterhelper/traces_test.go b/exporter/exporterhelper/traces_test.go index 4faa868092d..be5a45ac30d 100644 --- a/exporter/exporterhelper/traces_test.go +++ b/exporter/exporterhelper/traces_test.go @@ -37,7 +37,7 @@ const ( ) var ( - fakeTracesExporterName = component.NewIDWithName(component.MustNewType("fake_traces_exporter"), "with_name") + fakeTracesExporterName = component.MustNewIDWithName("fake_traces_exporter", "with_name") fakeTracesExporterConfig = struct{}{} ) @@ -155,12 +155,12 @@ func TestTracesRequestExporter_Default_ExportError(t *testing.T) { func TestTracesExporter_WithPersistentQueue(t *testing.T) { qCfg := NewDefaultQueueSettings() - storageID := component.NewIDWithName(component.MustNewType("file_storage"), "storage") + storageID := component.MustNewIDWithName("file_storage", "storage") qCfg.StorageID = &storageID rCfg := configretry.NewDefaultBackOffConfig() ts := consumertest.TracesSink{} set := exportertest.NewNopCreateSettings() - set.ID = component.NewIDWithName(component.MustNewType("test_traces"), "with_persistent_queue") + set.ID = component.MustNewIDWithName("test_traces", "with_persistent_queue") te, err := NewTracesExporter(context.Background(), set, &fakeTracesExporterConfig, ts.ConsumeTraces, WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) diff --git a/exporter/otlpexporter/config_test.go b/exporter/otlpexporter/config_test.go index d236e41776c..996ce34cc42 100644 --- a/exporter/otlpexporter/config_test.go +++ b/exporter/otlpexporter/config_test.go @@ -74,7 +74,7 @@ func TestUnmarshalConfig(t *testing.T) { }, WriteBufferSize: 512 * 1024, BalancerName: "round_robin", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID(component.MustNewType("nop"))}, + Auth: &configauth.Authentication{AuthenticatorID: component.MustNewID("nop")}, }, }, cfg) } diff --git a/extension/extension_test.go b/extension/extension_test.go index fc1c1857ae8..af75db9feea 100644 --- a/extension/extension_test.go +++ b/extension/extension_test.go @@ -82,7 +82,7 @@ func TestBuilder(t *testing.T) { var testType = component.MustNewType("test") defaultCfg := struct{}{} testID := component.NewID(testType) - unknownID := component.NewID(component.MustNewType("unknown")) + unknownID := component.MustNewID("unknown") factories, err := MakeFactoryMap([]Factory{ NewFactory( @@ -120,11 +120,11 @@ func TestBuilderFactory(t *testing.T) { factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustNewType("foo"), nil, nil, component.StabilityLevelDevelopment)}...) require.NoError(t, err) - cfgs := map[component.ID]component.Config{component.NewID(component.MustNewType("foo")): struct{}{}} + cfgs := map[component.ID]component.Config{component.MustNewID("foo"): struct{}{}} b := NewBuilder(cfgs, factories) - assert.NotNil(t, b.Factory(component.NewID(component.MustNewType("foo")).Type())) - assert.Nil(t, b.Factory(component.NewID(component.MustNewType("bar")).Type())) + assert.NotNil(t, b.Factory(component.MustNewID("foo").Type())) + assert.Nil(t, b.Factory(component.MustNewID("bar").Type())) } func createSettings(id component.ID) CreateSettings { diff --git a/internal/memorylimiter/memorylimiter_test.go b/internal/memorylimiter/memorylimiter_test.go index bab557f0d74..e9e92a33f70 100644 --- a/internal/memorylimiter/memorylimiter_test.go +++ b/internal/memorylimiter/memorylimiter_test.go @@ -173,7 +173,7 @@ type host struct { func (h *host) GetExtensions() map[component.ID]component.Component { ret := make(map[component.ID]component.Component) - ret[component.NewID(component.MustNewType("ballast"))] = &ballastExtension{ballastSize: h.ballastSize} + ret[component.MustNewID("ballast")] = &ballastExtension{ballastSize: h.ballastSize} return ret } diff --git a/internal/sharedcomponent/sharedcomponent_test.go b/internal/sharedcomponent/sharedcomponent_test.go index 6519e456089..8ba96a28734 100644 --- a/internal/sharedcomponent/sharedcomponent_test.go +++ b/internal/sharedcomponent/sharedcomponent_test.go @@ -15,7 +15,7 @@ import ( "go.opentelemetry.io/collector/component/componenttest" ) -var id = component.NewID(component.MustNewType("test")) +var id = component.MustNewID("test") type baseComponent struct { component.StartFunc diff --git a/otelcol/config_test.go b/otelcol/config_test.go index db0ab6e2058..e482e6c8ae8 100644 --- a/otelcol/config_test.go +++ b/otelcol/config_test.go @@ -76,7 +76,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-extension-reference", cfgFn: func() *Config { cfg := generateConfig() - cfg.Service.Extensions = append(cfg.Service.Extensions, component.NewIDWithName(component.MustNewType("nop"), "2")) + cfg.Service.Extensions = append(cfg.Service.Extensions, component.MustNewIDWithName("nop", "2")) return cfg }, expected: errors.New(`service::extensions: references extension "nop/2" which is not configured`), @@ -85,8 +85,8 @@ func TestConfigValidate(t *testing.T) { name: "invalid-receiver-reference", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.NewID(component.MustNewType("traces"))] - pipe.Receivers = append(pipe.Receivers, component.NewIDWithName(component.MustNewType("nop"), "2")) + pipe := cfg.Service.Pipelines[component.MustNewID("traces")] + pipe.Receivers = append(pipe.Receivers, component.MustNewIDWithName("nop", "2")) return cfg }, expected: errors.New(`service::pipelines::traces: references receiver "nop/2" which is not configured`), @@ -95,8 +95,8 @@ func TestConfigValidate(t *testing.T) { name: "invalid-processor-reference", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.NewID(component.MustNewType("traces"))] - pipe.Processors = append(pipe.Processors, component.NewIDWithName(component.MustNewType("nop"), "2")) + pipe := cfg.Service.Pipelines[component.MustNewID("traces")] + pipe.Processors = append(pipe.Processors, component.MustNewIDWithName("nop", "2")) return cfg }, expected: errors.New(`service::pipelines::traces: references processor "nop/2" which is not configured`), @@ -105,8 +105,8 @@ func TestConfigValidate(t *testing.T) { name: "invalid-exporter-reference", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.NewID(component.MustNewType("traces"))] - pipe.Exporters = append(pipe.Exporters, component.NewIDWithName(component.MustNewType("nop"), "2")) + pipe := cfg.Service.Pipelines[component.MustNewID("traces")] + pipe.Exporters = append(pipe.Exporters, component.MustNewIDWithName("nop", "2")) return cfg }, expected: errors.New(`service::pipelines::traces: references exporter "nop/2" which is not configured`), @@ -115,7 +115,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-receiver-config", cfgFn: func() *Config { cfg := generateConfig() - cfg.Receivers[component.NewID(component.MustNewType("nop"))] = &errConfig{ + cfg.Receivers[component.MustNewID("nop")] = &errConfig{ validateErr: errInvalidRecvConfig, } return cfg @@ -126,7 +126,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-exporter-config", cfgFn: func() *Config { cfg := generateConfig() - cfg.Exporters[component.NewID(component.MustNewType("nop"))] = &errConfig{ + cfg.Exporters[component.MustNewID("nop")] = &errConfig{ validateErr: errInvalidExpConfig, } return cfg @@ -137,7 +137,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-processor-config", cfgFn: func() *Config { cfg := generateConfig() - cfg.Processors[component.NewID(component.MustNewType("nop"))] = &errConfig{ + cfg.Processors[component.MustNewID("nop")] = &errConfig{ validateErr: errInvalidProcConfig, } return cfg @@ -148,7 +148,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-extension-config", cfgFn: func() *Config { cfg := generateConfig() - cfg.Extensions[component.NewID(component.MustNewType("nop"))] = &errConfig{ + cfg.Extensions[component.MustNewID("nop")] = &errConfig{ validateErr: errInvalidExtConfig, } return cfg @@ -159,7 +159,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-connector-config", cfgFn: func() *Config { cfg := generateConfig() - cfg.Connectors[component.NewIDWithName(component.MustNewType("nop"), "conn")] = &errConfig{ + cfg.Connectors[component.MustNewIDWithName("nop", "conn")] = &errConfig{ validateErr: errInvalidConnConfig, } return cfg @@ -170,11 +170,11 @@ func TestConfigValidate(t *testing.T) { name: "ambiguous-connector-name-as-receiver", cfgFn: func() *Config { cfg := generateConfig() - cfg.Receivers[component.NewID(component.MustNewType("nop2"))] = &errConfig{} - cfg.Connectors[component.NewID(component.MustNewType("nop2"))] = &errConfig{} - pipe := cfg.Service.Pipelines[component.NewID(component.MustNewType("traces"))] - pipe.Receivers = append(pipe.Receivers, component.NewIDWithName(component.MustNewType("nop"), "2")) - pipe.Exporters = append(pipe.Exporters, component.NewIDWithName(component.MustNewType("nop"), "2")) + cfg.Receivers[component.MustNewID("nop2")] = &errConfig{} + cfg.Connectors[component.MustNewID("nop2")] = &errConfig{} + pipe := cfg.Service.Pipelines[component.MustNewID("traces")] + pipe.Receivers = append(pipe.Receivers, component.MustNewIDWithName("nop", "2")) + pipe.Exporters = append(pipe.Exporters, component.MustNewIDWithName("nop", "2")) return cfg }, expected: errors.New(`connectors::nop2: ambiguous ID: Found both "nop2" receiver and "nop2" connector. Change one of the components' IDs to eliminate ambiguity (e.g. rename "nop2" connector to "nop2/connector")`), @@ -183,11 +183,11 @@ func TestConfigValidate(t *testing.T) { name: "ambiguous-connector-name-as-exporter", cfgFn: func() *Config { cfg := generateConfig() - cfg.Exporters[component.NewID(component.MustNewType("nop2"))] = &errConfig{} - cfg.Connectors[component.NewID(component.MustNewType("nop2"))] = &errConfig{} - pipe := cfg.Service.Pipelines[component.NewID(component.MustNewType("traces"))] - pipe.Receivers = append(pipe.Receivers, component.NewIDWithName(component.MustNewType("nop"), "2")) - pipe.Exporters = append(pipe.Exporters, component.NewIDWithName(component.MustNewType("nop"), "2")) + cfg.Exporters[component.MustNewID("nop2")] = &errConfig{} + cfg.Connectors[component.MustNewID("nop2")] = &errConfig{} + pipe := cfg.Service.Pipelines[component.MustNewID("traces")] + pipe.Receivers = append(pipe.Receivers, component.MustNewIDWithName("nop", "2")) + pipe.Exporters = append(pipe.Exporters, component.MustNewIDWithName("nop", "2")) return cfg }, expected: errors.New(`connectors::nop2: ambiguous ID: Found both "nop2" exporter and "nop2" connector. Change one of the components' IDs to eliminate ambiguity (e.g. rename "nop2" connector to "nop2/connector")`), @@ -196,8 +196,8 @@ func TestConfigValidate(t *testing.T) { name: "invalid-connector-reference-as-receiver", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.NewID(component.MustNewType("traces"))] - pipe.Receivers = append(pipe.Receivers, component.NewIDWithName(component.MustNewType("nop"), "conn2")) + pipe := cfg.Service.Pipelines[component.MustNewID("traces")] + pipe.Receivers = append(pipe.Receivers, component.MustNewIDWithName("nop", "conn2")) return cfg }, expected: errors.New(`service::pipelines::traces: references receiver "nop/conn2" which is not configured`), @@ -206,8 +206,8 @@ func TestConfigValidate(t *testing.T) { name: "invalid-connector-reference-as-receiver", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.NewID(component.MustNewType("traces"))] - pipe.Exporters = append(pipe.Exporters, component.NewIDWithName(component.MustNewType("nop"), "conn2")) + pipe := cfg.Service.Pipelines[component.MustNewID("traces")] + pipe.Exporters = append(pipe.Exporters, component.MustNewIDWithName("nop", "conn2")) return cfg }, expected: errors.New(`service::pipelines::traces: references exporter "nop/conn2" which is not configured`), @@ -234,19 +234,19 @@ func TestConfigValidate(t *testing.T) { func generateConfig() *Config { return &Config{ Receivers: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): &errConfig{}, + component.MustNewID("nop"): &errConfig{}, }, Exporters: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): &errConfig{}, + component.MustNewID("nop"): &errConfig{}, }, Processors: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): &errConfig{}, + component.MustNewID("nop"): &errConfig{}, }, Connectors: map[component.ID]component.Config{ - component.NewIDWithName(component.MustNewType("nop"), "conn"): &errConfig{}, + component.MustNewIDWithName("nop", "conn"): &errConfig{}, }, Extensions: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): &errConfig{}, + component.MustNewID("nop"): &errConfig{}, }, Service: service.Config{ Telemetry: telemetry.Config{ @@ -265,12 +265,12 @@ func generateConfig() *Config { Address: ":8080", }, }, - Extensions: []component.ID{component.NewID(component.MustNewType("nop"))}, + Extensions: []component.ID{component.MustNewID("nop")}, Pipelines: pipelines.Config{ - component.NewID(component.MustNewType("traces")): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewID("traces"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, }, diff --git a/otelcol/otelcoltest/config_test.go b/otelcol/otelcoltest/config_test.go index b6caff4321a..71502de536e 100644 --- a/otelcol/otelcoltest/config_test.go +++ b/otelcol/otelcoltest/config_test.go @@ -23,39 +23,39 @@ func TestLoadConfig(t *testing.T) { // Verify extensions. require.Len(t, cfg.Extensions, 2) - assert.Contains(t, cfg.Extensions, component.NewID(component.MustNewType("nop"))) - assert.Contains(t, cfg.Extensions, component.NewIDWithName(component.MustNewType("nop"), "myextension")) + assert.Contains(t, cfg.Extensions, component.MustNewID("nop")) + assert.Contains(t, cfg.Extensions, component.MustNewIDWithName("nop", "myextension")) // Verify receivers require.Len(t, cfg.Receivers, 2) - assert.Contains(t, cfg.Receivers, component.NewID(component.MustNewType("nop"))) - assert.Contains(t, cfg.Receivers, component.NewIDWithName(component.MustNewType("nop"), "myreceiver")) + assert.Contains(t, cfg.Receivers, component.MustNewID("nop")) + assert.Contains(t, cfg.Receivers, component.MustNewIDWithName("nop", "myreceiver")) // Verify exporters assert.Len(t, cfg.Exporters, 2) - assert.Contains(t, cfg.Exporters, component.NewID(component.MustNewType("nop"))) - assert.Contains(t, cfg.Exporters, component.NewIDWithName(component.MustNewType("nop"), "myexporter")) + assert.Contains(t, cfg.Exporters, component.MustNewID("nop")) + assert.Contains(t, cfg.Exporters, component.MustNewIDWithName("nop", "myexporter")) // Verify procs assert.Len(t, cfg.Processors, 2) - assert.Contains(t, cfg.Processors, component.NewID(component.MustNewType("nop"))) - assert.Contains(t, cfg.Processors, component.NewIDWithName(component.MustNewType("nop"), "myprocessor")) + assert.Contains(t, cfg.Processors, component.MustNewID("nop")) + assert.Contains(t, cfg.Processors, component.MustNewIDWithName("nop", "myprocessor")) // Verify connectors assert.Len(t, cfg.Connectors, 1) - assert.Contains(t, cfg.Connectors, component.NewIDWithName(component.MustNewType("nop"), "myconnector")) + assert.Contains(t, cfg.Connectors, component.MustNewIDWithName("nop", "myconnector")) // Verify service. require.Len(t, cfg.Service.Extensions, 1) - assert.Contains(t, cfg.Service.Extensions, component.NewID(component.MustNewType("nop"))) + assert.Contains(t, cfg.Service.Extensions, component.MustNewID("nop")) require.Len(t, cfg.Service.Pipelines, 1) assert.Equal(t, &pipelines.PipelineConfig{ - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + Receivers: []component.ID{component.MustNewID("nop")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, - cfg.Service.Pipelines[component.NewID(component.MustNewType("traces"))], + cfg.Service.Pipelines[component.MustNewID("traces")], "Did not load pipeline config correctly") } diff --git a/processor/batchprocessor/metrics_test.go b/processor/batchprocessor/metrics_test.go index 14bb7e277df..6b46f67ae31 100644 --- a/processor/batchprocessor/metrics_test.go +++ b/processor/batchprocessor/metrics_test.go @@ -97,7 +97,7 @@ func setupTelemetry(t *testing.T) testTelemetry { func (tt *testTelemetry) NewProcessorCreateSettings() processor.CreateSettings { settings := processortest.NewNopCreateSettings() settings.MeterProvider = tt.meterProvider - settings.ID = component.NewID(component.MustNewType("batch")) + settings.ID = component.MustNewID("batch") return settings } diff --git a/processor/memorylimiterprocessor/memorylimiter_test.go b/processor/memorylimiterprocessor/memorylimiter_test.go index f98554830ac..626bf877d7c 100644 --- a/processor/memorylimiterprocessor/memorylimiter_test.go +++ b/processor/memorylimiterprocessor/memorylimiter_test.go @@ -467,7 +467,7 @@ type host struct { func (h *host) GetExtensions() map[component.ID]component.Component { ret := make(map[component.ID]component.Component) - ret[component.NewID(component.MustNewType("ballast"))] = &ballastExtension{ballastSize: h.ballastSize} + ret[component.MustNewID("ballast")] = &ballastExtension{ballastSize: h.ballastSize} return ret } diff --git a/processor/processor_test.go b/processor/processor_test.go index dc3377b0a39..c72f7edb698 100644 --- a/processor/processor_test.go +++ b/processor/processor_test.go @@ -116,21 +116,21 @@ func TestBuilder(t *testing.T) { }{ { name: "unknown", - id: component.NewID(component.MustNewType("unknown")), + id: component.MustNewID("unknown"), err: "processor factory not available for: \"unknown\"", }, { name: "err", - id: component.NewID(component.MustNewType("err")), + id: component.MustNewID("err"), err: "telemetry type is not supported", }, { name: "all", - id: component.NewID(component.MustNewType("all")), + id: component.MustNewID("all"), }, { name: "all/named", - id: component.NewIDWithName(component.MustNewType("all"), "named"), + id: component.MustNewIDWithName("all", "named"), }, } @@ -184,7 +184,7 @@ func TestBuilderMissingConfig(t *testing.T) { require.NoError(t, err) bErr := NewBuilder(map[component.ID]component.Config{}, factories) - missingID := component.NewIDWithName(component.MustNewType("all"), "missing") + missingID := component.MustNewIDWithName("all", "missing") te, err := bErr.CreateTraces(context.Background(), createSettings(missingID), nil) assert.EqualError(t, err, "processor \"all/missing\" is not configured") @@ -203,11 +203,11 @@ func TestBuilderFactory(t *testing.T) { factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustNewType("foo"), nil)}...) require.NoError(t, err) - cfgs := map[component.ID]component.Config{component.NewID(component.MustNewType("foo")): struct{}{}} + cfgs := map[component.ID]component.Config{component.MustNewID("foo"): struct{}{}} b := NewBuilder(cfgs, factories) - assert.NotNil(t, b.Factory(component.NewID(component.MustNewType("foo")).Type())) - assert.Nil(t, b.Factory(component.NewID(component.MustNewType("bar")).Type())) + assert.NotNil(t, b.Factory(component.MustNewID("foo").Type())) + assert.Nil(t, b.Factory(component.MustNewID("bar").Type())) } var nopInstance = &nopProcessor{ diff --git a/processor/processorhelper/obsreport_test.go b/processor/processorhelper/obsreport_test.go index 249af85d86c..2cd4500e299 100644 --- a/processor/processorhelper/obsreport_test.go +++ b/processor/processorhelper/obsreport_test.go @@ -16,7 +16,7 @@ import ( ) var ( - processorID = component.NewID(component.MustNewType("fakeProcessor")) + processorID = component.MustNewID("fakeProcessor") ) func TestProcessorTraceData(t *testing.T) { diff --git a/receiver/otlpreceiver/internal/logs/otlp_test.go b/receiver/otlpreceiver/internal/logs/otlp_test.go index 41f00caea09..71c10390786 100644 --- a/receiver/otlpreceiver/internal/logs/otlp_test.go +++ b/receiver/otlpreceiver/internal/logs/otlp_test.go @@ -92,7 +92,7 @@ func otlpReceiverOnGRPCServer(t *testing.T, lc consumer.Logs) net.Addr { }) set := receivertest.NewNopCreateSettings() - set.ID = component.NewIDWithName(component.MustNewType("otlp"), "log") + set.ID = component.MustNewIDWithName("otlp", "log") obsreport, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{ ReceiverID: set.ID, Transport: "grpc", diff --git a/receiver/otlpreceiver/internal/metrics/otlp_test.go b/receiver/otlpreceiver/internal/metrics/otlp_test.go index 4f72f0fa0d7..48cfaca993d 100644 --- a/receiver/otlpreceiver/internal/metrics/otlp_test.go +++ b/receiver/otlpreceiver/internal/metrics/otlp_test.go @@ -93,7 +93,7 @@ func otlpReceiverOnGRPCServer(t *testing.T, mc consumer.Metrics) net.Addr { }) set := receivertest.NewNopCreateSettings() - set.ID = component.NewIDWithName(component.MustNewType("otlp"), "metrics") + set.ID = component.MustNewIDWithName("otlp", "metrics") obsreport, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{ ReceiverID: set.ID, Transport: "grpc", diff --git a/receiver/otlpreceiver/internal/trace/otlp_test.go b/receiver/otlpreceiver/internal/trace/otlp_test.go index dbfb831c866..3130f0a242b 100644 --- a/receiver/otlpreceiver/internal/trace/otlp_test.go +++ b/receiver/otlpreceiver/internal/trace/otlp_test.go @@ -89,7 +89,7 @@ func otlpReceiverOnGRPCServer(t *testing.T, tc consumer.Traces) net.Addr { }) set := receivertest.NewNopCreateSettings() - set.ID = component.NewIDWithName(component.MustNewType("otlp"), "trace") + set.ID = component.MustNewIDWithName("otlp", "trace") obsreport, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{ ReceiverID: set.ID, Transport: "grpc", diff --git a/receiver/otlpreceiver/otlp_test.go b/receiver/otlpreceiver/otlp_test.go index 0e8916db695..4f84f4623fe 100644 --- a/receiver/otlpreceiver/otlp_test.go +++ b/receiver/otlpreceiver/otlp_test.go @@ -48,7 +48,7 @@ import ( const otlpReceiverName = "receiver_test" -var otlpReceiverID = component.NewIDWithName(component.MustNewType("otlp"), otlpReceiverName) +var otlpReceiverID = component.MustNewIDWithName("otlp", otlpReceiverName) func TestJsonHttp(t *testing.T) { tests := []struct { diff --git a/receiver/receiver_test.go b/receiver/receiver_test.go index a74f9307331..910d562d476 100644 --- a/receiver/receiver_test.go +++ b/receiver/receiver_test.go @@ -116,21 +116,21 @@ func TestBuilder(t *testing.T) { }{ { name: "unknown", - id: component.NewID(component.MustNewType("unknown")), + id: component.MustNewID("unknown"), err: "receiver factory not available for: \"unknown\"", }, { name: "err", - id: component.NewID(component.MustNewType("err")), + id: component.MustNewID("err"), err: "telemetry type is not supported", }, { name: "all", - id: component.NewID(component.MustNewType("all")), + id: component.MustNewID("all"), }, { name: "all/named", - id: component.NewIDWithName(component.MustNewType("all"), "named"), + id: component.MustNewIDWithName("all", "named"), }, } @@ -184,7 +184,7 @@ func TestBuilderMissingConfig(t *testing.T) { require.NoError(t, err) bErr := NewBuilder(map[component.ID]component.Config{}, factories) - missingID := component.NewIDWithName(component.MustNewType("all"), "missing") + missingID := component.MustNewIDWithName("all", "missing") te, err := bErr.CreateTraces(context.Background(), createSettings(missingID), nil) assert.EqualError(t, err, "receiver \"all/missing\" is not configured") @@ -203,11 +203,11 @@ func TestBuilderFactory(t *testing.T) { factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustNewType("foo"), nil)}...) require.NoError(t, err) - cfgs := map[component.ID]component.Config{component.NewID(component.MustNewType("foo")): struct{}{}} + cfgs := map[component.ID]component.Config{component.MustNewID("foo"): struct{}{}} b := NewBuilder(cfgs, factories) - assert.NotNil(t, b.Factory(component.NewID(component.MustNewType("foo")).Type())) - assert.Nil(t, b.Factory(component.NewID(component.MustNewType("bar")).Type())) + assert.NotNil(t, b.Factory(component.MustNewID("foo").Type())) + assert.Nil(t, b.Factory(component.MustNewID("bar").Type())) } var nopInstance = &nopReceiver{ diff --git a/receiver/receiverhelper/obsreport_test.go b/receiver/receiverhelper/obsreport_test.go index d6d75946f60..3a417e176aa 100644 --- a/receiver/receiverhelper/obsreport_test.go +++ b/receiver/receiverhelper/obsreport_test.go @@ -25,7 +25,7 @@ const ( ) var ( - receiverID = component.NewID(component.MustNewType("fakeReceiver")) + receiverID = component.MustNewID("fakeReceiver") errFake = errors.New("errFake") ) diff --git a/receiver/scraperhelper/obsreport_test.go b/receiver/scraperhelper/obsreport_test.go index 767a392fcbf..6ccbc8041cd 100644 --- a/receiver/scraperhelper/obsreport_test.go +++ b/receiver/scraperhelper/obsreport_test.go @@ -21,8 +21,8 @@ import ( ) var ( - receiverID = component.NewID(component.MustNewType("fakeReceiver")) - scraperID = component.NewID(component.MustNewType("fakeScraper")) + receiverID = component.MustNewID("fakeReceiver") + scraperID = component.MustNewID("fakeScraper") errFake = errors.New("errFake") partialErrFake = scrapererror.NewPartialScrapeError(errFake, 1) diff --git a/receiver/scraperhelper/scrapercontroller_test.go b/receiver/scraperhelper/scrapercontroller_test.go index d104a415912..bf8ba9d4327 100644 --- a/receiver/scraperhelper/scrapercontroller_test.go +++ b/receiver/scraperhelper/scrapercontroller_test.go @@ -134,7 +134,7 @@ func TestScrapeController(t *testing.T) { for _, test := range testCases { test := test t.Run(test.name, func(t *testing.T) { - receiverID := component.NewID(component.MustNewType("receiver")) + receiverID := component.MustNewID("receiver") tt, err := componenttest.SetupTelemetry(receiverID) require.NoError(t, err) t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) @@ -326,7 +326,7 @@ func assertScraperViews(t *testing.T, tt componenttest.TestTelemetry, expectedEr } } - require.NoError(t, tt.CheckScraperMetrics(component.NewID(component.MustNewType("receiver")), component.NewID(component.MustNewType("scraper")), expectedScraped, expectedErrored)) + require.NoError(t, tt.CheckScraperMetrics(component.MustNewID("receiver"), component.MustNewID("scraper"), expectedScraped, expectedErrored)) } func TestSingleScrapePerInterval(t *testing.T) { diff --git a/service/config_test.go b/service/config_test.go index cef01975ff3..6ac9d6e625a 100644 --- a/service/config_test.go +++ b/service/config_test.go @@ -42,7 +42,7 @@ func TestConfigValidate(t *testing.T) { name: "duplicate-processor-reference", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Pipelines[component.NewID(component.MustNewType("traces"))] + pipe := cfg.Pipelines[component.MustNewID("traces")] pipe.Processors = append(pipe.Processors, pipe.Processors...) return cfg }, @@ -52,10 +52,10 @@ func TestConfigValidate(t *testing.T) { name: "invalid-service-pipeline-type", cfgFn: func() *Config { cfg := generateConfig() - cfg.Pipelines[component.NewID(component.MustNewType("wrongtype"))] = &pipelines.PipelineConfig{ - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + cfg.Pipelines[component.MustNewID("wrongtype")] = &pipelines.PipelineConfig{ + Receivers: []component.ID{component.MustNewID("nop")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("nop")}, } return cfg }, @@ -99,12 +99,12 @@ func generateConfig() *Config { Address: ":8080", }, }, - Extensions: extensions.Config{component.NewID(component.MustNewType("nop"))}, + Extensions: extensions.Config{component.MustNewID("nop")}, Pipelines: pipelines.Config{ - component.NewID(component.MustNewType("traces")): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewID("traces"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, } diff --git a/service/extensions/extensions_test.go b/service/extensions/extensions_test.go index b82147b6054..4f1f735852e 100644 --- a/service/extensions/extensions_test.go +++ b/service/extensions/extensions_test.go @@ -38,17 +38,17 @@ func TestBuildExtensions(t *testing.T) { { name: "extension_not_configured", config: Config{ - component.NewID(component.MustNewType("myextension")), + component.MustNewID("myextension"), }, wantErrMsg: "failed to create extension \"myextension\": extension \"myextension\" is not configured", }, { name: "missing_extension_factory", extensionsConfigs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("unknown")): nopExtensionConfig, + component.MustNewID("unknown"): nopExtensionConfig, }, config: Config{ - component.NewID(component.MustNewType("unknown")), + component.MustNewID("unknown"), }, wantErrMsg: "failed to create extension \"unknown\": extension factory not available for: \"unknown\"", }, @@ -233,10 +233,10 @@ func TestNotifyConfig(t *testing.T) { component.MustNewType("nop"): nopExtensionFactory, }, extensionsConfigs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExtensionConfig, + component.MustNewID("nop"): nopExtensionConfig, }, serviceExtensions: []component.ID{ - component.NewID(component.MustNewType("nop")), + component.MustNewID("nop"), }, }, { @@ -245,10 +245,10 @@ func TestNotifyConfig(t *testing.T) { component.MustNewType("notifiable1"): n1ExtensionFactory, }, extensionsConfigs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("notifiable1")): n1ExtensionConfig, + component.MustNewID("notifiable1"): n1ExtensionConfig, }, serviceExtensions: []component.ID{ - component.NewID(component.MustNewType("notifiable1")), + component.MustNewID("notifiable1"), }, }, { @@ -258,12 +258,12 @@ func TestNotifyConfig(t *testing.T) { component.MustNewType("notifiable2"): n2ExtensionFactory, }, extensionsConfigs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("notifiable1")): n1ExtensionConfig, - component.NewID(component.MustNewType("notifiable2")): n2ExtensionConfig, + component.MustNewID("notifiable1"): n1ExtensionConfig, + component.MustNewID("notifiable2"): n2ExtensionConfig, }, serviceExtensions: []component.ID{ - component.NewID(component.MustNewType("notifiable1")), - component.NewID(component.MustNewType("notifiable2")), + component.MustNewID("notifiable1"), + component.MustNewID("notifiable2"), }, }, { @@ -272,10 +272,10 @@ func TestNotifyConfig(t *testing.T) { component.MustNewType("notifiableErr"): nErrExtensionFactory, }, extensionsConfigs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("notifiableErr")): nErrExtensionConfig, + component.MustNewID("notifiableErr"): nErrExtensionConfig, }, serviceExtensions: []component.ID{ - component.NewID(component.MustNewType("notifiableErr")), + component.MustNewID("notifiableErr"), }, want: notificationError, }, @@ -520,7 +520,7 @@ func (ext *recordingExtension) Dependencies() []component.ID { } deps := make([]component.ID, len(ext.config.dependencies)) for i, dep := range ext.config.dependencies { - deps[i] = component.NewIDWithName(component.MustNewType("recording"), dep) + deps[i] = component.MustNewIDWithName("recording", dep) } return deps } diff --git a/service/internal/graph/graph_test.go b/service/internal/graph/graph_test.go index df611a00954..f2eb413a381 100644 --- a/service/internal/graph/graph_test.go +++ b/service/internal/graph/graph_test.go @@ -90,48 +90,48 @@ func TestGraphStartStop(t *testing.T) { { name: "single", edges: [][2]component.ID{ - {component.NewIDWithName(component.MustNewType("r"), "1"), component.NewIDWithName(component.MustNewType("p"), "1")}, - {component.NewIDWithName(component.MustNewType("r"), "2"), component.NewIDWithName(component.MustNewType("p"), "1")}, - {component.NewIDWithName(component.MustNewType("p"), "1"), component.NewIDWithName(component.MustNewType("p"), "2")}, - {component.NewIDWithName(component.MustNewType("p"), "2"), component.NewIDWithName(component.MustNewType("e"), "1")}, - {component.NewIDWithName(component.MustNewType("p"), "1"), component.NewIDWithName(component.MustNewType("e"), "2")}, + {component.MustNewIDWithName("r", "1"), component.MustNewIDWithName("p", "1")}, + {component.MustNewIDWithName("r", "2"), component.MustNewIDWithName("p", "1")}, + {component.MustNewIDWithName("p", "1"), component.MustNewIDWithName("p", "2")}, + {component.MustNewIDWithName("p", "2"), component.MustNewIDWithName("e", "1")}, + {component.MustNewIDWithName("p", "1"), component.MustNewIDWithName("e", "2")}, }, }, { name: "multi", edges: [][2]component.ID{ // Pipeline 1 - {component.NewIDWithName(component.MustNewType("r"), "1"), component.NewIDWithName(component.MustNewType("p"), "1")}, - {component.NewIDWithName(component.MustNewType("r"), "2"), component.NewIDWithName(component.MustNewType("p"), "1")}, - {component.NewIDWithName(component.MustNewType("p"), "1"), component.NewIDWithName(component.MustNewType("p"), "2")}, - {component.NewIDWithName(component.MustNewType("p"), "2"), component.NewIDWithName(component.MustNewType("e"), "1")}, - {component.NewIDWithName(component.MustNewType("p"), "1"), component.NewIDWithName(component.MustNewType("e"), "2")}, + {component.MustNewIDWithName("r", "1"), component.MustNewIDWithName("p", "1")}, + {component.MustNewIDWithName("r", "2"), component.MustNewIDWithName("p", "1")}, + {component.MustNewIDWithName("p", "1"), component.MustNewIDWithName("p", "2")}, + {component.MustNewIDWithName("p", "2"), component.MustNewIDWithName("e", "1")}, + {component.MustNewIDWithName("p", "1"), component.MustNewIDWithName("e", "2")}, // Pipeline 2, shares r1 and e2 - {component.NewIDWithName(component.MustNewType("r"), "1"), component.NewIDWithName(component.MustNewType("p"), "3")}, - {component.NewIDWithName(component.MustNewType("p"), "3"), component.NewIDWithName(component.MustNewType("e"), "2")}, + {component.MustNewIDWithName("r", "1"), component.MustNewIDWithName("p", "3")}, + {component.MustNewIDWithName("p", "3"), component.MustNewIDWithName("e", "2")}, }, }, { name: "connected", edges: [][2]component.ID{ // Pipeline 1 - {component.NewIDWithName(component.MustNewType("r"), "1"), component.NewIDWithName(component.MustNewType("p"), "1")}, - {component.NewIDWithName(component.MustNewType("r"), "2"), component.NewIDWithName(component.MustNewType("p"), "1")}, - {component.NewIDWithName(component.MustNewType("p"), "1"), component.NewIDWithName(component.MustNewType("p"), "2")}, - {component.NewIDWithName(component.MustNewType("p"), "2"), component.NewIDWithName(component.MustNewType("e"), "1")}, - {component.NewIDWithName(component.MustNewType("p"), "1"), component.NewIDWithName(component.MustNewType("c"), "1")}, + {component.MustNewIDWithName("r", "1"), component.MustNewIDWithName("p", "1")}, + {component.MustNewIDWithName("r", "2"), component.MustNewIDWithName("p", "1")}, + {component.MustNewIDWithName("p", "1"), component.MustNewIDWithName("p", "2")}, + {component.MustNewIDWithName("p", "2"), component.MustNewIDWithName("e", "1")}, + {component.MustNewIDWithName("p", "1"), component.MustNewIDWithName("c", "1")}, // Pipeline 2, shares r1 and c1 - {component.NewIDWithName(component.MustNewType("r"), "1"), component.NewIDWithName(component.MustNewType("p"), "3")}, - {component.NewIDWithName(component.MustNewType("p"), "3"), component.NewIDWithName(component.MustNewType("c"), "1")}, + {component.MustNewIDWithName("r", "1"), component.MustNewIDWithName("p", "3")}, + {component.MustNewIDWithName("p", "3"), component.MustNewIDWithName("c", "1")}, // Pipeline 3, emits to e2 and c2 - {component.NewIDWithName(component.MustNewType("c"), "1"), component.NewIDWithName(component.MustNewType("e"), "2")}, - {component.NewIDWithName(component.MustNewType("c"), "1"), component.NewIDWithName(component.MustNewType("c"), "2")}, + {component.MustNewIDWithName("c", "1"), component.MustNewIDWithName("e", "2")}, + {component.MustNewIDWithName("c", "1"), component.MustNewIDWithName("c", "2")}, // Pipeline 4, also emits to e2 - {component.NewIDWithName(component.MustNewType("c"), "2"), component.NewIDWithName(component.MustNewType("e"), "2")}, + {component.MustNewIDWithName("c", "2"), component.MustNewIDWithName("e", "2")}, }, }, } @@ -171,10 +171,10 @@ func TestGraphStartStop(t *testing.T) { func TestGraphStartStopCycle(t *testing.T) { pg := &Graph{componentGraph: simple.NewDirectedGraph()} - r1 := &testNode{id: component.NewIDWithName(component.MustNewType("r"), "1")} - p1 := &testNode{id: component.NewIDWithName(component.MustNewType("p"), "1")} - c1 := &testNode{id: component.NewIDWithName(component.MustNewType("c"), "1")} - e1 := &testNode{id: component.NewIDWithName(component.MustNewType("e"), "1")} + r1 := &testNode{id: component.MustNewIDWithName("r", "1")} + p1 := &testNode{id: component.MustNewIDWithName("p", "1")} + c1 := &testNode{id: component.MustNewIDWithName("c", "1")} + e1 := &testNode{id: component.MustNewIDWithName("e", "1")} pg.instanceIDs = map[int64]*component.InstanceID{ r1.ID(): {}, @@ -201,11 +201,11 @@ func TestGraphStartStopComponentError(t *testing.T) { pg := &Graph{componentGraph: simple.NewDirectedGraph()} pg.telemetry = servicetelemetry.NewNopTelemetrySettings() r1 := &testNode{ - id: component.NewIDWithName(component.MustNewType("r"), "1"), + id: component.MustNewIDWithName("r", "1"), startErr: errors.New("foo"), } e1 := &testNode{ - id: component.NewIDWithName(component.MustNewType("e"), "1"), + id: component.MustNewIDWithName("e", "1"), shutdownErr: errors.New("bar"), } pg.instanceIDs = map[int64]*component.InstanceID{ @@ -229,20 +229,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_simple.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustNewType("traces")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("traces"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewID(component.MustNewType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("metrics"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewID(component.MustNewType("logs")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("logs"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, }, expectedPerExporter: 1, @@ -250,20 +250,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_simple_mutate.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustNewType("traces")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("traces"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewID(component.MustNewType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("metrics"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewID(component.MustNewType("logs")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("logs"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, }, expectedPerExporter: 1, @@ -271,20 +271,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_simple_multi_proc.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustNewType("traces")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor")), component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("traces"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewID("exampleprocessor"), component.MustNewIDWithName("exampleprocessor", "mutate")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewID(component.MustNewType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor")), component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("metrics"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewID("exampleprocessor"), component.MustNewIDWithName("exampleprocessor", "mutate")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewID(component.MustNewType("logs")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor")), component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("logs"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewID("exampleprocessor"), component.MustNewIDWithName("exampleprocessor", "mutate")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, }, expectedPerExporter: 1, @@ -292,17 +292,17 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_simple_no_proc.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustNewType("traces")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("traces"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewID(component.MustNewType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("metrics"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewID(component.MustNewType("logs")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("logs"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, }, expectedPerExporter: 1, @@ -310,20 +310,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_multi.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustNewType("traces")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver")), component.NewIDWithName(component.MustNewType("examplereceiver"), "1")}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate"), component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter")), component.NewIDWithName(component.MustNewType("exampleexporter"), "1")}, + component.MustNewID("traces"): { + Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate"), component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")}, }, - component.NewID(component.MustNewType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver")), component.NewIDWithName(component.MustNewType("examplereceiver"), "1")}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate"), component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter")), component.NewIDWithName(component.MustNewType("exampleexporter"), "1")}, + component.MustNewID("metrics"): { + Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate"), component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")}, }, - component.NewID(component.MustNewType("logs")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver")), component.NewIDWithName(component.MustNewType("examplereceiver"), "1")}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate"), component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter")), component.NewIDWithName(component.MustNewType("exampleexporter"), "1")}, + component.MustNewID("logs"): { + Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate"), component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")}, }, }, expectedPerExporter: 2, @@ -331,17 +331,17 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_multi_no_proc.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustNewType("traces")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver")), component.NewIDWithName(component.MustNewType("examplereceiver"), "1")}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter")), component.NewIDWithName(component.MustNewType("exampleexporter"), "1")}, + component.MustNewID("traces"): { + Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")}, + Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")}, }, - component.NewID(component.MustNewType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver")), component.NewIDWithName(component.MustNewType("examplereceiver"), "1")}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter")), component.NewIDWithName(component.MustNewType("exampleexporter"), "1")}, + component.MustNewID("metrics"): { + Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")}, + Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")}, }, - component.NewID(component.MustNewType("logs")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver")), component.NewIDWithName(component.MustNewType("examplereceiver"), "1")}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter")), component.NewIDWithName(component.MustNewType("exampleexporter"), "1")}, + component.MustNewID("logs"): { + Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")}, + Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")}, }, }, expectedPerExporter: 2, @@ -349,32 +349,32 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "multi_pipeline_receivers_and_exporters.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustNewType("traces")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("traces"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewIDWithName(component.MustNewType("traces"), "1"): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("traces", "1"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewID(component.MustNewType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("metrics"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "1"): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("metrics", "1"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewID(component.MustNewType("logs")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("logs"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewIDWithName(component.MustNewType("logs"), "1"): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("logs", "1"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, }, expectedPerExporter: 2, @@ -382,15 +382,15 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_simple_traces.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + component.MustNewIDWithName("traces", "in"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.NewIDWithName(component.MustNewType("traces"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("traces", "out"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, }, expectedPerExporter: 1, @@ -398,15 +398,15 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_simple_metrics.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + component.MustNewIDWithName("metrics", "in"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("metrics", "out"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, }, expectedPerExporter: 1, @@ -414,15 +414,15 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_simple_logs.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("logs"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + component.MustNewIDWithName("logs", "in"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.NewIDWithName(component.MustNewType("logs"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("logs", "out"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, }, expectedPerExporter: 1, @@ -430,25 +430,25 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_fork_merge_traces.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + component.MustNewIDWithName("traces", "in"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.NewIDWithName(component.MustNewType("traces"), "type0"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "merge")}, + component.MustNewIDWithName("traces", "type0"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, }, - component.NewIDWithName(component.MustNewType("traces"), "type1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "merge")}, + component.MustNewIDWithName("traces", "type1"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, }, - component.NewIDWithName(component.MustNewType("traces"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "merge")}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("traces", "out"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, }, expectedPerExporter: 2, @@ -456,25 +456,25 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_fork_merge_metrics.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + component.MustNewIDWithName("metrics", "in"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "type0"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "merge")}, + component.MustNewIDWithName("metrics", "type0"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "type1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "merge")}, + component.MustNewIDWithName("metrics", "type1"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "merge")}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("metrics", "out"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, }, expectedPerExporter: 2, @@ -482,25 +482,25 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_fork_merge_logs.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("logs"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + component.MustNewIDWithName("logs", "in"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.NewIDWithName(component.MustNewType("logs"), "type0"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "merge")}, + component.MustNewIDWithName("logs", "type0"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, }, - component.NewIDWithName(component.MustNewType("logs"), "type1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "merge")}, + component.MustNewIDWithName("logs", "type1"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, }, - component.NewIDWithName(component.MustNewType("logs"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "merge")}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("logs", "out"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, }, expectedPerExporter: 2, @@ -508,20 +508,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_translate_from_traces.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustNewType("traces")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleconnector"))}, + component.MustNewID("traces"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleconnector")}, }, - component.NewID(component.MustNewType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustNewType("exampleconnector"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("metrics"): { + Receivers: []component.ID{component.MustNewID("exampleconnector")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewID(component.MustNewType("logs")): { - Receivers: []component.ID{component.NewID(component.MustNewType("exampleconnector"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("logs"): { + Receivers: []component.ID{component.MustNewID("exampleconnector")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, }, expectedPerExporter: 1, @@ -529,20 +529,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_translate_from_metrics.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustNewType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleconnector"))}, + component.MustNewID("metrics"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleconnector")}, }, - component.NewID(component.MustNewType("traces")): { - Receivers: []component.ID{component.NewID(component.MustNewType("exampleconnector"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("traces"): { + Receivers: []component.ID{component.MustNewID("exampleconnector")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewID(component.MustNewType("logs")): { - Receivers: []component.ID{component.NewID(component.MustNewType("exampleconnector"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("logs"): { + Receivers: []component.ID{component.MustNewID("exampleconnector")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, }, expectedPerExporter: 1, @@ -550,20 +550,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_translate_from_logs.yaml", pipelineConfigs: pipelines.Config{ - component.NewID(component.MustNewType("logs")): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleconnector"))}, + component.MustNewID("logs"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleconnector")}, }, - component.NewID(component.MustNewType("traces")): { - Receivers: []component.ID{component.NewID(component.MustNewType("exampleconnector"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("traces"): { + Receivers: []component.ID{component.MustNewID("exampleconnector")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewID(component.MustNewType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustNewType("exampleconnector"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewID("metrics"): { + Receivers: []component.ID{component.MustNewID("exampleconnector")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, }, expectedPerExporter: 1, @@ -571,35 +571,35 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_matrix.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + component.MustNewIDWithName("traces", "in"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + component.MustNewIDWithName("metrics", "in"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.NewIDWithName(component.MustNewType("logs"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + component.MustNewIDWithName("logs", "in"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.NewIDWithName(component.MustNewType("traces"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("traces", "out"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("metrics", "out"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewIDWithName(component.MustNewType("logs"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate")}, // mutate propagates upstream to connector - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("logs", "out"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, + Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, }, expectedPerExporter: 3, @@ -607,29 +607,29 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_lanes.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("mockforward"))}, + component.MustNewIDWithName("traces", "in"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Exporters: []component.ID{component.MustNewID("mockforward")}, }, - component.NewIDWithName(component.MustNewType("traces"), "out"): { - Receivers: []component.ID{component.NewID(component.MustNewType("mockforward"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("traces", "out"): { + Receivers: []component.ID{component.MustNewID("mockforward")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("mockforward"))}, + component.MustNewIDWithName("metrics", "in"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Exporters: []component.ID{component.MustNewID("mockforward")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "out"): { - Receivers: []component.ID{component.NewID(component.MustNewType("mockforward"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("metrics", "out"): { + Receivers: []component.ID{component.MustNewID("mockforward")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewIDWithName(component.MustNewType("logs"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("mockforward"))}, + component.MustNewIDWithName("logs", "in"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Exporters: []component.ID{component.MustNewID("mockforward")}, }, - component.NewIDWithName(component.MustNewType("logs"), "out"): { - Receivers: []component.ID{component.NewID(component.MustNewType("mockforward"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("logs", "out"): { + Receivers: []component.ID{component.MustNewID("mockforward")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, }, expectedPerExporter: 1, @@ -637,25 +637,25 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_mutate_traces.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + component.MustNewIDWithName("traces", "in"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.NewIDWithName(component.MustNewType("traces"), "out0"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("traces", "out0"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewIDWithName(component.MustNewType("traces"), "middle"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "mutate")}, + component.MustNewIDWithName("traces", "middle"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")}, }, - component.NewIDWithName(component.MustNewType("traces"), "out1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "mutate")}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("traces", "out1"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, }, expectedPerExporter: 2, @@ -663,25 +663,25 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_mutate_metrics.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + component.MustNewIDWithName("metrics", "in"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "out0"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("metrics", "out0"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "middle"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "mutate")}, + component.MustNewIDWithName("metrics", "middle"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "out1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "mutate")}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("metrics", "out1"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, }, expectedPerExporter: 2, @@ -689,25 +689,25 @@ func TestConnectorPipelinesGraph(t *testing.T) { { name: "pipelines_conn_mutate_logs.yaml", pipelineConfigs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("logs"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("examplereceiver"))}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, + component.MustNewIDWithName("logs", "in"): { + Receivers: []component.ID{component.MustNewID("examplereceiver")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.NewIDWithName(component.MustNewType("logs"), "out0"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("logs", "out0"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.NewIDWithName(component.MustNewType("logs"), "middle"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate")}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "mutate")}, + component.MustNewIDWithName("logs", "middle"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")}, }, - component.NewIDWithName(component.MustNewType("logs"), "out1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("exampleconnector"), "mutate")}, - Processors: []component.ID{component.NewID(component.MustNewType("exampleprocessor"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("exampleexporter"))}, + component.MustNewIDWithName("logs", "out1"): { + Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")}, + Processors: []component.ID{component.MustNewID("exampleprocessor")}, + Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, }, expectedPerExporter: 2, @@ -722,8 +722,8 @@ func TestConnectorPipelinesGraph(t *testing.T) { BuildInfo: component.NewDefaultBuildInfo(), ReceiverBuilder: receiver.NewBuilder( map[component.ID]component.Config{ - component.NewID(component.MustNewType("examplereceiver")): testcomponents.ExampleReceiverFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustNewType("examplereceiver"), "1"): testcomponents.ExampleReceiverFactory.CreateDefaultConfig(), + component.MustNewID("examplereceiver"): testcomponents.ExampleReceiverFactory.CreateDefaultConfig(), + component.MustNewIDWithName("examplereceiver", "1"): testcomponents.ExampleReceiverFactory.CreateDefaultConfig(), }, map[component.Type]receiver.Factory{ testcomponents.ExampleReceiverFactory.Type(): testcomponents.ExampleReceiverFactory, @@ -731,8 +731,8 @@ func TestConnectorPipelinesGraph(t *testing.T) { ), ProcessorBuilder: processor.NewBuilder( map[component.ID]component.Config{ - component.NewID(component.MustNewType("exampleprocessor")): testcomponents.ExampleProcessorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustNewType("exampleprocessor"), "mutate"): testcomponents.ExampleProcessorFactory.CreateDefaultConfig(), + component.MustNewID("exampleprocessor"): testcomponents.ExampleProcessorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("exampleprocessor", "mutate"): testcomponents.ExampleProcessorFactory.CreateDefaultConfig(), }, map[component.Type]processor.Factory{ testcomponents.ExampleProcessorFactory.Type(): testcomponents.ExampleProcessorFactory, @@ -740,8 +740,8 @@ func TestConnectorPipelinesGraph(t *testing.T) { ), ExporterBuilder: exporter.NewBuilder( map[component.ID]component.Config{ - component.NewID(component.MustNewType("exampleexporter")): testcomponents.ExampleExporterFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustNewType("exampleexporter"), "1"): testcomponents.ExampleExporterFactory.CreateDefaultConfig(), + component.MustNewID("exampleexporter"): testcomponents.ExampleExporterFactory.CreateDefaultConfig(), + component.MustNewIDWithName("exampleexporter", "1"): testcomponents.ExampleExporterFactory.CreateDefaultConfig(), }, map[component.Type]exporter.Factory{ testcomponents.ExampleExporterFactory.Type(): testcomponents.ExampleExporterFactory, @@ -749,11 +749,11 @@ func TestConnectorPipelinesGraph(t *testing.T) { ), ConnectorBuilder: connector.NewBuilder( map[component.ID]component.Config{ - component.NewID(component.MustNewType("exampleconnector")): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustNewType("exampleconnector"), "merge"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustNewType("exampleconnector"), "mutate"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustNewType("exampleconnector"), "inherit_mutate"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), - component.NewID(component.MustNewType("mockforward")): testcomponents.MockForwardConnectorFactory.CreateDefaultConfig(), + component.MustNewID("exampleconnector"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("exampleconnector", "merge"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("exampleconnector", "mutate"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("exampleconnector", "inherit_mutate"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(), + component.MustNewID("mockforward"): testcomponents.MockForwardConnectorFactory.CreateDefaultConfig(), }, map[component.Type]connector.Factory{ testcomponents.ExampleConnectorFactory.Type(): testcomponents.ExampleConnectorFactory, @@ -984,24 +984,24 @@ func TestConnectorPipelinesGraph(t *testing.T) { } func TestConnectorRouter(t *testing.T) { - rcvrID := component.NewID(component.MustNewType("examplereceiver")) - routeTracesID := component.NewIDWithName(component.MustNewType("examplerouter"), "traces") - routeMetricsID := component.NewIDWithName(component.MustNewType("examplerouter"), "metrics") - routeLogsID := component.NewIDWithName(component.MustNewType("examplerouter"), "logs") - expRightID := component.NewIDWithName(component.MustNewType("exampleexporter"), "right") - expLeftID := component.NewIDWithName(component.MustNewType("exampleexporter"), "left") + rcvrID := component.MustNewID("examplereceiver") + routeTracesID := component.MustNewIDWithName("examplerouter", "traces") + routeMetricsID := component.MustNewIDWithName("examplerouter", "metrics") + routeLogsID := component.MustNewIDWithName("examplerouter", "logs") + expRightID := component.MustNewIDWithName("exampleexporter", "right") + expLeftID := component.MustNewIDWithName("exampleexporter", "left") - tracesInID := component.NewIDWithName(component.MustNewType("traces"), "in") - tracesRightID := component.NewIDWithName(component.MustNewType("traces"), "right") - tracesLeftID := component.NewIDWithName(component.MustNewType("traces"), "left") + tracesInID := component.MustNewIDWithName("traces", "in") + tracesRightID := component.MustNewIDWithName("traces", "right") + tracesLeftID := component.MustNewIDWithName("traces", "left") - metricsInID := component.NewIDWithName(component.MustNewType("metrics"), "in") - metricsRightID := component.NewIDWithName(component.MustNewType("metrics"), "right") - metricsLeftID := component.NewIDWithName(component.MustNewType("metrics"), "left") + metricsInID := component.MustNewIDWithName("metrics", "in") + metricsRightID := component.MustNewIDWithName("metrics", "right") + metricsLeftID := component.MustNewIDWithName("metrics", "left") - logsInID := component.NewIDWithName(component.MustNewType("logs"), "in") - logsRightID := component.NewIDWithName(component.MustNewType("logs"), "right") - logsLeftID := component.NewIDWithName(component.MustNewType("logs"), "left") + logsInID := component.MustNewIDWithName("logs", "in") + logsRightID := component.MustNewIDWithName("logs", "right") + logsLeftID := component.MustNewIDWithName("logs", "left") ctx := context.Background() set := Settings{ @@ -1188,15 +1188,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_exporter_logs", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("bf")): badExporterFactory.CreateDefaultConfig(), + component.MustNewID("bf"): badExporterFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustNewType("logs")): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, + component.MustNewID("logs"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("bf")}, }, }, expected: "failed to create \"bf\" exporter for data type \"logs\": telemetry type is not supported", @@ -1204,15 +1204,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_exporter_metrics", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("bf")): badExporterFactory.CreateDefaultConfig(), + component.MustNewID("bf"): badExporterFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustNewType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, + component.MustNewID("metrics"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("bf")}, }, }, expected: "failed to create \"bf\" exporter for data type \"metrics\": telemetry type is not supported", @@ -1220,15 +1220,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_exporter_traces", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("bf")): badExporterFactory.CreateDefaultConfig(), + component.MustNewID("bf"): badExporterFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustNewType("traces")): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, + component.MustNewID("traces"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("bf")}, }, }, expected: "failed to create \"bf\" exporter for data type \"traces\": telemetry type is not supported", @@ -1236,19 +1236,19 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_processor_logs", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("bf")): badProcessorFactory.CreateDefaultConfig(), + component.MustNewID("bf"): badProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustNewType("logs")): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Processors: []component.ID{component.NewID(component.MustNewType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewID("logs"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Processors: []component.ID{component.MustNewID("bf")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "failed to create \"bf\" processor, in pipeline \"logs\": telemetry type is not supported", @@ -1256,19 +1256,19 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_processor_metrics", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("bf")): badProcessorFactory.CreateDefaultConfig(), + component.MustNewID("bf"): badProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustNewType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Processors: []component.ID{component.NewID(component.MustNewType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewID("metrics"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Processors: []component.ID{component.MustNewID("bf")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "failed to create \"bf\" processor, in pipeline \"metrics\": telemetry type is not supported", @@ -1276,19 +1276,19 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_processor_traces", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("bf")): badProcessorFactory.CreateDefaultConfig(), + component.MustNewID("bf"): badProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustNewType("traces")): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Processors: []component.ID{component.NewID(component.MustNewType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewID("traces"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Processors: []component.ID{component.MustNewID("bf")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "failed to create \"bf\" processor, in pipeline \"traces\": telemetry type is not supported", @@ -1296,15 +1296,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_receiver_logs", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("bf")): badReceiverFactory.CreateDefaultConfig(), + component.MustNewID("bf"): badReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustNewType("logs")): { - Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewID("logs"): { + Receivers: []component.ID{component.MustNewID("bf")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "failed to create \"bf\" receiver for data type \"logs\": telemetry type is not supported", @@ -1312,15 +1312,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_receiver_metrics", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("bf")): badReceiverFactory.CreateDefaultConfig(), + component.MustNewID("bf"): badReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustNewType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewID("metrics"): { + Receivers: []component.ID{component.MustNewID("bf")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "failed to create \"bf\" receiver for data type \"metrics\": telemetry type is not supported", @@ -1328,15 +1328,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_receiver_traces", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("bf")): badReceiverFactory.CreateDefaultConfig(), + component.MustNewID("bf"): badReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustNewType("traces")): { - Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewID("traces"): { + Receivers: []component.ID{component.MustNewID("bf")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "failed to create \"bf\" receiver for data type \"traces\": telemetry type is not supported", @@ -1344,22 +1344,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_traces_traces.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("bf")): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, + component.MustNewIDWithName("traces", "in"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("bf")}, }, - component.NewIDWithName(component.MustNewType("traces"), "out"): { - Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewIDWithName("traces", "out"): { + Receivers: []component.ID{component.MustNewID("bf")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "connector \"bf\" used as exporter in traces pipeline but not used in any supported receiver pipeline", @@ -1367,22 +1367,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_traces_metrics.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("bf")): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, + component.MustNewIDWithName("traces", "in"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("bf")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "out"): { - Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewIDWithName("metrics", "out"): { + Receivers: []component.ID{component.MustNewID("bf")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "connector \"bf\" used as exporter in traces pipeline but not used in any supported receiver pipeline", @@ -1390,22 +1390,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_traces_logs.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("bf")): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, + component.MustNewIDWithName("traces", "in"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("bf")}, }, - component.NewIDWithName(component.MustNewType("logs"), "out"): { - Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewIDWithName("logs", "out"): { + Receivers: []component.ID{component.MustNewID("bf")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "connector \"bf\" used as exporter in traces pipeline but not used in any supported receiver pipeline", @@ -1413,22 +1413,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_metrics_traces.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("bf")): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, + component.MustNewIDWithName("metrics", "in"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("bf")}, }, - component.NewIDWithName(component.MustNewType("traces"), "out"): { - Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewIDWithName("traces", "out"): { + Receivers: []component.ID{component.MustNewID("bf")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "connector \"bf\" used as exporter in metrics pipeline but not used in any supported receiver pipeline", @@ -1436,22 +1436,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_metrics_metrics.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("bf")): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, + component.MustNewIDWithName("metrics", "in"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("bf")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "out"): { - Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewIDWithName("metrics", "out"): { + Receivers: []component.ID{component.MustNewID("bf")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "connector \"bf\" used as exporter in metrics pipeline but not used in any supported receiver pipeline", @@ -1459,22 +1459,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_metrics_logs.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("bf")): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, + component.MustNewIDWithName("metrics", "in"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("bf")}, }, - component.NewIDWithName(component.MustNewType("logs"), "out"): { - Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewIDWithName("logs", "out"): { + Receivers: []component.ID{component.MustNewID("bf")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "connector \"bf\" used as exporter in metrics pipeline but not used in any supported receiver pipeline", @@ -1482,22 +1482,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_logs_traces.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("bf")): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("logs"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, + component.MustNewIDWithName("logs", "in"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("bf")}, }, - component.NewIDWithName(component.MustNewType("traces"), "out"): { - Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewIDWithName("traces", "out"): { + Receivers: []component.ID{component.MustNewID("bf")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "connector \"bf\" used as exporter in logs pipeline but not used in any supported receiver pipeline", @@ -1505,22 +1505,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_logs_metrics.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("bf")): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("logs"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, + component.MustNewIDWithName("logs", "in"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("bf")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "out"): { - Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewIDWithName("metrics", "out"): { + Receivers: []component.ID{component.MustNewID("bf")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "connector \"bf\" used as exporter in logs pipeline but not used in any supported receiver pipeline", @@ -1528,22 +1528,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_supported_connector_logs_logs.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("bf")): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("logs"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("bf"))}, + component.MustNewIDWithName("logs", "in"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("bf")}, }, - component.NewIDWithName(component.MustNewType("logs"), "out"): { - Receivers: []component.ID{component.NewID(component.MustNewType("bf"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewIDWithName("logs", "out"): { + Receivers: []component.ID{component.MustNewID("bf")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "connector \"bf\" used as exporter in logs pipeline but not used in any supported receiver pipeline", @@ -1551,18 +1551,18 @@ func TestGraphBuildErrors(t *testing.T) { { name: "orphaned-connector-use-as-exporter", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName(component.MustNewType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, + component.MustNewIDWithName("metrics", "in"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")}, }, }, expected: `connector "nop/conn" used as exporter in metrics pipeline but not used in any supported receiver pipeline`, @@ -1570,18 +1570,18 @@ func TestGraphBuildErrors(t *testing.T) { { name: "orphaned-connector-use-as-receiver", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName(component.MustNewType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("traces"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewIDWithName("traces", "out"): { + Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: `connector "nop/conn" used as receiver in traces pipeline but not used in any supported exporter pipeline`, @@ -1589,26 +1589,26 @@ func TestGraphBuildErrors(t *testing.T) { { name: "partially-orphaned-connector-use-as-exporter", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("mockforward")): mfConnectorFactory.CreateDefaultConfig(), + component.MustNewID("mockforward"): mfConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("mockforward"))}, + component.MustNewIDWithName("traces", "in"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("mockforward")}, }, - component.NewIDWithName(component.MustNewType("traces"), "out"): { - Receivers: []component.ID{component.NewID(component.MustNewType("mockforward"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewIDWithName("traces", "out"): { + Receivers: []component.ID{component.MustNewID("mockforward")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("mockforward"))}, + component.MustNewIDWithName("metrics", "in"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("mockforward")}, }, }, expected: `connector "mockforward" used as exporter in metrics pipeline but not used in any supported receiver pipeline`, @@ -1616,26 +1616,26 @@ func TestGraphBuildErrors(t *testing.T) { { name: "partially-orphaned-connector-use-as-receiver", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("mockforward")): mfConnectorFactory.CreateDefaultConfig(), + component.MustNewID("mockforward"): mfConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("mockforward"))}, + component.MustNewIDWithName("metrics", "in"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("mockforward")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "out"): { - Receivers: []component.ID{component.NewID(component.MustNewType("mockforward"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewIDWithName("metrics", "out"): { + Receivers: []component.ID{component.MustNewID("mockforward")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, - component.NewIDWithName(component.MustNewType("traces"), "out"): { - Receivers: []component.ID{component.NewID(component.MustNewType("mockforward"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewIDWithName("traces", "out"): { + Receivers: []component.ID{component.MustNewID("mockforward")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: `connector "mockforward" used as receiver in traces pipeline but not used in any supported exporter pipeline`, @@ -1643,22 +1643,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_simple_cycle_traces.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopProcessorFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName(component.MustNewType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustNewType("traces")): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, + component.MustNewID("traces"): { + Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")}, }, }, expected: `cycle detected: ` + @@ -1669,22 +1669,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_simple_cycle_metrics.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopProcessorFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName(component.MustNewType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustNewType("metrics")): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, + component.MustNewID("metrics"): { + Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")}, }, }, expected: `cycle detected: ` + @@ -1695,22 +1695,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_simple_cycle_logs.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopProcessorFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName(component.MustNewType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustNewType("logs")): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, + component.MustNewID("logs"): { + Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")}, }, }, expected: `cycle detected: ` + @@ -1721,39 +1721,39 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_deep_cycle_traces.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopProcessorFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName(component.MustNewType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustNewType("nop"), "conn1"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustNewType("nop"), "conn2"): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("nop", "conn1"): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("nop", "conn2"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, + component.MustNewIDWithName("traces", "in"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")}, }, - component.NewIDWithName(component.MustNewType("traces"), "1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn1")}, + component.MustNewIDWithName("traces", "1"): { + Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewIDWithName("nop", "conn1")}, }, - component.NewIDWithName(component.MustNewType("traces"), "2"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn1")}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn2"), component.NewIDWithName(component.MustNewType("nop"), "conn")}, + component.MustNewIDWithName("traces", "2"): { + Receivers: []component.ID{component.MustNewIDWithName("nop", "conn1")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewIDWithName("nop", "conn2"), component.MustNewIDWithName("nop", "conn")}, }, - component.NewIDWithName(component.MustNewType("traces"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn2")}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewIDWithName("traces", "out"): { + Receivers: []component.ID{component.MustNewIDWithName("nop", "conn2")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: `cycle detected: ` + @@ -1766,39 +1766,39 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_deep_cycle_metrics.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopProcessorFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName(component.MustNewType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustNewType("nop"), "conn1"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustNewType("nop"), "conn2"): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("nop", "conn1"): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("nop", "conn2"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("metrics"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, + component.MustNewIDWithName("metrics", "in"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn1")}, + component.MustNewIDWithName("metrics", "1"): { + Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewIDWithName("nop", "conn1")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "2"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn1")}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn2"), component.NewIDWithName(component.MustNewType("nop"), "conn")}, + component.MustNewIDWithName("metrics", "2"): { + Receivers: []component.ID{component.MustNewIDWithName("nop", "conn1")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewIDWithName("nop", "conn2"), component.MustNewIDWithName("nop", "conn")}, }, - component.NewIDWithName(component.MustNewType("metrics"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn2")}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewIDWithName("metrics", "out"): { + Receivers: []component.ID{component.MustNewIDWithName("nop", "conn2")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: `cycle detected: ` + @@ -1811,39 +1811,39 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_deep_cycle_logs.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopProcessorFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName(component.MustNewType("nop"), "conn"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustNewType("nop"), "conn1"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustNewType("nop"), "conn2"): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("nop", "conn1"): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("nop", "conn2"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("logs"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, + component.MustNewIDWithName("logs", "in"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")}, }, - component.NewIDWithName(component.MustNewType("logs"), "1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn")}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn1")}, + component.MustNewIDWithName("logs", "1"): { + Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewIDWithName("nop", "conn1")}, }, - component.NewIDWithName(component.MustNewType("logs"), "2"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn1")}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn2"), component.NewIDWithName(component.MustNewType("nop"), "conn")}, + component.MustNewIDWithName("logs", "2"): { + Receivers: []component.ID{component.MustNewIDWithName("nop", "conn1")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewIDWithName("nop", "conn2"), component.MustNewIDWithName("nop", "conn")}, }, - component.NewIDWithName(component.MustNewType("logs"), "out"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "conn2")}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewIDWithName("logs", "out"): { + Receivers: []component.ID{component.MustNewIDWithName("nop", "conn2")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: `cycle detected: ` + @@ -1856,55 +1856,55 @@ func TestGraphBuildErrors(t *testing.T) { { name: "not_allowed_deep_cycle_multi_signal.yaml", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopProcessorFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopExporterFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewIDWithName(component.MustNewType("nop"), "fork"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustNewType("nop"), "count"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustNewType("nop"), "forkagain"): nopConnectorFactory.CreateDefaultConfig(), - component.NewIDWithName(component.MustNewType("nop"), "rawlog"): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("nop", "fork"): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("nop", "count"): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("nop", "forkagain"): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewIDWithName("nop", "rawlog"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "fork")}, - }, - component.NewIDWithName(component.MustNewType("traces"), "copy1"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "fork")}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "count")}, - }, - component.NewIDWithName(component.MustNewType("traces"), "copy2"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "fork")}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "forkagain")}, - }, - component.NewIDWithName(component.MustNewType("traces"), "copy2a"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "forkagain")}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "count")}, - }, - component.NewIDWithName(component.MustNewType("traces"), "copy2b"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "forkagain")}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "rawlog")}, - }, - component.NewIDWithName(component.MustNewType("metrics"), "count"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "count")}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, - }, - component.NewIDWithName(component.MustNewType("logs"), "raw"): { - Receivers: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "rawlog")}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewIDWithName(component.MustNewType("nop"), "fork")}, // cannot loop back to "nop/fork" + component.MustNewIDWithName("traces", "in"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewIDWithName("nop", "fork")}, + }, + component.MustNewIDWithName("traces", "copy1"): { + Receivers: []component.ID{component.MustNewIDWithName("nop", "fork")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewIDWithName("nop", "count")}, + }, + component.MustNewIDWithName("traces", "copy2"): { + Receivers: []component.ID{component.MustNewIDWithName("nop", "fork")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewIDWithName("nop", "forkagain")}, + }, + component.MustNewIDWithName("traces", "copy2a"): { + Receivers: []component.ID{component.MustNewIDWithName("nop", "forkagain")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewIDWithName("nop", "count")}, + }, + component.MustNewIDWithName("traces", "copy2b"): { + Receivers: []component.ID{component.MustNewIDWithName("nop", "forkagain")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewIDWithName("nop", "rawlog")}, + }, + component.MustNewIDWithName("metrics", "count"): { + Receivers: []component.ID{component.MustNewIDWithName("nop", "count")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("nop")}, + }, + component.MustNewIDWithName("logs", "raw"): { + Receivers: []component.ID{component.MustNewIDWithName("nop", "rawlog")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewIDWithName("nop", "fork")}, // cannot loop back to "nop/fork" }, }, expected: `cycle detected: ` + @@ -1919,15 +1919,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_exporter_config", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustNewType("traces")): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop")), component.NewIDWithName(component.MustNewType("nop"), "1")}, + component.MustNewID("traces"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("nop"), component.MustNewIDWithName("nop", "1")}, }, }, expected: "failed to create \"nop/1\" exporter for data type \"traces\": exporter \"nop/1\" is not configured", @@ -1935,15 +1935,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_exporter_factory", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("unknown")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("unknown"): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustNewType("traces")): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("unknown"))}, + component.MustNewID("traces"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("unknown")}, }, }, expected: "failed to create \"unknown\" exporter for data type \"traces\": exporter factory not available for: \"unknown\"", @@ -1951,19 +1951,19 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_processor_config", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopProcessorFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustNewType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Processors: []component.ID{component.NewID(component.MustNewType("nop")), component.NewIDWithName(component.MustNewType("nop"), "1")}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewID("metrics"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Processors: []component.ID{component.MustNewID("nop"), component.MustNewIDWithName("nop", "1")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "failed to create \"nop/1\" processor, in pipeline \"metrics\": processor \"nop/1\" is not configured", @@ -1971,19 +1971,19 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_processor_factory", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, processorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("unknown")): nopProcessorFactory.CreateDefaultConfig(), + component.MustNewID("unknown"): nopProcessorFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustNewType("metrics")): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Processors: []component.ID{component.NewID(component.MustNewType("unknown"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewID("metrics"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Processors: []component.ID{component.MustNewID("unknown")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "failed to create \"unknown\" processor, in pipeline \"metrics\": processor factory not available for: \"unknown\"", @@ -1991,15 +1991,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_receiver_config", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustNewType("logs")): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop")), component.NewIDWithName(component.MustNewType("nop"), "1")}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewID("logs"): { + Receivers: []component.ID{component.MustNewID("nop"), component.MustNewIDWithName("nop", "1")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "failed to create \"nop/1\" receiver for data type \"logs\": receiver \"nop/1\" is not configured", @@ -2007,15 +2007,15 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_receiver_factory", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("unknown")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("unknown"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewID(component.MustNewType("logs")): { - Receivers: []component.ID{component.NewID(component.MustNewType("unknown"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewID("logs"): { + Receivers: []component.ID{component.MustNewID("unknown")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "failed to create \"unknown\" receiver for data type \"logs\": receiver factory not available for: \"unknown\"", @@ -2023,22 +2023,22 @@ func TestGraphBuildErrors(t *testing.T) { { name: "unknown_connector_factory", receiverCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, exporterCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("nop")): nopReceiverFactory.CreateDefaultConfig(), + component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, connectorCfgs: map[component.ID]component.Config{ - component.NewID(component.MustNewType("unknown")): nopConnectorFactory.CreateDefaultConfig(), + component.MustNewID("unknown"): nopConnectorFactory.CreateDefaultConfig(), }, pipelineCfgs: pipelines.Config{ - component.NewIDWithName(component.MustNewType("traces"), "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("unknown"))}, + component.MustNewIDWithName("traces", "in"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("unknown")}, }, - component.NewIDWithName(component.MustNewType("traces"), "out"): { - Receivers: []component.ID{component.NewID(component.MustNewType("unknown"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewIDWithName("traces", "out"): { + Receivers: []component.ID{component.MustNewID("unknown")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, }, expected: "connector factory not available for: \"unknown\"", @@ -2141,9 +2141,9 @@ func TestGraphFailToStartAndShutdown(t *testing.T) { t.Run(dt.String()+"/receiver", func(t *testing.T) { set.PipelineConfigs = pipelines.Config{ component.NewID(dt): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop")), component.NewID(component.MustNewType("err"))}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + Receivers: []component.ID{component.MustNewID("nop"), component.MustNewID("err")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, } pipelines, err := Build(context.Background(), set) @@ -2155,9 +2155,9 @@ func TestGraphFailToStartAndShutdown(t *testing.T) { t.Run(dt.String()+"/processor", func(t *testing.T) { set.PipelineConfigs = pipelines.Config{ component.NewID(dt): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Processors: []component.ID{component.NewID(component.MustNewType("nop")), component.NewID(component.MustNewType("err"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + Receivers: []component.ID{component.MustNewID("nop")}, + Processors: []component.ID{component.MustNewID("nop"), component.MustNewID("err")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, } pipelines, err := Build(context.Background(), set) @@ -2169,9 +2169,9 @@ func TestGraphFailToStartAndShutdown(t *testing.T) { t.Run(dt.String()+"/exporter", func(t *testing.T) { set.PipelineConfigs = pipelines.Config{ component.NewID(dt): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop")), component.NewID(component.MustNewType("err"))}, + Receivers: []component.ID{component.MustNewID("nop")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("nop"), component.MustNewID("err")}, }, } pipelines, err := Build(context.Background(), set) @@ -2184,14 +2184,14 @@ func TestGraphFailToStartAndShutdown(t *testing.T) { t.Run(dt.String()+"/"+dt2.String()+"/connector", func(t *testing.T) { set.PipelineConfigs = pipelines.Config{ component.NewIDWithName(dt, "in"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop")), component.NewIDWithName(component.MustNewType("err"), "conn")}, + Receivers: []component.ID{component.MustNewID("nop")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("nop"), component.MustNewIDWithName("err", "conn")}, }, component.NewIDWithName(dt2, "out"): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop")), component.NewIDWithName(component.MustNewType("err"), "conn")}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + Receivers: []component.ID{component.MustNewID("nop"), component.MustNewIDWithName("err", "conn")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, } pipelines, err := Build(context.Background(), set) @@ -2205,13 +2205,13 @@ func TestGraphFailToStartAndShutdown(t *testing.T) { func TestStatusReportedOnStartupShutdown(t *testing.T) { - rNoErr := &testNode{id: component.NewIDWithName(component.MustNewType("r_no_err"), "1")} - rStErr := &testNode{id: component.NewIDWithName(component.MustNewType("r_st_err"), "1"), startErr: assert.AnError} - rSdErr := &testNode{id: component.NewIDWithName(component.MustNewType("r_sd_err"), "1"), shutdownErr: assert.AnError} + rNoErr := &testNode{id: component.MustNewIDWithName("r_no_err", "1")} + rStErr := &testNode{id: component.MustNewIDWithName("r_st_err", "1"), startErr: assert.AnError} + rSdErr := &testNode{id: component.MustNewIDWithName("r_sd_err", "1"), shutdownErr: assert.AnError} - eNoErr := &testNode{id: component.NewIDWithName(component.MustNewType("e_no_err"), "1")} - eStErr := &testNode{id: component.NewIDWithName(component.MustNewType("e_st_err"), "1"), startErr: assert.AnError} - eSdErr := &testNode{id: component.NewIDWithName(component.MustNewType("e_sd_err"), "1"), shutdownErr: assert.AnError} + eNoErr := &testNode{id: component.MustNewIDWithName("e_no_err", "1")} + eStErr := &testNode{id: component.MustNewIDWithName("e_st_err", "1"), startErr: assert.AnError} + eSdErr := &testNode{id: component.MustNewIDWithName("e_sd_err", "1"), shutdownErr: assert.AnError} instanceIDs := map[*testNode]*component.InstanceID{ rNoErr: {ID: rNoErr.id}, diff --git a/service/internal/testcomponents/example_router_test.go b/service/internal/testcomponents/example_router_test.go index 71e368a4c5f..23f94854b2a 100644 --- a/service/internal/testcomponents/example_router_test.go +++ b/service/internal/testcomponents/example_router_test.go @@ -31,8 +31,8 @@ func TestExampleRouter(t *testing.T) { } func TestTracesRouter(t *testing.T) { - leftID := component.NewIDWithName(component.MustNewType("sink"), "left") - rightID := component.NewIDWithName(component.MustNewType("sink"), "right") + leftID := component.MustNewIDWithName("sink", "left") + rightID := component.MustNewIDWithName("sink", "right") sinkLeft := new(consumertest.TracesSink) sinkRight := new(consumertest.TracesSink) @@ -70,8 +70,8 @@ func TestTracesRouter(t *testing.T) { } func TestMetricsRouter(t *testing.T) { - leftID := component.NewIDWithName(component.MustNewType("sink"), "left") - rightID := component.NewIDWithName(component.MustNewType("sink"), "right") + leftID := component.MustNewIDWithName("sink", "left") + rightID := component.MustNewIDWithName("sink", "right") sinkLeft := new(consumertest.MetricsSink) sinkRight := new(consumertest.MetricsSink) @@ -109,8 +109,8 @@ func TestMetricsRouter(t *testing.T) { } func TestLogsRouter(t *testing.T) { - leftID := component.NewIDWithName(component.MustNewType("sink"), "left") - rightID := component.NewIDWithName(component.MustNewType("sink"), "right") + leftID := component.MustNewIDWithName("sink", "left") + rightID := component.MustNewIDWithName("sink", "right") sinkLeft := new(consumertest.LogsSink) sinkRight := new(consumertest.LogsSink) diff --git a/service/pipelines/config_test.go b/service/pipelines/config_test.go index c9aa6d7b3fa..7ad94d5ab3f 100644 --- a/service/pipelines/config_test.go +++ b/service/pipelines/config_test.go @@ -28,7 +28,7 @@ func TestConfigValidate(t *testing.T) { name: "duplicate-processor-reference", cfgFn: func() Config { cfg := generateConfig() - pipe := cfg[component.NewID(component.MustNewType("traces"))] + pipe := cfg[component.MustNewID("traces")] pipe.Processors = append(pipe.Processors, pipe.Processors...) return cfg }, @@ -38,7 +38,7 @@ func TestConfigValidate(t *testing.T) { name: "missing-pipeline-receivers", cfgFn: func() Config { cfg := generateConfig() - cfg[component.NewID(component.MustNewType("traces"))].Receivers = nil + cfg[component.MustNewID("traces")].Receivers = nil return cfg }, expected: fmt.Errorf(`pipeline "traces": %w`, errMissingServicePipelineReceivers), @@ -47,7 +47,7 @@ func TestConfigValidate(t *testing.T) { name: "missing-pipeline-exporters", cfgFn: func() Config { cfg := generateConfig() - cfg[component.NewID(component.MustNewType("traces"))].Exporters = nil + cfg[component.MustNewID("traces")].Exporters = nil return cfg }, expected: fmt.Errorf(`pipeline "traces": %w`, errMissingServicePipelineExporters), @@ -63,10 +63,10 @@ func TestConfigValidate(t *testing.T) { name: "invalid-service-pipeline-type", cfgFn: func() Config { cfg := generateConfig() - cfg[component.NewID(component.MustNewType("wrongtype"))] = &PipelineConfig{ - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + cfg[component.MustNewID("wrongtype")] = &PipelineConfig{ + Receivers: []component.ID{component.MustNewID("nop")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("nop")}, } return cfg }, @@ -84,10 +84,10 @@ func TestConfigValidate(t *testing.T) { func generateConfig() Config { return map[component.ID]*PipelineConfig{ - component.NewID(component.MustNewType("traces")): { - Receivers: []component.ID{component.NewID(component.MustNewType("nop"))}, - Processors: []component.ID{component.NewID(component.MustNewType("nop"))}, - Exporters: []component.ID{component.NewID(component.MustNewType("nop"))}, + component.MustNewID("traces"): { + Receivers: []component.ID{component.MustNewID("nop")}, + Processors: []component.ID{component.MustNewID("nop")}, + Exporters: []component.ID{component.MustNewID("nop")}, }, } } diff --git a/service/service_test.go b/service/service_test.go index b26a4d2926d..172007ce277 100644 --- a/service/service_test.go +++ b/service/service_test.go @@ -240,7 +240,7 @@ func TestServiceGetExporters(t *testing.T) { // and another service with a valid config can be started right after. func TestServiceTelemetryCleanupOnError(t *testing.T) { invalidCfg := newNopConfig() - invalidCfg.Pipelines[component.NewID(component.MustNewType("traces"))].Processors[0] = component.NewID(component.MustNewType("invalid")) + invalidCfg.Pipelines[component.MustNewID("traces")].Processors[0] = component.MustNewID("invalid") // Create a service with an invalid config and expect an error _, err := New(context.Background(), newNopSettings(), invalidCfg) require.Error(t, err) @@ -275,12 +275,12 @@ func testCollectorStartHelper(t *testing.T, tc ownMetricsTestCase) { set := newNopSettings() set.BuildInfo = component.BuildInfo{Version: "test version", Command: otelCommand} set.Extensions = extension.NewBuilder( - map[component.ID]component.Config{component.NewID(component.MustNewType("zpages")): &zpagesextension.Config{TCPAddr: confignet.TCPAddr{Endpoint: zpagesAddr}}}, + map[component.ID]component.Config{component.MustNewID("zpages"): &zpagesextension.Config{TCPAddr: confignet.TCPAddr{Endpoint: zpagesAddr}}}, map[component.Type]extension.Factory{component.MustNewType("zpages"): zpagesextension.NewFactory()}) set.LoggingOptions = []zap.Option{zap.Hooks(hook)} cfg := newNopConfig() - cfg.Extensions = []component.ID{component.NewID(component.MustNewType("zpages"))} + cfg.Extensions = []component.ID{component.MustNewID("zpages")} cfg.Telemetry.Metrics.Address = metricsAddr cfg.Telemetry.Resource = make(map[string]*string) // Include resource attributes under the service::telemetry::resource key. @@ -532,17 +532,17 @@ func newNopSettings() Settings { func newNopConfig() Config { return newNopConfigPipelineConfigs(pipelines.Config{ - component.NewID(component.MustNewType("traces")): { + component.MustNewID("traces"): { Receivers: []component.ID{component.NewID(nopType)}, Processors: []component.ID{component.NewID(nopType)}, Exporters: []component.ID{component.NewID(nopType)}, }, - component.NewID(component.MustNewType("metrics")): { + component.MustNewID("metrics"): { Receivers: []component.ID{component.NewID(nopType)}, Processors: []component.ID{component.NewID(nopType)}, Exporters: []component.ID{component.NewID(nopType)}, }, - component.NewID(component.MustNewType("logs")): { + component.MustNewID("logs"): { Receivers: []component.ID{component.NewID(nopType)}, Processors: []component.ID{component.NewID(nopType)}, Exporters: []component.ID{component.NewID(nopType)}, From ecf6908901a1448452a53fedafd288d6af6291d9 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Wed, 31 Jan 2024 12:55:53 +0100 Subject: [PATCH 09/13] Fix comment --- component/identifiable.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/component/identifiable.go b/component/identifiable.go index 90dc64c8dd1..8444e2cf1b0 100644 --- a/component/identifiable.go +++ b/component/identifiable.go @@ -26,7 +26,7 @@ func NewID(typeVal Type) ID { return ID{typeVal: typeVal} } -// NewID builds a Type and returns a new ID with the given Type and empty name. +// MustNewID builds a Type and returns a new ID with the given Type and empty name. // See MustNewType to check the valid values of typeVal. func MustNewID(typeVal string) ID { return ID{typeVal: MustNewType(typeVal)} From 37eb056c43f6bd632eb0d556617c72e0961d8c24 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Wed, 31 Jan 2024 12:56:52 +0100 Subject: [PATCH 10/13] Make NewType public --- component/config.go | 8 ++++---- component/config_test.go | 2 +- component/identifiable.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/component/config.go b/component/config.go index ac346fbaa55..1e8217e430e 100644 --- a/component/config.go +++ b/component/config.go @@ -124,17 +124,17 @@ func (t Type) String() string { // can only contain ASCII alphanumeric characters and '_'. var typeRegexp = regexp.MustCompile(`^[a-zA-Z][0-9a-zA-Z_]*$`) -// newType creates a type. It returns an error if the type is invalid. +// NewType creates a type. It returns an error if the type is invalid. // A type must // - have at least one character, // - start with an ASCII alphabetic character and // - can only contain ASCII alphanumeric characters and '_'. -func newType(ty string) (Type, error) { +func NewType(ty string) (Type, error) { if len(ty) == 0 { return Type(""), fmt.Errorf("id must not be empty") } if !typeRegexp.MatchString(ty) { - return Type(""), fmt.Errorf("invalid character(s) in type") + return Type(""), fmt.Errorf("invalid character(s) in type %q", ty) } return Type(ty), nil } @@ -145,7 +145,7 @@ func newType(ty string) (Type, error) { // - start with an ASCII alphabetic character and // - can only contain ASCII alphanumeric characters and '_'. func MustNewType(strType string) Type { - ty, err := newType(strType) + ty, err := NewType(strType) if err != nil { panic(err) } diff --git a/component/config_test.go b/component/config_test.go index c93312eba57..4b1b89ff801 100644 --- a/component/config_test.go +++ b/component/config_test.go @@ -404,7 +404,7 @@ func TestNewType(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - ty, err := newType(tt.name) + ty, err := NewType(tt.name) if tt.shouldErr { assert.Error(t, err) } else { diff --git a/component/identifiable.go b/component/identifiable.go index 8444e2cf1b0..d2d65a5e24f 100644 --- a/component/identifiable.go +++ b/component/identifiable.go @@ -85,7 +85,7 @@ func (id *ID) UnmarshalText(text []byte) error { } var err error - if id.typeVal, err = newType(typeStr); err != nil { + if id.typeVal, err = NewType(typeStr); err != nil { return fmt.Errorf("in %q id: %w", idStr, err) } id.nameVal = nameStr From 03d90ac8ff86417842dc27c228e119b4f1dfdc2f Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Wed, 31 Jan 2024 13:15:27 +0100 Subject: [PATCH 11/13] Add validation also on mdatagen --- cmd/mdatagen/validate.go | 11 +++++++++++ component/config.go | 1 + 2 files changed, 12 insertions(+) diff --git a/cmd/mdatagen/validate.go b/cmd/mdatagen/validate.go index aac3e3a6898..bc56375baf9 100644 --- a/cmd/mdatagen/validate.go +++ b/cmd/mdatagen/validate.go @@ -6,6 +6,7 @@ package main import ( "errors" "fmt" + "regexp" "go.uber.org/multierr" @@ -29,10 +30,20 @@ func (md *metadata) Validate() error { return errs } +// typeRegexp is used to validate the type of a component. +// A type must start with an ASCII alphabetic character and +// can only contain ASCII alphanumeric characters and '_'. +// This must be kept in sync with the regex in component/config.go. +var typeRegexp = regexp.MustCompile(`^[a-zA-Z][0-9a-zA-Z_]*$`) + func (md *metadata) validateType() error { if md.Type == "" { return errors.New("missing type") } + + if !typeRegexp.MatchString(md.Type) { + return fmt.Errorf("invalid character(s) in type %q", md.Type) + } return nil } diff --git a/component/config.go b/component/config.go index 1e8217e430e..f20e9ad7388 100644 --- a/component/config.go +++ b/component/config.go @@ -122,6 +122,7 @@ func (t Type) String() string { // typeRegexp is used to validate the type of a component. // A type must start with an ASCII alphabetic character and // can only contain ASCII alphanumeric characters and '_'. +// This must be kept in sync with the regex in cmd/mdatagen/validate.go. var typeRegexp = regexp.MustCompile(`^[a-zA-Z][0-9a-zA-Z_]*$`) // NewType creates a type. It returns an error if the type is invalid. From e6bb5fb0f7044529f53a0a97f4a427b8bcee7a99 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Wed, 31 Jan 2024 15:58:30 +0100 Subject: [PATCH 12/13] Attempt to fix contrib testS --- connector/connectortest/connector.go | 1 + exporter/exportertest/nop_exporter.go | 1 + extension/extensiontest/nop_extension.go | 1 + processor/processortest/nop_processor.go | 1 + receiver/receivertest/nop_receiver.go | 1 + 5 files changed, 5 insertions(+) diff --git a/connector/connectortest/connector.go b/connector/connectortest/connector.go index 34570029483..d30fb65b6a5 100644 --- a/connector/connectortest/connector.go +++ b/connector/connectortest/connector.go @@ -18,6 +18,7 @@ var nopType = component.MustNewType("nop") // NewNopCreateSettings returns a new nop settings for Create* functions. func NewNopCreateSettings() connector.CreateSettings { return connector.CreateSettings{ + ID: component.NewID(nopType), TelemetrySettings: componenttest.NewNopTelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo(), } diff --git a/exporter/exportertest/nop_exporter.go b/exporter/exportertest/nop_exporter.go index dc3bb83ef07..e7e9f350331 100644 --- a/exporter/exportertest/nop_exporter.go +++ b/exporter/exportertest/nop_exporter.go @@ -17,6 +17,7 @@ var nopType = component.MustNewType("nop") // NewNopCreateSettings returns a new nop settings for Create*Exporter functions. func NewNopCreateSettings() exporter.CreateSettings { return exporter.CreateSettings{ + ID: component.NewID(nopType), TelemetrySettings: componenttest.NewNopTelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo(), } diff --git a/extension/extensiontest/nop_extension.go b/extension/extensiontest/nop_extension.go index 37a4ec91d27..fcb9ab001f7 100644 --- a/extension/extensiontest/nop_extension.go +++ b/extension/extensiontest/nop_extension.go @@ -16,6 +16,7 @@ var nopType = component.MustNewType("nop") // NewNopCreateSettings returns a new nop settings for extension.Factory Create* functions. func NewNopCreateSettings() extension.CreateSettings { return extension.CreateSettings{ + ID: component.NewID(nopType), TelemetrySettings: componenttest.NewNopTelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo(), } diff --git a/processor/processortest/nop_processor.go b/processor/processortest/nop_processor.go index 52d57c33373..dad0a9f0566 100644 --- a/processor/processortest/nop_processor.go +++ b/processor/processortest/nop_processor.go @@ -18,6 +18,7 @@ var nopType = component.MustNewType("nop") // NewNopCreateSettings returns a new nop settings for Create* functions. func NewNopCreateSettings() processor.CreateSettings { return processor.CreateSettings{ + ID: component.NewID(nopType), TelemetrySettings: componenttest.NewNopTelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo(), } diff --git a/receiver/receivertest/nop_receiver.go b/receiver/receivertest/nop_receiver.go index d1143b471e4..4c5565e6019 100644 --- a/receiver/receivertest/nop_receiver.go +++ b/receiver/receivertest/nop_receiver.go @@ -17,6 +17,7 @@ var componentType = component.MustNewType("nop") // NewNopCreateSettings returns a new nop settings for Create* functions. func NewNopCreateSettings() receiver.CreateSettings { return receiver.CreateSettings{ + ID: component.NewID(componentType), TelemetrySettings: componenttest.NewNopTelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo(), } From c58f72c26d260658d64d26380d575abc944870e1 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Fri, 2 Feb 2024 12:13:19 +0100 Subject: [PATCH 13/13] Move interface assertion to test file --- component/config.go | 2 -- component/config_test.go | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/component/config.go b/component/config.go index f20e9ad7388..f54b3a176c2 100644 --- a/component/config.go +++ b/component/config.go @@ -112,8 +112,6 @@ func callValidateIfPossible(v reflect.Value) error { // Type is the component type as it is used in the config. type Type string -var _ fmt.Stringer = (Type)("") - // String returns the string representation of the type. func (t Type) String() string { return string(t) diff --git a/component/config_test.go b/component/config_test.go index 4b1b89ff801..fcddc343d20 100644 --- a/component/config_test.go +++ b/component/config_test.go @@ -5,6 +5,7 @@ package component import ( "errors" + "fmt" "reflect" "testing" @@ -12,6 +13,8 @@ import ( "github.com/stretchr/testify/require" ) +var _ fmt.Stringer = (Type)("") + type configChildStruct struct { Child errConfig ChildPtr *errConfig