diff --git a/connector/servicegraphconnector/connector_test.go b/connector/servicegraphconnector/connector_test.go index 771304740620f..f395ac87062da 100644 --- a/connector/servicegraphconnector/connector_test.go +++ b/connector/servicegraphconnector/connector_test.go @@ -313,7 +313,7 @@ func TestStaleSeriesCleanup(t *testing.T) { mHost := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeMetrics: { - component.NewID("mock"): mockMetricsExporter, + component.MustNewID("mock"): mockMetricsExporter, }, }) @@ -365,7 +365,7 @@ func TestValidateOwnTelemetry(t *testing.T) { mHost := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeMetrics: { - component.NewID("mock"): mockMetricsExporter, + component.MustNewID("mock"): mockMetricsExporter, }, }) diff --git a/exporter/awss3exporter/config_test.go b/exporter/awss3exporter/config_test.go index 5f0c09356a496..97e0478783bde 100644 --- a/exporter/awss3exporter/config_test.go +++ b/exporter/awss3exporter/config_test.go @@ -26,7 +26,7 @@ func TestLoadConfig(t *testing.T) { require.NoError(t, err) require.NotNil(t, cfg) - e := cfg.Exporters[component.NewID("awss3")].(*Config) + e := cfg.Exporters[component.MustNewID("awss3")].(*Config) assert.Equal(t, e, &Config{ S3Uploader: S3UploaderConfig{ @@ -51,7 +51,7 @@ func TestConfig(t *testing.T) { require.NoError(t, err) require.NotNil(t, cfg) - e := cfg.Exporters[component.NewID("awss3")].(*Config) + e := cfg.Exporters[component.MustNewID("awss3")].(*Config) assert.Equal(t, e, &Config{ @@ -79,7 +79,7 @@ func TestConfigForS3CompatibleSystems(t *testing.T) { require.NoError(t, err) require.NotNil(t, cfg) - e := cfg.Exporters[component.NewID("awss3")].(*Config) + e := cfg.Exporters[component.MustNewID("awss3")].(*Config) assert.Equal(t, e, &Config{ @@ -167,7 +167,7 @@ func TestMarshallerName(t *testing.T) { require.NoError(t, err) require.NotNil(t, cfg) - e := cfg.Exporters[component.NewID("awss3")].(*Config) + e := cfg.Exporters[component.MustNewID("awss3")].(*Config) assert.Equal(t, e, &Config{ @@ -180,7 +180,7 @@ func TestMarshallerName(t *testing.T) { }, ) - e = cfg.Exporters[component.NewIDWithName("awss3", "proto")].(*Config) + e = cfg.Exporters[component.MustNewIDWithName("awss3", "proto")].(*Config) assert.Equal(t, e, &Config{ diff --git a/exporter/azuremonitorexporter/config_test.go b/exporter/azuremonitorexporter/config_test.go index 4eb5bc07022f7..ba1e41f7fefbe 100644 --- a/exporter/azuremonitorexporter/config_test.go +++ b/exporter/azuremonitorexporter/config_test.go @@ -23,7 +23,7 @@ func TestLoadConfig(t *testing.T) { cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) require.NoError(t, err) - disk := component.NewIDWithName("disk", "") + disk := component.MustNewIDWithName("disk", "") tests := []struct { id component.ID diff --git a/exporter/kineticaexporter/config_test.go b/exporter/kineticaexporter/config_test.go index 19e08f37d4943..8d5517b78e920 100644 --- a/exporter/kineticaexporter/config_test.go +++ b/exporter/kineticaexporter/config_test.go @@ -29,7 +29,7 @@ func TestLoadConfig(t *testing.T) { }{ { - id: component.NewIDWithName("kinetica", ""), + id: component.MustNewIDWithName("kinetica", ""), expected: defaultCfg, }, } diff --git a/exporter/loadbalancingexporter/loadbalancer_test.go b/exporter/loadbalancingexporter/loadbalancer_test.go index fbc884ff18636..5d8c74e0f14b9 100644 --- a/exporter/loadbalancingexporter/loadbalancer_test.go +++ b/exporter/loadbalancingexporter/loadbalancer_test.go @@ -243,7 +243,7 @@ func TestRemoveExtraExporters(t *testing.T) { func TestAddMissingExporters(t *testing.T) { // prepare cfg := simpleConfig() - exporterFactory := exporter.NewFactory("otlp", func() component.Config { + exporterFactory := exporter.NewFactory(component.MustNewType("otlp"), func() component.Config { return &otlpexporter.Config{} }, exporter.WithTraces(func( _ context.Context, @@ -277,7 +277,7 @@ func TestFailedToAddMissingExporters(t *testing.T) { // prepare cfg := simpleConfig() expectedErr := errors.New("some expected error") - exporterFactory := exporter.NewFactory("otlp", func() component.Config { + exporterFactory := exporter.NewFactory(component.MustNewType("otlp"), func() component.Config { return &otlpexporter.Config{} }, exporter.WithTraces(func( _ context.Context, diff --git a/exporter/opensearchexporter/config_test.go b/exporter/opensearchexporter/config_test.go index f974ad004f2f0..0cd9255ee508e 100644 --- a/exporter/opensearchexporter/config_test.go +++ b/exporter/opensearchexporter/config_test.go @@ -57,7 +57,7 @@ func TestLoadConfig(t *testing.T) { }, MaxIdleConns: &maxIdleConns, IdleConnTimeout: &idleConnTimeout, - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("sample_basic_auth")}, + Auth: &configauth.Authentication{AuthenticatorID: component.MustNewID("sample_basic_auth")}, }, BackOffConfig: configretry.BackOffConfig{ Enabled: true, diff --git a/exporter/otelarrowexporter/config_test.go b/exporter/otelarrowexporter/config_test.go index 9deac375628e0..9f4d83ea5ef73 100644 --- a/exporter/otelarrowexporter/config_test.go +++ b/exporter/otelarrowexporter/config_test.go @@ -79,7 +79,7 @@ func TestUnmarshalConfig(t *testing.T) { }, WriteBufferSize: 512 * 1024, BalancerName: "experimental", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("nop")}, + Auth: &configauth.Authentication{AuthenticatorID: component.MustNewID("nop")}, }, Arrow: ArrowSettings{ NumStreams: 2, diff --git a/extension/pprofextension/pprofextension_test.go b/extension/pprofextension/pprofextension_test.go index 513a1af738049..4a03e5a863dca 100644 --- a/extension/pprofextension/pprofextension_test.go +++ b/extension/pprofextension/pprofextension_test.go @@ -27,7 +27,7 @@ func TestPerformanceProfilerExtensionUsage(t *testing.T) { BlockProfileFraction: 3, MutexProfileFraction: 5, } - tt, err := componenttest.SetupTelemetry(component.NewID("TestPprofExtension")) + tt, err := componenttest.SetupTelemetry(component.MustNewID("TestPprofExtension")) require.NoError(t, err, "SetupTelemetry should succeed") pprofExt := newServer(config, tt.TelemetrySettings()) @@ -61,7 +61,7 @@ func TestPerformanceProfilerExtensionPortAlreadyInUse(t *testing.T) { Endpoint: endpoint, }, } - tt, err := componenttest.SetupTelemetry(component.NewID("TestPprofExtension")) + tt, err := componenttest.SetupTelemetry(component.MustNewID("TestPprofExtension")) require.NoError(t, err, "SetupTelemetry should succeed") pprofExt := newServer(config, tt.TelemetrySettings()) require.NotNil(t, pprofExt) @@ -76,7 +76,7 @@ func TestPerformanceProfilerMultipleStarts(t *testing.T) { }, } - tt, err := componenttest.SetupTelemetry(component.NewID("TestPprofExtension")) + tt, err := componenttest.SetupTelemetry(component.MustNewID("TestPprofExtension")) require.NoError(t, err, "SetupTelemetry should succeed") pprofExt := newServer(config, tt.TelemetrySettings()) require.NotNil(t, pprofExt) @@ -95,7 +95,7 @@ func TestPerformanceProfilerMultipleShutdowns(t *testing.T) { }, } - tt, err := componenttest.SetupTelemetry(component.NewID("TestPprofExtension")) + tt, err := componenttest.SetupTelemetry(component.MustNewID("TestPprofExtension")) require.NoError(t, err, "SetupTelemetry should succeed") pprofExt := newServer(config, tt.TelemetrySettings()) require.NotNil(t, pprofExt) @@ -111,7 +111,7 @@ func TestPerformanceProfilerShutdownWithoutStart(t *testing.T) { Endpoint: testutil.GetAvailableLocalAddress(t), }, } - tt, err := componenttest.SetupTelemetry(component.NewID("TestPprofExtension")) + tt, err := componenttest.SetupTelemetry(component.MustNewID("TestPprofExtension")) require.NoError(t, err, "SetupTelemetry should succeed") pprofExt := newServer(config, tt.TelemetrySettings()) require.NotNil(t, pprofExt) @@ -133,7 +133,7 @@ func TestPerformanceProfilerLifecycleWithFile(t *testing.T) { }, SaveToFile: tmpFile.Name(), } - tt, err := componenttest.SetupTelemetry(component.NewID("TestPprofExtension")) + tt, err := componenttest.SetupTelemetry(component.MustNewID("TestPprofExtension")) require.NoError(t, err, "SetupTelemetry should succeed") pprofExt := newServer(config, tt.TelemetrySettings()) require.NotNil(t, pprofExt) diff --git a/extension/storage/dbstorage/extension_test.go b/extension/storage/dbstorage/extension_test.go index 7d588f122add9..e97b52c410682 100644 --- a/extension/storage/dbstorage/extension_test.go +++ b/extension/storage/dbstorage/extension_test.go @@ -113,5 +113,5 @@ func newTestExtension(t *testing.T) storage.Extension { } func newTestEntity(name string) component.ID { - return component.NewIDWithName("nop", name) + return component.MustNewIDWithName("nop", name) } diff --git a/extension/storage/filestorage/extension_test.go b/extension/storage/filestorage/extension_test.go index 0062f6a7eef47..d808647b12934 100644 --- a/extension/storage/filestorage/extension_test.go +++ b/extension/storage/filestorage/extension_test.go @@ -292,7 +292,7 @@ func newTestExtension(t *testing.T) storage.Extension { } func newTestEntity(name string) component.ID { - return component.NewIDWithName("nop", name) + return component.MustNewIDWithName("nop", name) } func TestCompaction(t *testing.T) { diff --git a/extension/storage/storagetest/extension_test.go b/extension/storage/storagetest/extension_test.go index c2c445f21ef6a..43a519f79f6a1 100644 --- a/extension/storage/storagetest/extension_test.go +++ b/extension/storage/storagetest/extension_test.go @@ -36,7 +36,7 @@ func runExtensionLifecycle(t *testing.T, ext *TestStorage, expectPersistence boo ctx := context.Background() require.NoError(t, ext.Start(ctx, componenttest.NewNopHost())) - clientOne, err := ext.GetClient(ctx, component.KindProcessor, component.NewID("foo"), "client_one") + clientOne, err := ext.GetClient(ctx, component.KindProcessor, component.MustNewID("foo"), "client_one") require.NoError(t, err) creatorID, err := CreatorID(ctx, clientOne) @@ -65,7 +65,7 @@ func runExtensionLifecycle(t *testing.T, ext *TestStorage, expectPersistence boo require.NoError(t, clientOne.Close(ctx)) // Create new client to test persistence - clientTwo, err := ext.GetClient(ctx, component.KindProcessor, component.NewID("foo"), "client_one") + clientTwo, err := ext.GetClient(ctx, component.KindProcessor, component.MustNewID("foo"), "client_one") require.NoError(t, err) creatorID, err = CreatorID(ctx, clientTwo) diff --git a/internal/aws/xray/telemetry/registry_test.go b/internal/aws/xray/telemetry/registry_test.go index 84f0dc7db304d..0b297f5bec7ce 100644 --- a/internal/aws/xray/telemetry/registry_test.go +++ b/internal/aws/xray/telemetry/registry_test.go @@ -12,9 +12,9 @@ import ( func TestRegistry(t *testing.T) { r := NewRegistry() - newID := component.NewID("new") - contribID := component.NewID("contrib") - notCreatedID := component.NewID("not-created") + newID := component.MustNewID("new") + contribID := component.MustNewID("contrib") + notCreatedID := component.MustNewID("not_created") original := r.Register( newID, Config{ diff --git a/internal/aws/xray/telemetry/telemetrytest/nop_registry_test.go b/internal/aws/xray/telemetry/telemetrytest/nop_registry_test.go index 58db96b1af3ee..440d4b5967782 100644 --- a/internal/aws/xray/telemetry/telemetrytest/nop_registry_test.go +++ b/internal/aws/xray/telemetry/telemetrytest/nop_registry_test.go @@ -16,9 +16,9 @@ func TestNopRegistry(t *testing.T) { assert.Same(t, nopRegistryInstance, NewNopRegistry()) r := NewNopRegistry() assert.NotPanics(t, func() { - recorder := r.Register(component.NewID("a"), telemetry.Config{}, nil) - assert.Same(t, recorder, r.Load(component.NewID("b"))) - r.LoadOrStore(component.NewID("c"), recorder) - r.LoadOrNop(component.NewID("d")) + recorder := r.Register(component.MustNewID("a"), telemetry.Config{}, nil) + assert.Same(t, recorder, r.Load(component.MustNewID("b"))) + r.LoadOrStore(component.MustNewID("c"), recorder) + r.LoadOrNop(component.MustNewID("d")) }) } diff --git a/internal/sharedcomponent/sharedcomponent_test.go b/internal/sharedcomponent/sharedcomponent_test.go index 9673eb20217bb..cc3c6a6eda36d 100644 --- a/internal/sharedcomponent/sharedcomponent_test.go +++ b/internal/sharedcomponent/sharedcomponent_test.go @@ -13,7 +13,7 @@ import ( "go.opentelemetry.io/collector/component/componenttest" ) -var id = component.NewID("test") +var id = component.MustNewID("test") func TestNewSharedComponents(t *testing.T) { comps := NewSharedComponents() diff --git a/pkg/stanza/adapter/integration_test.go b/pkg/stanza/adapter/integration_test.go index f4a1836e6b381..984ffba0636ad 100644 --- a/pkg/stanza/adapter/integration_test.go +++ b/pkg/stanza/adapter/integration_test.go @@ -36,7 +36,7 @@ func createNoopReceiver(nextConsumer consumer.Logs) (*receiver, error) { return nil, err } - receiverID := component.NewID("test") + receiverID := component.MustNewID("test") obsrecv, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{ ReceiverID: receiverID, ReceiverCreateSettings: receivertest.NewNopCreateSettings(), @@ -46,7 +46,7 @@ func createNoopReceiver(nextConsumer consumer.Logs) (*receiver, error) { } return &receiver{ - id: component.NewID("testReceiver"), + id: component.MustNewID("testReceiver"), pipe: pipe, emitter: emitter, consumer: nextConsumer, diff --git a/pkg/stanza/adapter/receiver_test.go b/pkg/stanza/adapter/receiver_test.go index c137a9244d5b5..5dce972694bff 100644 --- a/pkg/stanza/adapter/receiver_test.go +++ b/pkg/stanza/adapter/receiver_test.go @@ -151,7 +151,7 @@ func BenchmarkReadLine(b *testing.B) { storageClient := storagetest.NewInMemoryClient( component.KindReceiver, - component.NewID("foolog"), + component.MustNewID("foolog"), "test", ) @@ -216,7 +216,7 @@ func BenchmarkParseAndMap(b *testing.B) { storageClient := storagetest.NewInMemoryClient( component.KindReceiver, - component.NewID("foolog"), + component.MustNewID("foolog"), "test", ) diff --git a/pkg/stanza/adapter/storage_test.go b/pkg/stanza/adapter/storage_test.go index 419f06986faf9..4a3d2faf1267e 100644 --- a/pkg/stanza/adapter/storage_test.go +++ b/pkg/stanza/adapter/storage_test.go @@ -85,7 +85,7 @@ func TestFindCorrectStorageExtension(t *testing.T) { } func TestFailOnMissingStorageExtension(t *testing.T) { - id := component.NewIDWithName("test", "missing") + id := component.MustNewIDWithName("test", "missing") r := createReceiver(t, id) err := r.Start(context.Background(), storagetest.NewStorageHost()) require.Error(t, err) diff --git a/processor/filterprocessor/config_test.go b/processor/filterprocessor/config_test.go index 667672c7c0798..9ebf9ee47cba0 100644 --- a/processor/filterprocessor/config_test.go +++ b/processor/filterprocessor/config_test.go @@ -40,7 +40,7 @@ func TestLoadingConfigStrict(t *testing.T) { expected *Config }{ { - id: component.NewIDWithName("filter", "empty"), + id: component.MustNewIDWithName("filter", "empty"), expected: &Config{ ErrorMode: ottl.PropagateError, Metrics: MetricFilters{ @@ -50,7 +50,7 @@ func TestLoadingConfigStrict(t *testing.T) { }, }, }, { - id: component.NewIDWithName("filter", "include"), + id: component.MustNewIDWithName("filter", "include"), expected: &Config{ ErrorMode: ottl.PropagateError, Metrics: MetricFilters{ @@ -58,7 +58,7 @@ func TestLoadingConfigStrict(t *testing.T) { }, }, }, { - id: component.NewIDWithName("filter", "exclude"), + id: component.MustNewIDWithName("filter", "exclude"), expected: &Config{ ErrorMode: ottl.PropagateError, Metrics: MetricFilters{ @@ -66,7 +66,7 @@ func TestLoadingConfigStrict(t *testing.T) { }, }, }, { - id: component.NewIDWithName("filter", "includeexclude"), + id: component.MustNewIDWithName("filter", "includeexclude"), expected: &Config{ ErrorMode: ottl.PropagateError, Metrics: MetricFilters{ @@ -126,7 +126,7 @@ func TestLoadingConfigStrictLogs(t *testing.T) { expected *Config }{ { - id: component.NewIDWithName("filter", "empty"), + id: component.MustNewIDWithName("filter", "empty"), expected: &Config{ ErrorMode: ottl.PropagateError, Logs: LogFilters{ @@ -136,7 +136,7 @@ func TestLoadingConfigStrictLogs(t *testing.T) { }, }, }, { - id: component.NewIDWithName("filter", "include"), + id: component.MustNewIDWithName("filter", "include"), expected: &Config{ ErrorMode: ottl.PropagateError, Logs: LogFilters{ @@ -144,7 +144,7 @@ func TestLoadingConfigStrictLogs(t *testing.T) { }, }, }, { - id: component.NewIDWithName("filter", "exclude"), + id: component.MustNewIDWithName("filter", "exclude"), expected: &Config{ ErrorMode: ottl.PropagateError, Logs: LogFilters{ @@ -152,7 +152,7 @@ func TestLoadingConfigStrictLogs(t *testing.T) { }, }, }, { - id: component.NewIDWithName("filter", "includeexclude"), + id: component.MustNewIDWithName("filter", "includeexclude"), expected: &Config{ ErrorMode: ottl.PropagateError, Logs: LogFilters{ @@ -199,7 +199,7 @@ func TestLoadingConfigSeverityLogsStrict(t *testing.T) { expected *Config }{ { - id: component.NewIDWithName("filter", "include"), + id: component.MustNewIDWithName("filter", "include"), expected: &Config{ ErrorMode: ottl.PropagateError, Logs: LogFilters{ @@ -207,7 +207,7 @@ func TestLoadingConfigSeverityLogsStrict(t *testing.T) { }, }, }, { - id: component.NewIDWithName("filter", "exclude"), + id: component.MustNewIDWithName("filter", "exclude"), expected: &Config{ ErrorMode: ottl.PropagateError, Logs: LogFilters{ @@ -215,7 +215,7 @@ func TestLoadingConfigSeverityLogsStrict(t *testing.T) { }, }, }, { - id: component.NewIDWithName("filter", "includeexclude"), + id: component.MustNewIDWithName("filter", "includeexclude"), expected: &Config{ ErrorMode: ottl.PropagateError, Logs: LogFilters{ @@ -261,7 +261,7 @@ func TestLoadingConfigSeverityLogsRegexp(t *testing.T) { expected *Config }{ { - id: component.NewIDWithName("filter", "include"), + id: component.MustNewIDWithName("filter", "include"), expected: &Config{ ErrorMode: ottl.PropagateError, Logs: LogFilters{ @@ -269,7 +269,7 @@ func TestLoadingConfigSeverityLogsRegexp(t *testing.T) { }, }, }, { - id: component.NewIDWithName("filter", "exclude"), + id: component.MustNewIDWithName("filter", "exclude"), expected: &Config{ ErrorMode: ottl.PropagateError, Logs: LogFilters{ @@ -277,7 +277,7 @@ func TestLoadingConfigSeverityLogsRegexp(t *testing.T) { }, }, }, { - id: component.NewIDWithName("filter", "includeexclude"), + id: component.MustNewIDWithName("filter", "includeexclude"), expected: &Config{ ErrorMode: ottl.PropagateError, Logs: LogFilters{ @@ -324,7 +324,7 @@ func TestLoadingConfigBodyLogsStrict(t *testing.T) { expected *Config }{ { - id: component.NewIDWithName("filter", "include"), + id: component.MustNewIDWithName("filter", "include"), expected: &Config{ ErrorMode: ottl.PropagateError, Logs: LogFilters{ @@ -332,7 +332,7 @@ func TestLoadingConfigBodyLogsStrict(t *testing.T) { }, }, }, { - id: component.NewIDWithName("filter", "exclude"), + id: component.MustNewIDWithName("filter", "exclude"), expected: &Config{ ErrorMode: ottl.PropagateError, Logs: LogFilters{ @@ -340,7 +340,7 @@ func TestLoadingConfigBodyLogsStrict(t *testing.T) { }, }, }, { - id: component.NewIDWithName("filter", "includeexclude"), + id: component.MustNewIDWithName("filter", "includeexclude"), expected: &Config{ ErrorMode: ottl.PropagateError, Logs: LogFilters{ @@ -387,7 +387,7 @@ func TestLoadingConfigBodyLogsRegexp(t *testing.T) { expected *Config }{ { - id: component.NewIDWithName("filter", "include"), + id: component.MustNewIDWithName("filter", "include"), expected: &Config{ ErrorMode: ottl.PropagateError, Logs: LogFilters{ @@ -395,7 +395,7 @@ func TestLoadingConfigBodyLogsRegexp(t *testing.T) { }, }, }, { - id: component.NewIDWithName("filter", "exclude"), + id: component.MustNewIDWithName("filter", "exclude"), expected: &Config{ ErrorMode: ottl.PropagateError, Logs: LogFilters{ @@ -403,7 +403,7 @@ func TestLoadingConfigBodyLogsRegexp(t *testing.T) { }, }, }, { - id: component.NewIDWithName("filter", "includeexclude"), + id: component.MustNewIDWithName("filter", "includeexclude"), expected: &Config{ ErrorMode: ottl.PropagateError, Logs: LogFilters{ @@ -452,7 +452,7 @@ func TestLoadingConfigMinSeverityNumberLogs(t *testing.T) { expected *Config }{ { - id: component.NewIDWithName("filter", "include"), + id: component.MustNewIDWithName("filter", "include"), expected: &Config{ ErrorMode: ottl.PropagateError, Logs: LogFilters{ @@ -460,7 +460,7 @@ func TestLoadingConfigMinSeverityNumberLogs(t *testing.T) { }, }, }, { - id: component.NewIDWithName("filter", "exclude"), + id: component.MustNewIDWithName("filter", "exclude"), expected: &Config{ ErrorMode: ottl.PropagateError, Logs: LogFilters{ @@ -468,7 +468,7 @@ func TestLoadingConfigMinSeverityNumberLogs(t *testing.T) { }, }, }, { - id: component.NewIDWithName("filter", "includeexclude"), + id: component.MustNewIDWithName("filter", "includeexclude"), expected: &Config{ ErrorMode: ottl.PropagateError, Logs: LogFilters{ @@ -521,7 +521,7 @@ func TestLoadingConfigRegexp(t *testing.T) { expected component.Config }{ { - id: component.NewIDWithName("filter", "include"), + id: component.MustNewIDWithName("filter", "include"), expected: &Config{ ErrorMode: ottl.PropagateError, Metrics: MetricFilters{ @@ -529,7 +529,7 @@ func TestLoadingConfigRegexp(t *testing.T) { }, }, }, { - id: component.NewIDWithName("filter", "exclude"), + id: component.MustNewIDWithName("filter", "exclude"), expected: &Config{ ErrorMode: ottl.PropagateError, Metrics: MetricFilters{ @@ -537,7 +537,7 @@ func TestLoadingConfigRegexp(t *testing.T) { }, }, }, { - id: component.NewIDWithName("filter", "unlimitedcache"), + id: component.MustNewIDWithName("filter", "unlimitedcache"), expected: &Config{ ErrorMode: ottl.PropagateError, Metrics: MetricFilters{ @@ -551,7 +551,7 @@ func TestLoadingConfigRegexp(t *testing.T) { }, }, }, { - id: component.NewIDWithName("filter", "limitedcache"), + id: component.MustNewIDWithName("filter", "limitedcache"), expected: &Config{ ErrorMode: ottl.PropagateError, Metrics: MetricFilters{ @@ -592,7 +592,7 @@ func TestLoadingSpans(t *testing.T) { expected component.Config }{ { - id: component.NewIDWithName("filter", "spans"), + id: component.MustNewIDWithName("filter", "spans"), expected: &Config{ ErrorMode: ottl.PropagateError, Spans: filterconfig.MatchConfig{ @@ -642,7 +642,7 @@ func TestLoadingConfigExpr(t *testing.T) { expected component.Config }{ { - id: component.NewIDWithName("filter", "empty"), + id: component.MustNewIDWithName("filter", "empty"), expected: &Config{ ErrorMode: ottl.PropagateError, Metrics: MetricFilters{ @@ -653,7 +653,7 @@ func TestLoadingConfigExpr(t *testing.T) { }, }, { - id: component.NewIDWithName("filter", "include"), + id: component.MustNewIDWithName("filter", "include"), expected: &Config{ ErrorMode: ottl.PropagateError, Metrics: MetricFilters{ @@ -668,7 +668,7 @@ func TestLoadingConfigExpr(t *testing.T) { }, }, { - id: component.NewIDWithName("filter", "exclude"), + id: component.MustNewIDWithName("filter", "exclude"), expected: &Config{ ErrorMode: ottl.PropagateError, Metrics: MetricFilters{ @@ -683,7 +683,7 @@ func TestLoadingConfigExpr(t *testing.T) { }, }, { - id: component.NewIDWithName("filter", "includeexclude"), + id: component.MustNewIDWithName("filter", "includeexclude"), expected: &Config{ ErrorMode: ottl.PropagateError, Metrics: MetricFilters{ @@ -842,7 +842,7 @@ func TestLoadingConfigOTTL(t *testing.T) { errorMessage string }{ { - id: component.NewIDWithName("filter", "ottl"), + id: component.MustNewIDWithName("filter", "ottl"), expected: &Config{ ErrorMode: ottl.IgnoreError, Traces: TraceFilters{ @@ -869,7 +869,7 @@ func TestLoadingConfigOTTL(t *testing.T) { }, }, { - id: component.NewIDWithName("filter", "multiline"), + id: component.MustNewIDWithName("filter", "multiline"), expected: &Config{ ErrorMode: ottl.PropagateError, Traces: TraceFilters{ diff --git a/processor/routingprocessor/factory_test.go b/processor/routingprocessor/factory_test.go index f78e98f30bceb..1a8f2abe5a463 100644 --- a/processor/routingprocessor/factory_test.go +++ b/processor/routingprocessor/factory_test.go @@ -152,10 +152,10 @@ func TestProcessorDoesNotFailToBuildExportersWithMultiplePipelines(t *testing.T) host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeTraces: { - component.NewID("otlp/traces"): otlpTracesExporter, + component.MustNewIDWithName("otlp", "traces"): otlpTracesExporter, }, component.DataTypeMetrics: { - component.NewID("otlp/metrics"): otlpMetricsExporter, + component.MustNewIDWithName("otlp", "metrics"): otlpMetricsExporter, }, }) diff --git a/processor/routingprocessor/logs_test.go b/processor/routingprocessor/logs_test.go index 5d10640feb08a..e0f94ef90ef74 100644 --- a/processor/routingprocessor/logs_test.go +++ b/processor/routingprocessor/logs_test.go @@ -41,8 +41,8 @@ func TestLogs_RoutingWorks_Context(t *testing.T) { host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeLogs: { - component.NewID("otlp"): defaultExp, - component.NewIDWithName("otlp", "2"): lExp, + component.MustNewID("otlp"): defaultExp, + component.MustNewIDWithName("otlp", "2"): lExp, }, }) @@ -133,8 +133,8 @@ func TestLogs_RoutingWorks_ResourceAttribute(t *testing.T) { host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeLogs: { - component.NewID("otlp"): defaultExp, - component.NewIDWithName("otlp", "2"): lExp, + component.MustNewID("otlp"): defaultExp, + component.MustNewIDWithName("otlp", "2"): lExp, }, }) @@ -188,8 +188,8 @@ func TestLogs_RoutingWorks_ResourceAttribute_DropsRoutingAttribute(t *testing.T) host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeLogs: { - component.NewID("otlp"): defaultExp, - component.NewIDWithName("otlp", "2"): lExp, + component.MustNewID("otlp"): defaultExp, + component.MustNewIDWithName("otlp", "2"): lExp, }, }) @@ -232,8 +232,8 @@ func TestLogs_AreCorrectlySplitPerResourceAttributeRouting(t *testing.T) { host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeLogs: { - component.NewID("otlp"): defaultExp, - component.NewIDWithName("otlp", "2"): lExp, + component.MustNewID("otlp"): defaultExp, + component.MustNewIDWithName("otlp", "2"): lExp, }, }) @@ -286,9 +286,9 @@ func TestLogsAreCorrectlySplitPerResourceAttributeWithOTTL(t *testing.T) { host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeLogs: { - component.NewID("otlp"): defaultExp, - component.NewIDWithName("otlp", "1"): firstExp, - component.NewIDWithName("otlp", "2"): secondExp, + component.MustNewID("otlp"): defaultExp, + component.MustNewIDWithName("otlp", "1"): firstExp, + component.MustNewIDWithName("otlp", "2"): secondExp, }, }) @@ -408,8 +408,8 @@ func TestLogsAttributeWithOTTLDoesNotCauseCrash(t *testing.T) { host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeLogs: { - component.NewID("otlp"): defaultExp, - component.NewIDWithName("otlp", "1"): firstExp, + component.MustNewID("otlp"): defaultExp, + component.MustNewIDWithName("otlp", "1"): firstExp, }, }) diff --git a/processor/routingprocessor/metrics_test.go b/processor/routingprocessor/metrics_test.go index 3cd40ecd739e4..d5404eaa0aaf3 100644 --- a/processor/routingprocessor/metrics_test.go +++ b/processor/routingprocessor/metrics_test.go @@ -42,8 +42,8 @@ func TestMetrics_AreCorrectlySplitPerResourceAttributeRouting(t *testing.T) { host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeMetrics: { - component.NewID("otlp"): defaultExp, - component.NewIDWithName("otlp", "2"): mExp, + component.MustNewID("otlp"): defaultExp, + component.MustNewIDWithName("otlp", "2"): mExp, }, }) @@ -101,8 +101,8 @@ func TestMetrics_RoutingWorks_Context(t *testing.T) { host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeMetrics: { - component.NewID("otlp"): defaultExp, - component.NewIDWithName("otlp", "2"): mExp, + component.MustNewID("otlp"): defaultExp, + component.MustNewIDWithName("otlp", "2"): mExp, }, }) @@ -195,8 +195,8 @@ func TestMetrics_RoutingWorks_ResourceAttribute(t *testing.T) { host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeMetrics: { - component.NewID("otlp"): defaultExp, - component.NewIDWithName("otlp", "2"): mExp, + component.MustNewID("otlp"): defaultExp, + component.MustNewIDWithName("otlp", "2"): mExp, }, }) @@ -250,8 +250,8 @@ func TestMetrics_RoutingWorks_ResourceAttribute_DropsRoutingAttribute(t *testing host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeMetrics: { - component.NewID("otlp"): defaultExp, - component.NewIDWithName("otlp", "2"): mExp, + component.MustNewID("otlp"): defaultExp, + component.MustNewIDWithName("otlp", "2"): mExp, }, }) @@ -312,8 +312,8 @@ func Benchmark_MetricsRouting_ResourceAttribute(b *testing.B) { host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeMetrics: { - component.NewID("otlp"): defaultExp, - component.NewIDWithName("otlp", "2"): mExp, + component.MustNewID("otlp"): defaultExp, + component.MustNewIDWithName("otlp", "2"): mExp, }, }) @@ -345,9 +345,9 @@ func TestMetricsAreCorrectlySplitPerResourceAttributeRoutingWithOTTL(t *testing. host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeMetrics: { - component.NewID("otlp"): defaultExp, - component.NewIDWithName("otlp", "1"): firstExp, - component.NewIDWithName("otlp", "2"): secondExp, + component.MustNewID("otlp"): defaultExp, + component.MustNewIDWithName("otlp", "1"): firstExp, + component.MustNewIDWithName("otlp", "2"): secondExp, }, }) @@ -480,8 +480,8 @@ func TestMetricsAttributeWithOTTLDoesNotCauseCrash(t *testing.T) { host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeMetrics: { - component.NewID("otlp"): defaultExp, - component.NewIDWithName("otlp", "1"): firstExp, + component.MustNewID("otlp"): defaultExp, + component.MustNewIDWithName("otlp", "1"): firstExp, }, }) diff --git a/processor/routingprocessor/traces_test.go b/processor/routingprocessor/traces_test.go index e6a235e9458b2..549354e74cd58 100644 --- a/processor/routingprocessor/traces_test.go +++ b/processor/routingprocessor/traces_test.go @@ -34,7 +34,7 @@ func TestTraces_RegisterExportersForValidRoute(t *testing.T) { require.NoError(t, err) otlpExpFactory := otlpexporter.NewFactory() - otlpID := component.NewID("otlp") + otlpID := component.MustNewID("otlp") otlpConfig := &otlpexporter.Config{ ClientConfig: configgrpc.ClientConfig{ Endpoint: "example.com:1234", @@ -72,7 +72,7 @@ func TestTraces_InvalidExporter(t *testing.T) { host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeTraces: { - component.NewID("otlp"): &mockComponent{}, + component.MustNewID("otlp"): &mockComponent{}, }, }) @@ -89,8 +89,8 @@ func TestTraces_AreCorrectlySplitPerResourceAttributeRouting(t *testing.T) { host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeTraces: { - component.NewID("otlp"): defaultExp, - component.NewIDWithName("otlp", "2"): tExp, + component.MustNewID("otlp"): defaultExp, + component.MustNewIDWithName("otlp", "2"): tExp, }, }) @@ -145,8 +145,8 @@ func TestTraces_RoutingWorks_Context(t *testing.T) { host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeTraces: { - component.NewID("otlp"): defaultExp, - component.NewIDWithName("otlp", "2"): tExp, + component.MustNewID("otlp"): defaultExp, + component.MustNewIDWithName("otlp", "2"): tExp, }, }) @@ -238,8 +238,8 @@ func TestTraces_RoutingWorks_ResourceAttribute(t *testing.T) { host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeTraces: { - component.NewID("otlp"): defaultExp, - component.NewIDWithName("otlp", "2"): tExp, + component.MustNewID("otlp"): defaultExp, + component.MustNewIDWithName("otlp", "2"): tExp, }, }) @@ -293,8 +293,8 @@ func TestTraces_RoutingWorks_ResourceAttribute_DropsRoutingAttribute(t *testing. host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeTraces: { - component.NewID("otlp"): defaultExp, - component.NewIDWithName("otlp", "2"): tExp, + component.MustNewID("otlp"): defaultExp, + component.MustNewIDWithName("otlp", "2"): tExp, }, }) @@ -340,9 +340,9 @@ func TestTracesAreCorrectlySplitPerResourceAttributeWithOTTL(t *testing.T) { host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeTraces: { - component.NewID("otlp"): defaultExp, - component.NewIDWithName("otlp", "1"): firstExp, - component.NewIDWithName("otlp", "2"): secondExp, + component.MustNewID("otlp"): defaultExp, + component.MustNewIDWithName("otlp", "1"): firstExp, + component.MustNewIDWithName("otlp", "2"): secondExp, }, }) @@ -465,8 +465,8 @@ func TestTracesAttributeWithOTTLDoesNotCauseCrash(t *testing.T) { host := newMockHost(map[component.DataType]map[component.ID]component.Component{ component.DataTypeTraces: { - component.NewID("otlp"): defaultExp, - component.NewIDWithName("otlp", "1"): firstExp, + component.MustNewID("otlp"): defaultExp, + component.MustNewIDWithName("otlp", "1"): firstExp, }, }) diff --git a/processor/spanmetricsprocessor/processor_test.go b/processor/spanmetricsprocessor/processor_test.go index ced0fae28edab..72c7e86b2f967 100644 --- a/processor/spanmetricsprocessor/processor_test.go +++ b/processor/spanmetricsprocessor/processor_test.go @@ -721,7 +721,7 @@ func initSpan(span span, s ptrace.Span) { func newOTLPExporters(t *testing.T) (component.ID, exporter.Metrics, exporter.Traces) { otlpExpFactory := otlpexporter.NewFactory() - otlpID := component.NewID("otlp") + otlpID := component.MustNewID("otlp") otlpConfig := &otlpexporter.Config{ ClientConfig: configgrpc.ClientConfig{ Endpoint: "example.com:1234", diff --git a/processor/spanprocessor/config_test.go b/processor/spanprocessor/config_test.go index 73d891fa12008..49490eb221ecb 100644 --- a/processor/spanprocessor/config_test.go +++ b/processor/spanprocessor/config_test.go @@ -24,7 +24,7 @@ func TestLoadingConfig(t *testing.T) { expected component.Config }{ { - id: component.NewIDWithName("span", "custom"), + id: component.MustNewIDWithName("span", "custom"), expected: &Config{ Rename: Name{ FromAttributes: []string{"db.svc", "operation", "id"}, @@ -33,7 +33,7 @@ func TestLoadingConfig(t *testing.T) { }, }, { - id: component.NewIDWithName("span", "no-separator"), + id: component.MustNewIDWithName("span", "no-separator"), expected: &Config{ Rename: Name{ FromAttributes: []string{"db.svc", "operation", "id"}, @@ -42,7 +42,7 @@ func TestLoadingConfig(t *testing.T) { }, }, { - id: component.NewIDWithName("span", "to_attributes"), + id: component.MustNewIDWithName("span", "to_attributes"), expected: &Config{ Rename: Name{ ToAttributes: &ToAttributes{ @@ -52,7 +52,7 @@ func TestLoadingConfig(t *testing.T) { }, }, { - id: component.NewIDWithName("span", "includeexclude"), + id: component.MustNewIDWithName("span", "includeexclude"), expected: &Config{ MatchConfig: filterconfig.MatchConfig{ Include: &filterconfig.MatchProperties{ @@ -74,7 +74,7 @@ func TestLoadingConfig(t *testing.T) { }, { // Set name - id: component.NewIDWithName("span", "set_status_err"), + id: component.MustNewIDWithName("span", "set_status_err"), expected: &Config{ SetStatus: &Status{ Code: "Error", @@ -83,7 +83,7 @@ func TestLoadingConfig(t *testing.T) { }, }, { - id: component.NewIDWithName("span", "set_status_ok"), + id: component.MustNewIDWithName("span", "set_status_ok"), expected: &Config{ MatchConfig: filterconfig.MatchConfig{ Include: &filterconfig.MatchProperties{ diff --git a/receiver/awsxrayreceiver/internal/udppoller/poller_test.go b/receiver/awsxrayreceiver/internal/udppoller/poller_test.go index 04e9911bc7f0d..878939b28a154 100644 --- a/receiver/awsxrayreceiver/internal/udppoller/poller_test.go +++ b/receiver/awsxrayreceiver/internal/udppoller/poller_test.go @@ -113,7 +113,7 @@ func TestCloseStopsPoller(t *testing.T) { } func TestSuccessfullyPollPacket(t *testing.T) { - receiverID := component.NewID("TestSuccessfullyPollPacket") + receiverID := component.MustNewID("TestSuccessfullyPollPacket") tt, err := componenttest.SetupTelemetry(receiverID) assert.NoError(t, err, "SetupTelemetry should succeed") defer func() { @@ -149,7 +149,7 @@ func TestSuccessfullyPollPacket(t *testing.T) { } func TestIncompletePacketNoSeparator(t *testing.T) { - receiverID := component.NewID("TestIncompletePacketNoSeparator") + receiverID := component.MustNewID("TestIncompletePacketNoSeparator") tt, err := componenttest.SetupTelemetry(receiverID) assert.NoError(t, err, "SetupTelemetry should succeed") defer func() { @@ -179,7 +179,7 @@ func TestIncompletePacketNoSeparator(t *testing.T) { } func TestIncompletePacketNoBody(t *testing.T) { - receiverID := component.NewID("TestIncompletePacketNoBody") + receiverID := component.MustNewID("TestIncompletePacketNoBody") tt, err := componenttest.SetupTelemetry(receiverID) assert.NoError(t, err, "SetupTelemetry should succeed") defer func() { @@ -204,7 +204,7 @@ func TestIncompletePacketNoBody(t *testing.T) { } func TestNonJsonHeader(t *testing.T) { - receiverID := component.NewID("TestNonJsonHeader") + receiverID := component.MustNewID("TestNonJsonHeader") tt, err := componenttest.SetupTelemetry(receiverID) assert.NoError(t, err, "SetupTelemetry should succeed") defer func() { @@ -234,7 +234,7 @@ func TestNonJsonHeader(t *testing.T) { } func TestJsonInvalidHeader(t *testing.T) { - receiverID := component.NewID("TestJsonInvalidHeader") + receiverID := component.MustNewID("TestJsonInvalidHeader") tt, err := componenttest.SetupTelemetry(receiverID) assert.NoError(t, err, "SetupTelemetry should succeed") defer func() { @@ -270,7 +270,7 @@ func TestJsonInvalidHeader(t *testing.T) { } func TestSocketReadIrrecoverableNetError(t *testing.T) { - receiverID := component.NewID("TestSocketReadIrrecoverableNetError") + receiverID := component.MustNewID("TestSocketReadIrrecoverableNetError") tt, err := componenttest.SetupTelemetry(receiverID) assert.NoError(t, err, "SetupTelemetry should succeed") defer func() { @@ -306,7 +306,7 @@ func TestSocketReadIrrecoverableNetError(t *testing.T) { } func TestSocketReadTimeOutNetError(t *testing.T) { - receiverID := component.NewID("TestSocketReadTimeOutNetError") + receiverID := component.MustNewID("TestSocketReadTimeOutNetError") tt, err := componenttest.SetupTelemetry(receiverID) assert.NoError(t, err, "SetupTelemetry should succeed") defer func() { @@ -343,7 +343,7 @@ func TestSocketReadTimeOutNetError(t *testing.T) { } func TestSocketGenericReadError(t *testing.T) { - receiverID := component.NewID("TestSocketGenericReadError") + receiverID := component.MustNewID("TestSocketGenericReadError") tt, err := componenttest.SetupTelemetry(receiverID) assert.NoError(t, err, "SetupTelemetry should succeed") defer func() { diff --git a/receiver/awsxrayreceiver/receiver_test.go b/receiver/awsxrayreceiver/receiver_test.go index 5715fb3a9b25d..7fc10df57ee2e 100644 --- a/receiver/awsxrayreceiver/receiver_test.go +++ b/receiver/awsxrayreceiver/receiver_test.go @@ -106,7 +106,7 @@ func TestSegmentsPassedToConsumer(t *testing.T) { } t.Skip("Flaky Test - See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/10596") - receiverID := component.NewID("TestSegmentsPassedToConsumer") + receiverID := component.MustNewID("TestSegmentsPassedToConsumer") tt, err := componenttest.SetupTelemetry(receiverID) assert.NoError(t, err, "SetupTelemetry should succeed") defer func() { @@ -137,7 +137,7 @@ func TestSegmentsPassedToConsumer(t *testing.T) { } func TestTranslatorErrorsOut(t *testing.T) { - receiverID := component.NewID("TestTranslatorErrorsOut") + receiverID := component.MustNewID("TestTranslatorErrorsOut") tt, err := componenttest.SetupTelemetry(receiverID) assert.NoError(t, err, "SetupTelemetry should succeed") defer func() { @@ -164,7 +164,7 @@ func TestTranslatorErrorsOut(t *testing.T) { } func TestSegmentsConsumerErrorsOut(t *testing.T) { - receiverID := component.NewID("TestSegmentsConsumerErrorsOut") + receiverID := component.MustNewID("TestSegmentsConsumerErrorsOut") tt, err := componenttest.SetupTelemetry(receiverID) assert.NoError(t, err, "SetupTelemetry should succeed") defer func() { @@ -194,7 +194,7 @@ func TestSegmentsConsumerErrorsOut(t *testing.T) { } func TestPollerCloseError(t *testing.T) { - receiverID := component.NewID("TestPollerCloseError") + receiverID := component.MustNewID("TestPollerCloseError") tt, err := componenttest.SetupTelemetry(receiverID) assert.NoError(t, err, "SetupTelemetry should succeed") defer func() { @@ -212,7 +212,7 @@ func TestPollerCloseError(t *testing.T) { } func TestProxyCloseError(t *testing.T) { - receiverID := component.NewID("TestPollerCloseError") + receiverID := component.MustNewID("TestPollerCloseError") tt, err := componenttest.SetupTelemetry(receiverID) assert.NoError(t, err, "SetupTelemetry should succeed") defer func() { @@ -230,7 +230,7 @@ func TestProxyCloseError(t *testing.T) { } func TestBothPollerAndProxyCloseError(t *testing.T) { - receiverID := component.NewID("TestBothPollerAndProxyCloseError") + receiverID := component.MustNewID("TestBothPollerAndProxyCloseError") tt, err := componenttest.SetupTelemetry(receiverID) assert.NoError(t, err, "SetupTelemetry should succeed") defer func() { diff --git a/receiver/filelogreceiver/filelog_test.go b/receiver/filelogreceiver/filelog_test.go index 4a8d5ef4af4de..cf2673b4bdaa2 100644 --- a/receiver/filelogreceiver/filelog_test.go +++ b/receiver/filelogreceiver/filelog_test.go @@ -50,7 +50,7 @@ func TestLoadConfig(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() - sub, err := cm.Sub(component.NewID("filelog").String()) + sub, err := cm.Sub(component.MustNewID("filelog").String()) require.NoError(t, err) require.NoError(t, component.UnmarshalConfig(sub, cfg)) diff --git a/receiver/fluentforwardreceiver/config_test.go b/receiver/fluentforwardreceiver/config_test.go index c4678bc80af12..50c58cbde1a58 100644 --- a/receiver/fluentforwardreceiver/config_test.go +++ b/receiver/fluentforwardreceiver/config_test.go @@ -20,7 +20,7 @@ func TestLoadConfig(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() - sub, err := cm.Sub(component.NewID("fluentforward").String()) + sub, err := cm.Sub(component.MustNewID("fluentforward").String()) require.NoError(t, err) require.NoError(t, component.UnmarshalConfig(sub, cfg)) diff --git a/receiver/hostmetricsreceiver/hostmetrics_receiver_test.go b/receiver/hostmetricsreceiver/hostmetrics_receiver_test.go index bc14415c5c4f7..dc424677a6ccd 100644 --- a/receiver/hostmetricsreceiver/hostmetrics_receiver_test.go +++ b/receiver/hostmetricsreceiver/hostmetrics_receiver_test.go @@ -227,7 +227,7 @@ func (m *mockFactory) CreateMetricsScraper(context.Context, receiver.CreateSetti return args.Get(0).(scraperhelper.Scraper), args.Error(1) } -func (m *mockScraper) ID() component.ID { return component.NewID("mock_scraper") } +func (m *mockScraper) ID() component.ID { return component.MustNewID("mock_scraper") } func (m *mockScraper) Start(context.Context, component.Host) error { return nil } func (m *mockScraper) Shutdown(context.Context) error { return nil } func (m *mockScraper) Scrape(context.Context) (pmetric.Metrics, error) { diff --git a/receiver/jaegerreceiver/trace_receiver_test.go b/receiver/jaegerreceiver/trace_receiver_test.go index 2b93b0f4f5dc4..561c55c7d7b35 100644 --- a/receiver/jaegerreceiver/trace_receiver_test.go +++ b/receiver/jaegerreceiver/trace_receiver_test.go @@ -41,7 +41,7 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger" ) -var jaegerReceiver = component.NewIDWithName("jaeger", "receiver_test") +var jaegerReceiver = component.MustNewIDWithName("jaeger", "receiver_test") func TestTraceSource(t *testing.T) { set := receivertest.NewNopCreateSettings() diff --git a/receiver/k8sclusterreceiver/factory_test.go b/receiver/k8sclusterreceiver/factory_test.go index 8dc82905af2e6..747bc007f314a 100644 --- a/receiver/k8sclusterreceiver/factory_test.go +++ b/receiver/k8sclusterreceiver/factory_test.go @@ -111,8 +111,8 @@ func newNopHostWithExporters() component.Host { func (n *nopHostWithExporters) GetExporters() map[component.DataType]map[component.ID]component.Component { return map[component.DataType]map[component.ID]component.Component{ component.DataTypeMetrics: { - component.NewIDWithName("nop", "withoutmetadata"): MockExporter{}, - component.NewIDWithName("nop", "withmetadata"): mockExporterWithK8sMetadata{}, + component.MustNewIDWithName("nop", "withoutmetadata"): MockExporter{}, + component.MustNewIDWithName("nop", "withmetadata"): mockExporterWithK8sMetadata{}, }, } } diff --git a/receiver/k8sclusterreceiver/watcher_test.go b/receiver/k8sclusterreceiver/watcher_test.go index e3e63f56b43ee..22d626d822e36 100644 --- a/receiver/k8sclusterreceiver/watcher_test.go +++ b/receiver/k8sclusterreceiver/watcher_test.go @@ -54,7 +54,7 @@ func TestSetupMetadataExporters(t *testing.T) { fields{}, args{ exporters: map[component.ID]component.Component{ - component.NewID("nop"): MockExporter{}, + component.MustNewID("nop"): MockExporter{}, }, metadataExportersFromConfig: []string{"nop"}, }, @@ -66,7 +66,7 @@ func TestSetupMetadataExporters(t *testing.T) { metadataConsumers: []metadataConsumer{(&mockExporterWithK8sMetadata{}).ConsumeMetadata}, }, args{exporters: map[component.ID]component.Component{ - component.NewID("nop"): mockExporterWithK8sMetadata{}, + component.MustNewID("nop"): mockExporterWithK8sMetadata{}, }, metadataExportersFromConfig: []string{"nop"}, }, @@ -78,7 +78,7 @@ func TestSetupMetadataExporters(t *testing.T) { metadataConsumers: []metadataConsumer{}, }, args{exporters: map[component.ID]component.Component{ - component.NewID("nop"): mockExporterWithK8sMetadata{}, + component.MustNewID("nop"): mockExporterWithK8sMetadata{}, }, metadataExportersFromConfig: []string{"nop/1"}, }, diff --git a/receiver/namedpipereceiver/namedpipe_test.go b/receiver/namedpipereceiver/namedpipe_test.go index 652b699ee0a8a..7331e8c100613 100644 --- a/receiver/namedpipereceiver/namedpipe_test.go +++ b/receiver/namedpipereceiver/namedpipe_test.go @@ -41,7 +41,7 @@ func TestLoadConfig(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() - sub, err := cm.Sub(component.NewID("namedpipe").String()) + sub, err := cm.Sub(component.MustNewID("namedpipe").String()) require.NoError(t, err) require.NoError(t, component.UnmarshalConfig(sub, cfg)) diff --git a/receiver/opencensusreceiver/internal/ocmetrics/opencensus_test.go b/receiver/opencensusreceiver/internal/ocmetrics/opencensus_test.go index 2a3a4c9b4239d..8a4211fd1cb04 100644 --- a/receiver/opencensusreceiver/internal/ocmetrics/opencensus_test.go +++ b/receiver/opencensusreceiver/internal/ocmetrics/opencensus_test.go @@ -35,7 +35,7 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/opencensus" ) -var receiverID = component.NewID("opencensus") +var receiverID = component.MustNewID("opencensus") func TestReceiver_endToEnd(t *testing.T) { tt, err := componenttest.SetupTelemetry(receiverID) diff --git a/receiver/opencensusreceiver/internal/octrace/observability_test.go b/receiver/opencensusreceiver/internal/octrace/observability_test.go index 2eed308fb6fb0..2156e042b820f 100644 --- a/receiver/opencensusreceiver/internal/octrace/observability_test.go +++ b/receiver/opencensusreceiver/internal/octrace/observability_test.go @@ -23,7 +23,7 @@ import ( nooptrace "go.opentelemetry.io/otel/trace/noop" ) -var receiverID = component.NewID("opencensus") +var receiverID = component.MustNewID("opencensus") // Ensure that if we add a metrics exporter that our target metrics // will be recorded but also with the proper tag keys and values. diff --git a/receiver/prometheusreceiver/internal/transaction_test.go b/receiver/prometheusreceiver/internal/transaction_test.go index a6a6b8f667dae..196133ff56b9c 100644 --- a/receiver/prometheusreceiver/internal/transaction_test.go +++ b/receiver/prometheusreceiver/internal/transaction_test.go @@ -354,7 +354,7 @@ func TestAppendExemplarWithEmptyLabelArray(t *testing.T) { func nopObsRecv(t *testing.T) *receiverhelper.ObsReport { obsrecv, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{ - ReceiverID: component.NewID("prometheus"), + ReceiverID: component.MustNewID("prometheus"), Transport: transport, ReceiverCreateSettings: receivertest.NewNopCreateSettings(), }) diff --git a/receiver/purefareceiver/internal/bearertoken_test.go b/receiver/purefareceiver/internal/bearertoken_test.go index 214889aab0944..dfb947990c092 100644 --- a/receiver/purefareceiver/internal/bearertoken_test.go +++ b/receiver/purefareceiver/internal/bearertoken_test.go @@ -27,7 +27,7 @@ func TestBearerToken(t *testing.T) { baExt, err := baFactory.CreateExtension(context.Background(), extensiontest.NewNopCreateSettings(), baCfg) require.NoError(t, err) - baComponentName := component.NewIDWithName("bearertokenauth", "array01") + baComponentName := component.MustNewIDWithName("bearertokenauth", "array01") host := &mockHost{ Host: componenttest.NewNopHost(), diff --git a/receiver/purefareceiver/internal/scraper_test.go b/receiver/purefareceiver/internal/scraper_test.go index fb0aeec916aae..15c102787ef73 100644 --- a/receiver/purefareceiver/internal/scraper_test.go +++ b/receiver/purefareceiver/internal/scraper_test.go @@ -32,7 +32,7 @@ func TestToPrometheusConfig(t *testing.T) { host := &mockHost{ extensions: map[component.ID]component.Component{ - component.NewIDWithName("bearertokenauth", "array01"): baExt, + component.MustNewIDWithName("bearertokenauth", "array01"): baExt, }, } @@ -42,7 +42,7 @@ func TestToPrometheusConfig(t *testing.T) { { Address: "array01", Auth: configauth.Authentication{ - AuthenticatorID: component.NewIDWithName("bearertokenauth", "array01"), + AuthenticatorID: component.MustNewIDWithName("bearertokenauth", "array01"), }, }, } diff --git a/receiver/purefbreceiver/internal/baerertoken_test.go b/receiver/purefbreceiver/internal/baerertoken_test.go index 42af128f5154d..4eb80b0360e6f 100644 --- a/receiver/purefbreceiver/internal/baerertoken_test.go +++ b/receiver/purefbreceiver/internal/baerertoken_test.go @@ -27,7 +27,7 @@ func TestBearerToken(t *testing.T) { baExt, err := baFactory.CreateExtension(context.Background(), extensiontest.NewNopCreateSettings(), baCfg) require.NoError(t, err) - baComponentName := component.NewIDWithName("bearertokenauth", "fb02") + baComponentName := component.MustNewIDWithName("bearertokenauth", "fb02") host := &mockHost{ Host: componenttest.NewNopHost(), diff --git a/receiver/purefbreceiver/internal/scraper_test.go b/receiver/purefbreceiver/internal/scraper_test.go index f06928fc7e241..f0941e2df4617 100644 --- a/receiver/purefbreceiver/internal/scraper_test.go +++ b/receiver/purefbreceiver/internal/scraper_test.go @@ -32,7 +32,7 @@ func TestToPrometheusConfig(t *testing.T) { host := &mockHost{ extensions: map[component.ID]component.Component{ - component.NewIDWithName("bearertokenauth", "fb01"): baExt, + component.MustNewIDWithName("bearertokenauth", "fb01"): baExt, }, } @@ -42,7 +42,7 @@ func TestToPrometheusConfig(t *testing.T) { { Address: "fb01", Auth: configauth.Authentication{ - AuthenticatorID: component.NewIDWithName("bearertokenauth", "fb01"), + AuthenticatorID: component.MustNewIDWithName("bearertokenauth", "fb01"), }, }, } diff --git a/receiver/receivercreator/config_test.go b/receiver/receivercreator/config_test.go index ce3ceefb6f5cb..9daee44b7602d 100644 --- a/receiver/receivercreator/config_test.go +++ b/receiver/receivercreator/config_test.go @@ -72,7 +72,7 @@ func TestLoadConfig(t *testing.T) { expected: createDefaultConfig(), }, { - id: component.NewIDWithName("receiver_creator", ""), + id: component.MustNewIDWithName("receiver_creator", ""), expected: createDefaultConfig(), }, { @@ -81,7 +81,7 @@ func TestLoadConfig(t *testing.T) { receiverTemplates: map[string]receiverTemplate{ "examplereceiver/1": { receiverConfig: receiverConfig{ - id: component.NewIDWithName("examplereceiver", "1"), + id: component.MustNewIDWithName("examplereceiver", "1"), config: userConfigMap{ "key": "value", }, @@ -93,7 +93,7 @@ func TestLoadConfig(t *testing.T) { }, "nop/1": { receiverConfig: receiverConfig{ - id: component.NewIDWithName("nop", "1"), + id: component.MustNewIDWithName("nop", "1"), config: userConfigMap{ endpointConfigKey: "localhost:12345", }, @@ -105,8 +105,8 @@ func TestLoadConfig(t *testing.T) { }, }, WatchObservers: []component.ID{ - component.NewID("mock_observer"), - component.NewIDWithName("mock_observer", "with_name"), + component.MustNewID("mock_observer"), + component.MustNewIDWithName("mock_observer", "with_name"), }, ResourceAttributes: map[observer.EndpointType]map[string]string{ observer.ContainerType: {"container.key": "container.value"}, diff --git a/receiver/receivercreator/observerhandler_test.go b/receiver/receivercreator/observerhandler_test.go index 0a74bf04ffd6d..d1e220db55de5 100644 --- a/receiver/receivercreator/observerhandler_test.go +++ b/receiver/receivercreator/observerhandler_test.go @@ -30,7 +30,7 @@ func TestOnAddForMetrics(t *testing.T) { }{ { name: "dynamically set with supported endpoint", - receiverTemplateID: component.NewIDWithName("with.endpoint", "some.name"), + receiverTemplateID: component.MustNewIDWithName("with_endpoint", "some.name"), receiverTemplateConfig: userConfigMap{"int_field": 12345678}, expectedReceiverType: &nopWithEndpointReceiver{}, expectedReceiverConfig: &nopWithEndpointConfig{ @@ -40,7 +40,7 @@ func TestOnAddForMetrics(t *testing.T) { }, { name: "inherits supported endpoint", - receiverTemplateID: component.NewIDWithName("with.endpoint", "some.name"), + receiverTemplateID: component.MustNewIDWithName("with_endpoint", "some.name"), receiverTemplateConfig: userConfigMap{"endpoint": "some.endpoint"}, expectedReceiverType: &nopWithEndpointReceiver{}, expectedReceiverConfig: &nopWithEndpointConfig{ @@ -50,7 +50,7 @@ func TestOnAddForMetrics(t *testing.T) { }, { name: "not dynamically set with unsupported endpoint", - receiverTemplateID: component.NewIDWithName("without.endpoint", "some.name"), + receiverTemplateID: component.MustNewIDWithName("without_endpoint", "some.name"), receiverTemplateConfig: userConfigMap{"int_field": 23456789, "not_endpoint": "not.an.endpoint"}, expectedReceiverType: &nopWithoutEndpointReceiver{}, expectedReceiverConfig: &nopWithoutEndpointConfig{ @@ -60,9 +60,9 @@ func TestOnAddForMetrics(t *testing.T) { }, { name: "inherits unsupported endpoint", - receiverTemplateID: component.NewIDWithName("without.endpoint", "some.name"), + receiverTemplateID: component.MustNewIDWithName("without_endpoint", "some.name"), receiverTemplateConfig: userConfigMap{"endpoint": "unsupported.endpoint"}, - expectedError: "failed to load \"without.endpoint/some.name\" template config: 1 error(s) decoding:\n\n* '' has invalid keys: endpoint", + expectedError: "failed to load \"without_endpoint/some.name\" template config: 1 error(s) decoding:\n\n* '' has invalid keys: endpoint", }, } { t.Run(test.name, func(t *testing.T) { @@ -132,7 +132,7 @@ func TestOnAddForLogs(t *testing.T) { }{ { name: "dynamically set with supported endpoint", - receiverTemplateID: component.NewIDWithName("with.endpoint", "some.name"), + receiverTemplateID: component.MustNewIDWithName("with_endpoint", "some.name"), receiverTemplateConfig: userConfigMap{"int_field": 12345678}, expectedReceiverType: &nopWithEndpointReceiver{}, expectedReceiverConfig: &nopWithEndpointConfig{ @@ -142,7 +142,7 @@ func TestOnAddForLogs(t *testing.T) { }, { name: "inherits supported endpoint", - receiverTemplateID: component.NewIDWithName("with.endpoint", "some.name"), + receiverTemplateID: component.MustNewIDWithName("with_endpoint", "some.name"), receiverTemplateConfig: userConfigMap{"endpoint": "some.endpoint"}, expectedReceiverType: &nopWithEndpointReceiver{}, expectedReceiverConfig: &nopWithEndpointConfig{ @@ -152,7 +152,7 @@ func TestOnAddForLogs(t *testing.T) { }, { name: "not dynamically set with unsupported endpoint", - receiverTemplateID: component.NewIDWithName("without.endpoint", "some.name"), + receiverTemplateID: component.MustNewIDWithName("without_endpoint", "some.name"), receiverTemplateConfig: userConfigMap{"int_field": 23456789, "not_endpoint": "not.an.endpoint"}, expectedReceiverType: &nopWithoutEndpointReceiver{}, expectedReceiverConfig: &nopWithoutEndpointConfig{ @@ -162,9 +162,9 @@ func TestOnAddForLogs(t *testing.T) { }, { name: "inherits unsupported endpoint", - receiverTemplateID: component.NewIDWithName("without.endpoint", "some.name"), + receiverTemplateID: component.MustNewIDWithName("without_endpoint", "some.name"), receiverTemplateConfig: userConfigMap{"endpoint": "unsupported.endpoint"}, - expectedError: "failed to load \"without.endpoint/some.name\" template config: 1 error(s) decoding:\n\n* '' has invalid keys: endpoint", + expectedError: "failed to load \"without_endpoint/some.name\" template config: 1 error(s) decoding:\n\n* '' has invalid keys: endpoint", }, } { t.Run(test.name, func(t *testing.T) { @@ -234,7 +234,7 @@ func TestOnAddForTraces(t *testing.T) { }{ { name: "dynamically set with supported endpoint", - receiverTemplateID: component.NewIDWithName("with.endpoint", "some.name"), + receiverTemplateID: component.MustNewIDWithName("with_endpoint", "some.name"), receiverTemplateConfig: userConfigMap{"int_field": 12345678}, expectedReceiverType: &nopWithEndpointReceiver{}, expectedReceiverConfig: &nopWithEndpointConfig{ @@ -244,7 +244,7 @@ func TestOnAddForTraces(t *testing.T) { }, { name: "inherits supported endpoint", - receiverTemplateID: component.NewIDWithName("with.endpoint", "some.name"), + receiverTemplateID: component.MustNewIDWithName("with_endpoint", "some.name"), receiverTemplateConfig: userConfigMap{"endpoint": "some.endpoint"}, expectedReceiverType: &nopWithEndpointReceiver{}, expectedReceiverConfig: &nopWithEndpointConfig{ @@ -254,7 +254,7 @@ func TestOnAddForTraces(t *testing.T) { }, { name: "not dynamically set with unsupported endpoint", - receiverTemplateID: component.NewIDWithName("without.endpoint", "some.name"), + receiverTemplateID: component.MustNewIDWithName("without_endpoint", "some.name"), receiverTemplateConfig: userConfigMap{"int_field": 23456789, "not_endpoint": "not.an.endpoint"}, expectedReceiverType: &nopWithoutEndpointReceiver{}, expectedReceiverConfig: &nopWithoutEndpointConfig{ @@ -264,9 +264,9 @@ func TestOnAddForTraces(t *testing.T) { }, { name: "inherits unsupported endpoint", - receiverTemplateID: component.NewIDWithName("without.endpoint", "some.name"), + receiverTemplateID: component.MustNewIDWithName("without_endpoint", "some.name"), receiverTemplateConfig: userConfigMap{"endpoint": "unsupported.endpoint"}, - expectedError: "failed to load \"without.endpoint/some.name\" template config: 1 error(s) decoding:\n\n* '' has invalid keys: endpoint", + expectedError: "failed to load \"without_endpoint/some.name\" template config: 1 error(s) decoding:\n\n* '' has invalid keys: endpoint", }, } { t.Run(test.name, func(t *testing.T) { @@ -329,7 +329,7 @@ func TestOnAddForTraces(t *testing.T) { func TestOnRemoveForMetrics(t *testing.T) { cfg := createDefaultConfig().(*Config) rcvrCfg := receiverConfig{ - id: component.NewIDWithName("with.endpoint", "some.name"), + id: component.MustNewIDWithName("with_endpoint", "some.name"), config: userConfigMap{"endpoint": "some.endpoint"}, endpointID: portEndpoint.ID, } @@ -358,7 +358,7 @@ func TestOnRemoveForMetrics(t *testing.T) { func TestOnRemoveForLogs(t *testing.T) { cfg := createDefaultConfig().(*Config) rcvrCfg := receiverConfig{ - id: component.NewIDWithName("with.endpoint", "some.name"), + id: component.MustNewIDWithName("with_endpoint", "some.name"), config: userConfigMap{"endpoint": "some.endpoint"}, endpointID: portEndpoint.ID, } @@ -387,7 +387,7 @@ func TestOnRemoveForLogs(t *testing.T) { func TestOnChange(t *testing.T) { cfg := createDefaultConfig().(*Config) rcvrCfg := receiverConfig{ - id: component.NewIDWithName("with.endpoint", "some.name"), + id: component.MustNewIDWithName("with_endpoint", "some.name"), config: userConfigMap{"endpoint": "some.endpoint"}, endpointID: portEndpoint.ID, } @@ -450,8 +450,8 @@ type mockHost struct { func newMockHost(t *testing.T, host component.Host) *mockHost { factories, err := otelcoltest.NopFactories() require.NoError(t, err) - factories.Receivers["with.endpoint"] = &nopWithEndpointFactory{Factory: receivertest.NewNopFactory()} - factories.Receivers["without.endpoint"] = &nopWithoutEndpointFactory{Factory: receivertest.NewNopFactory()} + factories.Receivers[component.MustNewType("with_endpoint")] = &nopWithEndpointFactory{Factory: receivertest.NewNopFactory()} + factories.Receivers[component.MustNewType("without_endpoint")] = &nopWithoutEndpointFactory{Factory: receivertest.NewNopFactory()} return &mockHost{t: t, factories: factories, Host: host} } @@ -478,7 +478,7 @@ func newMockRunner(t *testing.T) *mockRunner { return &mockRunner{ receiverRunner: receiverRunner{ params: cs, - idNamespace: component.NewIDWithName("some.type", "some.name"), + idNamespace: component.MustNewIDWithName("some_type", "some.name"), host: newMockHost(t, componenttest.NewNopHost()), }, } @@ -491,7 +491,7 @@ func newObserverHandler( nextTraces consumer.Traces, ) (*observerHandler, *mockRunner) { set := receivertest.NewNopCreateSettings() - set.ID = component.NewIDWithName("some.type", "some.name") + set.ID = component.MustNewIDWithName("some_type", "some.name") mr := newMockRunner(t) return &observerHandler{ params: set, diff --git a/receiver/receivercreator/receiver_test.go b/receiver/receivercreator/receiver_test.go index 34b9637871974..6e5b70d3f87f2 100644 --- a/receiver/receivercreator/receiver_test.go +++ b/receiver/receivercreator/receiver_test.go @@ -66,8 +66,8 @@ func TestMockedEndToEnd(t *testing.T) { host := &mockHostFactories{Host: componenttest.NewNopHost(), factories: factories} host.extensions = map[component.ID]component.Component{ - component.NewID("mock_observer"): &mockObserver{}, - component.NewIDWithName("mock_observer", "with_name"): &mockObserver{}, + component.MustNewID("mock_observer"): &mockObserver{}, + component.MustNewIDWithName("mock_observer", "with_name"): &mockObserver{}, } cfg := factory.CreateDefaultConfig() diff --git a/receiver/receivercreator/runner_test.go b/receiver/receivercreator/runner_test.go index c6aeff382a6aa..ca80b5fc350e3 100644 --- a/receiver/receivercreator/runner_test.go +++ b/receiver/receivercreator/runner_test.go @@ -43,7 +43,7 @@ func Test_loadAndCreateMetricsRuntimeReceiver(t *testing.T) { t.Run("test create receiver from loaded config", func(t *testing.T) { recvr, err := run.createMetricsRuntimeReceiver( exampleFactory, - component.NewIDWithName("nop", "1/receiver_creator/1{endpoint=\"localhost:12345\"}/endpoint.id"), + component.MustNewIDWithName("nop", "1/receiver_creator/1{endpoint=\"localhost:12345\"}/endpoint.id"), loadedConfig, nil) require.NoError(t, err) @@ -68,7 +68,7 @@ func TestValidateSetEndpointFromConfig(t *testing.T) { Endpoint any `mapstructure:"endpoint"` } - receiverWithEndpoint := receiver.NewFactory("with.endpoint", func() component.Config { + receiverWithEndpoint := receiver.NewFactory(component.MustNewType("with_endpoint"), func() component.Config { return &configWithEndpoint{} }) @@ -76,7 +76,7 @@ func TestValidateSetEndpointFromConfig(t *testing.T) { NotEndpoint any `mapstructure:"not.endpoint"` } - receiverWithoutEndpoint := receiver.NewFactory("without.endpoint", func() component.Config { + receiverWithoutEndpoint := receiver.NewFactory(component.MustNewType("without_endpoint"), func() component.Config { return &configWithoutEndpoint{} }) diff --git a/receiver/skywalkingreceiver/skywalking_receiver_test.go b/receiver/skywalkingreceiver/skywalking_receiver_test.go index ea8a1d467b4f3..e16cc95d53dca 100644 --- a/receiver/skywalkingreceiver/skywalking_receiver_test.go +++ b/receiver/skywalkingreceiver/skywalking_receiver_test.go @@ -26,7 +26,7 @@ import ( ) var ( - skywalkingReceiver = component.NewIDWithName("skywalking", "receiver_test") + skywalkingReceiver = component.MustNewIDWithName("skywalking", "receiver_test") ) var traceJSON = []byte(` diff --git a/receiver/solacereceiver/factory_test.go b/receiver/solacereceiver/factory_test.go index 402cf436319ae..5de3ab748504a 100644 --- a/receiver/solacereceiver/factory_test.go +++ b/receiver/solacereceiver/factory_test.go @@ -31,7 +31,7 @@ func TestCreateTracesReceiver(t *testing.T) { require.NoError(t, component.UnmarshalConfig(sub, cfg)) set := receivertest.NewNopCreateSettings() - set.ID = component.NewIDWithName("solace", "factory") + set.ID = component.MustNewIDWithName("solace", "factory") receiver, err := factory.CreateTracesReceiver( context.Background(), set, @@ -95,7 +95,7 @@ func TestCreateTracesReceiverBadMetrics(t *testing.T) { require.NoError(t, err) require.NoError(t, component.UnmarshalConfig(sub, cfg)) set := receivertest.NewNopCreateSettings() - set.ID = component.NewIDWithName("solace", "factory") + set.ID = component.MustNewIDWithName("solace", "factory") receiver, err := factory.CreateTracesReceiver( context.Background(), set, diff --git a/receiver/splunkenterprisereceiver/client_test.go b/receiver/splunkenterprisereceiver/client_test.go index 3c876604227e1..83ea4caf1bb48 100644 --- a/receiver/splunkenterprisereceiver/client_test.go +++ b/receiver/splunkenterprisereceiver/client_test.go @@ -37,7 +37,7 @@ func TestClientCreation(t *testing.T) { ClientConfig: confighttp.ClientConfig{ Endpoint: "https://localhost:8089", Auth: &configauth.Authentication{ - AuthenticatorID: component.NewID("basicauth/client"), + AuthenticatorID: component.MustNewIDWithName("basicauth", "client"), }, }, ScraperControllerSettings: scraperhelper.ScraperControllerSettings{ @@ -49,7 +49,7 @@ func TestClientCreation(t *testing.T) { host := &mockHost{ extensions: map[component.ID]component.Component{ - component.NewID("basicauth/client"): auth.NewClient(), + component.MustNewIDWithName("basicauth", "client"): auth.NewClient(), }, } // create a client from an example config @@ -68,7 +68,7 @@ func TestClientCreateRequest(t *testing.T) { ClientConfig: confighttp.ClientConfig{ Endpoint: "https://localhost:8089", Auth: &configauth.Authentication{ - AuthenticatorID: component.NewID("basicauth/client"), + AuthenticatorID: component.MustNewIDWithName("basicauth", "client"), }, }, ScraperControllerSettings: scraperhelper.ScraperControllerSettings{ @@ -80,7 +80,7 @@ func TestClientCreateRequest(t *testing.T) { host := &mockHost{ extensions: map[component.ID]component.Component{ - component.NewID("basicauth/client"): auth.NewClient(), + component.MustNewIDWithName("basicauth", "client"): auth.NewClient(), }, } // create a client from an example config @@ -150,7 +150,7 @@ func TestAPIRequestCreate(t *testing.T) { ClientConfig: confighttp.ClientConfig{ Endpoint: "https://localhost:8089", Auth: &configauth.Authentication{ - AuthenticatorID: component.NewID("basicauth/client"), + AuthenticatorID: component.MustNewIDWithName("basicauth", "client"), }, }, ScraperControllerSettings: scraperhelper.ScraperControllerSettings{ @@ -162,7 +162,7 @@ func TestAPIRequestCreate(t *testing.T) { host := &mockHost{ extensions: map[component.ID]component.Component{ - component.NewID("basicauth/client"): auth.NewClient(), + component.MustNewIDWithName("basicauth", "client"): auth.NewClient(), }, } // create a client from an example config diff --git a/receiver/splunkenterprisereceiver/scraper_test.go b/receiver/splunkenterprisereceiver/scraper_test.go index 8a9a994cde1a0..c0ae5d7c624a2 100644 --- a/receiver/splunkenterprisereceiver/scraper_test.go +++ b/receiver/splunkenterprisereceiver/scraper_test.go @@ -87,7 +87,7 @@ func TestScraper(t *testing.T) { ClientConfig: confighttp.ClientConfig{ Endpoint: ts.URL, Auth: &configauth.Authentication{ - AuthenticatorID: component.NewID("basicauth/client"), + AuthenticatorID: component.MustNewIDWithName("basicauth", "client"), }, }, ScraperControllerSettings: scraperhelper.ScraperControllerSettings{ @@ -100,7 +100,7 @@ func TestScraper(t *testing.T) { host := &mockHost{ extensions: map[component.ID]component.Component{ - component.NewID("basicauth/client"): auth.NewClient(), + component.MustNewIDWithName("basicauth", "client"): auth.NewClient(), }, } diff --git a/receiver/sqlqueryreceiver/receiver.go b/receiver/sqlqueryreceiver/receiver.go index f9b54613e6e53..269237140998d 100644 --- a/receiver/sqlqueryreceiver/receiver.go +++ b/receiver/sqlqueryreceiver/receiver.go @@ -41,7 +41,7 @@ func createMetricsReceiverFunc(sqlOpenerFunc sqlquery.SQLOpenerFunc, clientProvi if len(query.Metrics) == 0 { continue } - id := component.NewIDWithName("sqlqueryreceiver", fmt.Sprintf("query-%d: %s", i, query.SQL)) + id := component.MustNewIDWithName("sqlqueryreceiver", fmt.Sprintf("query-%d: %s", i, query.SQL)) dbProviderFunc := func() (*sql.DB, error) { return sqlOpenerFunc(sqlCfg.Driver, sqlCfg.DataSource) } diff --git a/receiver/sshcheckreceiver/internal/configssh/configssh_test.go b/receiver/sshcheckreceiver/internal/configssh/configssh_test.go index 96f9c9493e558..47097a5f0fdca 100644 --- a/receiver/sshcheckreceiver/internal/configssh/configssh_test.go +++ b/receiver/sshcheckreceiver/internal/configssh/configssh_test.go @@ -24,7 +24,7 @@ type mockHost struct { func TestAllSSHClientSettings(t *testing.T) { host := &mockHost{ ext: map[component.ID]extension.Extension{ - component.NewID("testauth"): &authtest.MockClient{}, + component.MustNewID("testauth"): &authtest.MockClient{}, }, } @@ -127,7 +127,7 @@ func TestAllSSHClientSettings(t *testing.T) { func Test_Client_Dial(t *testing.T) { host := &mockHost{ ext: map[component.ID]extension.Extension{ - component.NewID("testauth"): &authtest.MockClient{}, + component.MustNewID("testauth"): &authtest.MockClient{}, }, } @@ -201,7 +201,7 @@ func Test_Client_Dial(t *testing.T) { func Test_Client_ToSFTPClient(t *testing.T) { host := &mockHost{ ext: map[component.ID]extension.Extension{ - component.NewID("testauth"): &authtest.MockClient{}, + component.MustNewID("testauth"): &authtest.MockClient{}, }, }