From cf06b167ad2043c98bd7a49442bd13e148c32981 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Fri, 27 Sep 2024 09:37:59 -0700 Subject: [PATCH] Deprecate funcs that repeate receiver in name Signed-off-by: Bogdan Drutu --- .chloggen/deprecate-receiver-name.yaml | 27 ++++ .../generated_component_test.go | 6 +- .../internal/samplereceiver/metrics_test.go | 2 +- .../internal/templates/component_test.go.tmpl | 6 +- exporter/exportertest/contract_checker.go | 6 +- internal/e2e/otlphttp_test.go | 6 +- otelcol/command_components.go | 6 +- .../nopreceiver/generated_component_test.go | 6 +- receiver/nopreceiver/nop_receiver_test.go | 6 +- receiver/otlpreceiver/factory.go | 4 +- receiver/otlpreceiver/factory_test.go | 24 +-- .../otlpreceiver/generated_component_test.go | 6 +- receiver/otlpreceiver/otlp_test.go | 6 +- receiver/receiver.go | 138 +++++++++++------- receiver/receiver_test.go | 18 +-- receiver/receiverprofiles/profiles.go | 60 +++++--- receiver/receiverprofiles/receiver_test.go | 4 +- receiver/receivertest/contract_checker.go | 6 +- receiver/receivertest/nop_receiver_test.go | 8 +- service/internal/builders/receiver.go | 16 +- service/internal/builders/receiver_test.go | 8 +- .../testcomponents/example_receiver.go | 27 ++-- 22 files changed, 235 insertions(+), 161 deletions(-) create mode 100644 .chloggen/deprecate-receiver-name.yaml diff --git a/.chloggen/deprecate-receiver-name.yaml b/.chloggen/deprecate-receiver-name.yaml new file mode 100644 index 00000000000..fd47163dcc3 --- /dev/null +++ b/.chloggen/deprecate-receiver-name.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: deprecation + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: receiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Deprecate funcs that repeat "receiver" in name + +# One or more tracking issues or pull requests related to the change +issues: [11287] + +# (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: | + Factory.Create[Traces|Metrics|Logs|Profiles]Receiver -> Factory.Create[Traces|Metrics|Logs|Profiles] + Factory.[Traces|Metrics|Logs|Profiles]ReceiverStability -> Factory.[Traces|Metrics|Logs|Profiles]Stability + +# 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] diff --git a/cmd/mdatagen/internal/samplereceiver/generated_component_test.go b/cmd/mdatagen/internal/samplereceiver/generated_component_test.go index ce37390aecd..3191974f91a 100644 --- a/cmd/mdatagen/internal/samplereceiver/generated_component_test.go +++ b/cmd/mdatagen/internal/samplereceiver/generated_component_test.go @@ -36,21 +36,21 @@ func TestComponentLifecycle(t *testing.T) { { name: "logs", createFn: func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + return factory.CreateLogs(ctx, set, cfg, consumertest.NewNop()) }, }, { name: "metrics", createFn: func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + return factory.CreateMetrics(ctx, set, cfg, consumertest.NewNop()) }, }, { name: "traces", createFn: func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateTracesReceiver(ctx, set, cfg, consumertest.NewNop()) + return factory.CreateTraces(ctx, set, cfg, consumertest.NewNop()) }, }, } diff --git a/cmd/mdatagen/internal/samplereceiver/metrics_test.go b/cmd/mdatagen/internal/samplereceiver/metrics_test.go index 733eaa0239f..fe6438bb304 100644 --- a/cmd/mdatagen/internal/samplereceiver/metrics_test.go +++ b/cmd/mdatagen/internal/samplereceiver/metrics_test.go @@ -26,7 +26,7 @@ func TestGeneratedMetrics(t *testing.T) { func TestComponentTelemetry(t *testing.T) { tt := setupTestTelemetry() factory := NewFactory() - receiver, err := factory.CreateMetricsReceiver(context.Background(), tt.NewSettings(), componenttest.NewNopHost(), new(consumertest.MetricsSink)) + receiver, err := factory.CreateMetrics(context.Background(), tt.NewSettings(), componenttest.NewNopHost(), new(consumertest.MetricsSink)) require.NoError(t, err) tt.assertMetrics(t, []metricdata.Metrics{ { diff --git a/cmd/mdatagen/internal/templates/component_test.go.tmpl b/cmd/mdatagen/internal/templates/component_test.go.tmpl index c40f3f39d07..27bdf0b4a0b 100644 --- a/cmd/mdatagen/internal/templates/component_test.go.tmpl +++ b/cmd/mdatagen/internal/templates/component_test.go.tmpl @@ -268,7 +268,7 @@ func TestComponentLifecycle(t *testing.T) { { name: "logs", createFn: func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + return factory.CreateLogs(ctx, set, cfg, consumertest.NewNop()) }, }, {{ end }} @@ -276,7 +276,7 @@ func TestComponentLifecycle(t *testing.T) { { name: "metrics", createFn: func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + return factory.CreateMetrics(ctx, set, cfg, consumertest.NewNop()) }, }, {{ end }} @@ -284,7 +284,7 @@ func TestComponentLifecycle(t *testing.T) { { name: "traces", createFn: func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateTracesReceiver(ctx, set, cfg, consumertest.NewNop()) + return factory.CreateTraces(ctx, set, cfg, consumertest.NewNop()) }, }, {{ end }} diff --git a/exporter/exportertest/contract_checker.go b/exporter/exportertest/contract_checker.go index 52c85c33a0f..2b1661e9317 100644 --- a/exporter/exportertest/contract_checker.go +++ b/exporter/exportertest/contract_checker.go @@ -92,17 +92,17 @@ func checkConsumeContractScenario(t *testing.T, params CheckConsumeContractParam mockConsumerInstance := newMockConsumer(decisionFunc) switch params.Signal { case pipeline.SignalLogs: - r, err := params.ReceiverFactory.CreateLogsReceiver(context.Background(), receivertest.NewNopSettings(), params.ReceiverConfig, &mockConsumerInstance) + r, err := params.ReceiverFactory.CreateLogs(context.Background(), receivertest.NewNopSettings(), params.ReceiverConfig, &mockConsumerInstance) require.NoError(t, err) require.NoError(t, r.Start(context.Background(), componenttest.NewNopHost())) checkLogs(t, params, r, &mockConsumerInstance, checkIfTestPassed) case pipeline.SignalTraces: - r, err := params.ReceiverFactory.CreateTracesReceiver(context.Background(), receivertest.NewNopSettings(), params.ReceiverConfig, &mockConsumerInstance) + r, err := params.ReceiverFactory.CreateTraces(context.Background(), receivertest.NewNopSettings(), params.ReceiverConfig, &mockConsumerInstance) require.NoError(t, err) require.NoError(t, r.Start(context.Background(), componenttest.NewNopHost())) checkTraces(t, params, r, &mockConsumerInstance, checkIfTestPassed) case pipeline.SignalMetrics: - r, err := params.ReceiverFactory.CreateMetricsReceiver(context.Background(), receivertest.NewNopSettings(), params.ReceiverConfig, &mockConsumerInstance) + r, err := params.ReceiverFactory.CreateMetrics(context.Background(), receivertest.NewNopSettings(), params.ReceiverConfig, &mockConsumerInstance) require.NoError(t, err) require.NoError(t, r.Start(context.Background(), componenttest.NewNopHost())) checkMetrics(t, params, r, &mockConsumerInstance, checkIfTestPassed) diff --git a/internal/e2e/otlphttp_test.go b/internal/e2e/otlphttp_test.go index 9a7e8ded972..7b320e57dbb 100644 --- a/internal/e2e/otlphttp_test.go +++ b/internal/e2e/otlphttp_test.go @@ -328,7 +328,7 @@ func createExporterConfig(baseURL string, defaultCfg component.Config) *otlphttp func startTracesReceiver(t *testing.T, addr string, next consumer.Traces) { factory := otlpreceiver.NewFactory() cfg := createReceiverConfig(addr, factory.CreateDefaultConfig()) - recv, err := factory.CreateTracesReceiver(context.Background(), receivertest.NewNopSettings(), cfg, next) + recv, err := factory.CreateTraces(context.Background(), receivertest.NewNopSettings(), cfg, next) require.NoError(t, err) startAndCleanup(t, recv) } @@ -336,7 +336,7 @@ func startTracesReceiver(t *testing.T, addr string, next consumer.Traces) { func startMetricsReceiver(t *testing.T, addr string, next consumer.Metrics) { factory := otlpreceiver.NewFactory() cfg := createReceiverConfig(addr, factory.CreateDefaultConfig()) - recv, err := factory.CreateMetricsReceiver(context.Background(), receivertest.NewNopSettings(), cfg, next) + recv, err := factory.CreateMetrics(context.Background(), receivertest.NewNopSettings(), cfg, next) require.NoError(t, err) startAndCleanup(t, recv) } @@ -344,7 +344,7 @@ func startMetricsReceiver(t *testing.T, addr string, next consumer.Metrics) { func startLogsReceiver(t *testing.T, addr string, next consumer.Logs) { factory := otlpreceiver.NewFactory() cfg := createReceiverConfig(addr, factory.CreateDefaultConfig()) - recv, err := factory.CreateLogsReceiver(context.Background(), receivertest.NewNopSettings(), cfg, next) + recv, err := factory.CreateLogs(context.Background(), receivertest.NewNopSettings(), cfg, next) require.NoError(t, err) startAndCleanup(t, recv) } diff --git a/otelcol/command_components.go b/otelcol/command_components.go index 819e189c4d8..becd8ff9ae7 100644 --- a/otelcol/command_components.go +++ b/otelcol/command_components.go @@ -92,9 +92,9 @@ func newComponentsCommand(set CollectorSettings) *cobra.Command { Name: rcv.Type(), Module: factories.ReceiverModules[rcv.Type()], Stability: map[string]string{ - "logs": rcv.LogsReceiverStability().String(), - "metrics": rcv.MetricsReceiverStability().String(), - "traces": rcv.TracesReceiverStability().String(), + "logs": rcv.LogsStability().String(), + "metrics": rcv.MetricsStability().String(), + "traces": rcv.TracesStability().String(), }, }) } diff --git a/receiver/nopreceiver/generated_component_test.go b/receiver/nopreceiver/generated_component_test.go index 14c94434412..716724ce0e3 100644 --- a/receiver/nopreceiver/generated_component_test.go +++ b/receiver/nopreceiver/generated_component_test.go @@ -35,21 +35,21 @@ func TestComponentLifecycle(t *testing.T) { { name: "logs", createFn: func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + return factory.CreateLogs(ctx, set, cfg, consumertest.NewNop()) }, }, { name: "metrics", createFn: func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + return factory.CreateMetrics(ctx, set, cfg, consumertest.NewNop()) }, }, { name: "traces", createFn: func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateTracesReceiver(ctx, set, cfg, consumertest.NewNop()) + return factory.CreateTraces(ctx, set, cfg, consumertest.NewNop()) }, }, } diff --git a/receiver/nopreceiver/nop_receiver_test.go b/receiver/nopreceiver/nop_receiver_test.go index 85518f47a49..c51baa0c85c 100644 --- a/receiver/nopreceiver/nop_receiver_test.go +++ b/receiver/nopreceiver/nop_receiver_test.go @@ -23,17 +23,17 @@ func TestNewNopFactory(t *testing.T) { cfg := factory.CreateDefaultConfig() assert.Equal(t, &struct{}{}, cfg) - traces, err := factory.CreateTracesReceiver(context.Background(), receivertest.NewNopSettings(), cfg, consumertest.NewNop()) + traces, err := factory.CreateTraces(context.Background(), receivertest.NewNopSettings(), cfg, consumertest.NewNop()) require.NoError(t, err) assert.NoError(t, traces.Start(context.Background(), componenttest.NewNopHost())) assert.NoError(t, traces.Shutdown(context.Background())) - metrics, err := factory.CreateMetricsReceiver(context.Background(), receivertest.NewNopSettings(), cfg, consumertest.NewNop()) + metrics, err := factory.CreateMetrics(context.Background(), receivertest.NewNopSettings(), cfg, consumertest.NewNop()) require.NoError(t, err) assert.NoError(t, metrics.Start(context.Background(), componenttest.NewNopHost())) assert.NoError(t, metrics.Shutdown(context.Background())) - logs, err := factory.CreateLogsReceiver(context.Background(), receivertest.NewNopSettings(), cfg, consumertest.NewNop()) + logs, err := factory.CreateLogs(context.Background(), receivertest.NewNopSettings(), cfg, consumertest.NewNop()) require.NoError(t, err) assert.NoError(t, logs.Start(context.Background(), componenttest.NewNopHost())) assert.NoError(t, logs.Shutdown(context.Background())) diff --git a/receiver/otlpreceiver/factory.go b/receiver/otlpreceiver/factory.go index aebdffafad0..f2feeb7383a 100644 --- a/receiver/otlpreceiver/factory.go +++ b/receiver/otlpreceiver/factory.go @@ -154,8 +154,8 @@ func createProfiles( } // This is the map of already created OTLP receivers for particular configurations. -// We maintain this map because the Factory is asked trace and metric receivers separately -// when it gets CreateTracesReceiver() and CreateMetricsReceiver() but they must not +// We maintain this map because the receiver.Factory is asked trace and metric receivers separately +// when it gets CreateTraces() and CreateMetrics() but they must not // create separate objects, they must use one otlpReceiver object per configuration. // When the receiver is shutdown it should be removed from this map so the same configuration // can be recreated successfully. diff --git a/receiver/otlpreceiver/factory_test.go b/receiver/otlpreceiver/factory_test.go index 10afd012da6..217fad88ec8 100644 --- a/receiver/otlpreceiver/factory_test.go +++ b/receiver/otlpreceiver/factory_test.go @@ -36,19 +36,19 @@ func TestCreateSameReceiver(t *testing.T) { cfg.HTTP.Endpoint = testutil.GetAvailableLocalAddress(t) creationSet := receivertest.NewNopSettings() - tReceiver, err := factory.CreateTracesReceiver(context.Background(), creationSet, cfg, consumertest.NewNop()) + tReceiver, err := factory.CreateTraces(context.Background(), creationSet, cfg, consumertest.NewNop()) assert.NotNil(t, tReceiver) require.NoError(t, err) - mReceiver, err := factory.CreateMetricsReceiver(context.Background(), creationSet, cfg, consumertest.NewNop()) + mReceiver, err := factory.CreateMetrics(context.Background(), creationSet, cfg, consumertest.NewNop()) assert.NotNil(t, mReceiver) require.NoError(t, err) - lReceiver, err := factory.CreateMetricsReceiver(context.Background(), creationSet, cfg, consumertest.NewNop()) + lReceiver, err := factory.CreateMetrics(context.Background(), creationSet, cfg, consumertest.NewNop()) assert.NotNil(t, lReceiver) require.NoError(t, err) - pReceiver, err := factory.(receiverprofiles.Factory).CreateProfilesReceiver(context.Background(), creationSet, cfg, consumertest.NewNop()) + pReceiver, err := factory.(receiverprofiles.Factory).CreateProfiles(context.Background(), creationSet, cfg, consumertest.NewNop()) assert.NotNil(t, pReceiver) require.NoError(t, err) @@ -57,7 +57,7 @@ func TestCreateSameReceiver(t *testing.T) { assert.Same(t, tReceiver, pReceiver) } -func TestCreateTracesReceiver(t *testing.T) { +func TestCreateTraces(t *testing.T) { factory := NewFactory() defaultGRPCSettings := &configgrpc.ServerConfig{ NetAddr: confignet.AddrConfig{ @@ -135,7 +135,7 @@ func TestCreateTracesReceiver(t *testing.T) { creationSet := receivertest.NewNopSettings() for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - tr, err := factory.CreateTracesReceiver(ctx, creationSet, tt.cfg, tt.sink) + tr, err := factory.CreateTraces(ctx, creationSet, tt.cfg, tt.sink) if tt.wantErr { assert.Error(t, err) return @@ -151,7 +151,7 @@ func TestCreateTracesReceiver(t *testing.T) { } } -func TestCreateMetricReceiver(t *testing.T) { +func TestCreateMetric(t *testing.T) { factory := NewFactory() defaultGRPCSettings := &configgrpc.ServerConfig{ NetAddr: confignet.AddrConfig{ @@ -229,7 +229,7 @@ func TestCreateMetricReceiver(t *testing.T) { creationSet := receivertest.NewNopSettings() for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - mr, err := factory.CreateMetricsReceiver(ctx, creationSet, tt.cfg, tt.sink) + mr, err := factory.CreateMetrics(ctx, creationSet, tt.cfg, tt.sink) if tt.wantErr { assert.Error(t, err) return @@ -245,7 +245,7 @@ func TestCreateMetricReceiver(t *testing.T) { } } -func TestCreateLogReceiver(t *testing.T) { +func TestCreateLogs(t *testing.T) { factory := NewFactory() defaultGRPCSettings := &configgrpc.ServerConfig{ NetAddr: confignet.AddrConfig{ @@ -323,7 +323,7 @@ func TestCreateLogReceiver(t *testing.T) { creationSet := receivertest.NewNopSettings() for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - mr, err := factory.CreateLogsReceiver(ctx, creationSet, tt.cfg, tt.sink) + mr, err := factory.CreateLogs(ctx, creationSet, tt.cfg, tt.sink) if tt.wantErr { assert.Error(t, err) return @@ -339,7 +339,7 @@ func TestCreateLogReceiver(t *testing.T) { } } -func TestCreateProfilesReceiver(t *testing.T) { +func TestCreateProfiles(t *testing.T) { factory := NewFactory() defaultGRPCSettings := &configgrpc.ServerConfig{ NetAddr: confignet.AddrConfig{ @@ -416,7 +416,7 @@ func TestCreateProfilesReceiver(t *testing.T) { creationSet := receivertest.NewNopSettings() for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - tr, err := factory.(receiverprofiles.Factory).CreateProfilesReceiver(ctx, creationSet, tt.cfg, tt.sink) + tr, err := factory.(receiverprofiles.Factory).CreateProfiles(ctx, creationSet, tt.cfg, tt.sink) if tt.wantErr { assert.Error(t, err) return diff --git a/receiver/otlpreceiver/generated_component_test.go b/receiver/otlpreceiver/generated_component_test.go index 2e1ed747ee8..bd2395ffd39 100644 --- a/receiver/otlpreceiver/generated_component_test.go +++ b/receiver/otlpreceiver/generated_component_test.go @@ -35,21 +35,21 @@ func TestComponentLifecycle(t *testing.T) { { name: "logs", createFn: func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateLogsReceiver(ctx, set, cfg, consumertest.NewNop()) + return factory.CreateLogs(ctx, set, cfg, consumertest.NewNop()) }, }, { name: "metrics", createFn: func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) + return factory.CreateMetrics(ctx, set, cfg, consumertest.NewNop()) }, }, { name: "traces", createFn: func(ctx context.Context, set receiver.Settings, cfg component.Config) (component.Component, error) { - return factory.CreateTracesReceiver(ctx, set, cfg, consumertest.NewNop()) + return factory.CreateTraces(ctx, set, cfg, consumertest.NewNop()) }, }, } diff --git a/receiver/otlpreceiver/otlp_test.go b/receiver/otlpreceiver/otlp_test.go index 31b045771ca..1f174319767 100644 --- a/receiver/otlpreceiver/otlp_test.go +++ b/receiver/otlpreceiver/otlp_test.go @@ -700,7 +700,7 @@ func TestGRPCInvalidTLSCredentials(t *testing.T) { }, } - r, err := NewFactory().CreateTracesReceiver( + r, err := NewFactory().CreateTraces( context.Background(), receivertest.NewNopSettings(), cfg, @@ -769,7 +769,7 @@ func TestHTTPInvalidTLSCredentials(t *testing.T) { } // TLS is resolved during Start for HTTP. - r, err := NewFactory().CreateTracesReceiver( + r, err := NewFactory().CreateTraces( context.Background(), receivertest.NewNopSettings(), cfg, @@ -1016,7 +1016,7 @@ func TestShutdown(t *testing.T) { cfg.HTTP.Endpoint = endpointHTTP set := receivertest.NewNopSettings() set.ID = otlpReceiverID - r, err := NewFactory().CreateTracesReceiver( + r, err := NewFactory().CreateTraces( context.Background(), set, cfg, diff --git a/receiver/receiver.go b/receiver/receiver.go index 010a87735d3..786071a352d 100644 --- a/receiver/receiver.go +++ b/receiver/receiver.go @@ -14,7 +14,7 @@ import ( // Traces receiver receives traces. // Its purpose is to translate data from any format to the collector's internal trace format. -// TracesReceiver feeds a consumer.Traces with data. +// Traces receiver feeds a consumer.Traces with data. // // For example, it could be Zipkin data source which translates Zipkin spans into ptrace.Traces. type Traces interface { @@ -23,7 +23,7 @@ type Traces interface { // Metrics receiver receives metrics. // Its purpose is to translate data from any format to the collector's internal metrics format. -// MetricsReceiver feeds a consumer.Metrics with data. +// Metrics receiver feeds a consumer.Metrics with data. // // For example, it could be Prometheus data source which translates Prometheus metrics into pmetric.Metrics. type Metrics interface { @@ -32,7 +32,7 @@ type Metrics interface { // Logs receiver receives logs. // Its purpose is to translate data from any format to the collector's internal logs data format. -// LogsReceiver feeds a consumer.Logs with data. +// Logs receiver feeds a consumer.Logs with data. // // For example, it could be a receiver that reads syslogs and convert them into plog.Logs. type Logs interface { @@ -57,37 +57,55 @@ type Settings struct { type Factory interface { component.Factory - // CreateTracesReceiver creates a TracesReceiver based on this config. + // CreateTraces creates a Traces based on this config. // If the receiver type does not support traces, // this function returns the error [pipeline.ErrSignalNotSupported]. - // Implementers can assume `nextConsumer` is never nil. - CreateTracesReceiver(ctx context.Context, set Settings, cfg component.Config, nextConsumer consumer.Traces) (Traces, error) + // Implementers can assume `next` is never nil. + CreateTraces(ctx context.Context, set Settings, cfg component.Config, next consumer.Traces) (Traces, error) - // TracesReceiverStability gets the stability level of the TracesReceiver. + // Deprecated: [v0.111.0] Use CreateTraces. + CreateTracesReceiver(ctx context.Context, set Settings, cfg component.Config, next consumer.Traces) (Traces, error) + + // TracesStability gets the stability level of the TracesReceiver. + TracesStability() component.StabilityLevel + + // Deprecated: [v0.111.0] Use TracesStability. TracesReceiverStability() component.StabilityLevel - // CreateMetricsReceiver creates a MetricsReceiver based on this config. + // CreateMetrics creates a Metrics based on this config. // If the receiver type does not support metrics, // this function returns the error [pipeline.ErrSignalNotSupported]. - // Implementers can assume `nextConsumer` is never nil. - CreateMetricsReceiver(ctx context.Context, set Settings, cfg component.Config, nextConsumer consumer.Metrics) (Metrics, error) + // Implementers can assume `next` is never nil. + CreateMetrics(ctx context.Context, set Settings, cfg component.Config, next consumer.Metrics) (Metrics, error) + + // Deprecated: [v0.111.0] Use CreateMetrics. + CreateMetricsReceiver(ctx context.Context, set Settings, cfg component.Config, next consumer.Metrics) (Metrics, error) - // MetricsReceiverStability gets the stability level of the MetricsReceiver. + // MetricsStability gets the stability level of the MetricsReceiver. + MetricsStability() component.StabilityLevel + + // Deprecated: [v0.111.0] Use MetricsStability. MetricsReceiverStability() component.StabilityLevel - // CreateLogsReceiver creates a LogsReceiver based on this config. + // CreateLogs creates a Logs based on this config. // If the receiver type does not support logs, // this function returns the error [pipeline.ErrSignalNotSupported]. - // Implementers can assume `nextConsumer` is never nil. - CreateLogsReceiver(ctx context.Context, set Settings, cfg component.Config, nextConsumer consumer.Logs) (Logs, error) + // Implementers can assume `next` is never nil. + CreateLogs(ctx context.Context, set Settings, cfg component.Config, next consumer.Logs) (Logs, error) + + // Deprecated: [v0.111.0] Use CreateLogs. + CreateLogsReceiver(ctx context.Context, set Settings, cfg component.Config, next consumer.Logs) (Logs, error) + + // LogsStability gets the stability level of the LogsReceiver. + LogsStability() component.StabilityLevel - // LogsReceiverStability gets the stability level of the LogsReceiver. + // Deprecated: [v0.111.0] Use LogsStability. LogsReceiverStability() component.StabilityLevel unexportedFactoryFunc() } -// FactoryOption apply changes to ReceiverOptions. +// FactoryOption apply changes to Factory. type FactoryOption interface { // applyOption applies the option. applyOption(o *factory) @@ -103,48 +121,49 @@ func (f factoryOptionFunc) applyOption(o *factory) { // CreateTracesFunc is the equivalent of Factory.CreateTraces. type CreateTracesFunc func(context.Context, Settings, component.Config, consumer.Traces) (Traces, error) -// CreateTracesReceiver implements Factory.CreateTracesReceiver(). -func (f CreateTracesFunc) CreateTracesReceiver( - ctx context.Context, - set Settings, - cfg component.Config, - nextConsumer consumer.Traces) (Traces, error) { +// CreateTraces implements Factory.CreateTraces(). +func (f CreateTracesFunc) CreateTraces(ctx context.Context, set Settings, cfg component.Config, next consumer.Traces) (Traces, error) { if f == nil { return nil, pipeline.ErrSignalNotSupported } - return f(ctx, set, cfg, nextConsumer) + return f(ctx, set, cfg, next) +} + +// Deprecated: [v0.111.0] Use CreateTraces. +func (f CreateTracesFunc) CreateTracesReceiver(ctx context.Context, set Settings, cfg component.Config, next consumer.Traces) (Traces, error) { + return f.CreateTraces(ctx, set, cfg, next) } // CreateMetricsFunc is the equivalent of Factory.CreateMetrics. type CreateMetricsFunc func(context.Context, Settings, component.Config, consumer.Metrics) (Metrics, error) -// CreateMetricsReceiver implements Factory.CreateMetricsReceiver(). -func (f CreateMetricsFunc) CreateMetricsReceiver( - ctx context.Context, - set Settings, - cfg component.Config, - nextConsumer consumer.Metrics, -) (Metrics, error) { +// CreateMetrics implements Factory.CreateMetrics. +func (f CreateMetricsFunc) CreateMetrics(ctx context.Context, set Settings, cfg component.Config, next consumer.Metrics) (Metrics, error) { if f == nil { return nil, pipeline.ErrSignalNotSupported } - return f(ctx, set, cfg, nextConsumer) + return f(ctx, set, cfg, next) +} + +// Deprecated: [v0.111.0] Use CreateMetrics. +func (f CreateMetricsFunc) CreateMetricsReceiver(ctx context.Context, set Settings, cfg component.Config, next consumer.Metrics) (Metrics, error) { + return f.CreateMetrics(ctx, set, cfg, next) } -// CreateLogsFunc is the equivalent of ReceiverFactory.CreateLogsReceiver(). +// CreateLogsFunc is the equivalent of Factory.CreateLogs. type CreateLogsFunc func(context.Context, Settings, component.Config, consumer.Logs) (Logs, error) -// CreateLogsReceiver implements Factory.CreateLogsReceiver(). -func (f CreateLogsFunc) CreateLogsReceiver( - ctx context.Context, - set Settings, - cfg component.Config, - nextConsumer consumer.Logs, -) (Logs, error) { +// CreateLogs implements Factory.CreateLogs. +func (f CreateLogsFunc) CreateLogs(ctx context.Context, set Settings, cfg component.Config, next consumer.Logs) (Logs, error) { if f == nil { return nil, pipeline.ErrSignalNotSupported } - return f(ctx, set, cfg, nextConsumer) + return f(ctx, set, cfg, next) +} + +// Deprecated: [v0.111.0] Use CreateLogs. +func (f CreateLogsFunc) CreateLogsReceiver(ctx context.Context, set Settings, cfg component.Config, next consumer.Logs) (Logs, error) { + return f.CreateLogs(ctx, set, cfg, next) } type factory struct { @@ -164,39 +183,54 @@ func (f *factory) Type() component.Type { func (f *factory) unexportedFactoryFunc() {} -func (f *factory) TracesReceiverStability() component.StabilityLevel { +func (f *factory) TracesStability() component.StabilityLevel { return f.tracesStabilityLevel } -func (f *factory) MetricsReceiverStability() component.StabilityLevel { +func (f *factory) MetricsStability() component.StabilityLevel { return f.metricsStabilityLevel } -func (f *factory) LogsReceiverStability() component.StabilityLevel { +func (f *factory) LogsStability() component.StabilityLevel { return f.logsStabilityLevel } -// WithTraces overrides the default "error not supported" implementation for CreateTracesReceiver and the default "undefined" stability level. -func WithTraces(createTracesReceiver CreateTracesFunc, sl component.StabilityLevel) FactoryOption { +// Deprecated: [v0.111.0] use TracesStability. +func (f *factory) TracesReceiverStability() component.StabilityLevel { + return f.TracesStability() +} + +// Deprecated: [v0.111.0] use MetricsStability. +func (f *factory) MetricsReceiverStability() component.StabilityLevel { + return f.MetricsStability() +} + +// Deprecated: [v0.111.0] use LogsStability. +func (f *factory) LogsReceiverStability() component.StabilityLevel { + return f.LogsStability() +} + +// WithTraces overrides the default "error not supported" implementation for Factory.CreateTraces and the default "undefined" stability level. +func WithTraces(createTraces CreateTracesFunc, sl component.StabilityLevel) FactoryOption { return factoryOptionFunc(func(o *factory) { o.tracesStabilityLevel = sl - o.CreateTracesFunc = createTracesReceiver + o.CreateTracesFunc = createTraces }) } -// WithMetrics overrides the default "error not supported" implementation for CreateMetricsReceiver and the default "undefined" stability level. -func WithMetrics(createMetricsReceiver CreateMetricsFunc, sl component.StabilityLevel) FactoryOption { +// WithMetrics overrides the default "error not supported" implementation for Factory.CreateMetrics and the default "undefined" stability level. +func WithMetrics(createMetrics CreateMetricsFunc, sl component.StabilityLevel) FactoryOption { return factoryOptionFunc(func(o *factory) { o.metricsStabilityLevel = sl - o.CreateMetricsFunc = createMetricsReceiver + o.CreateMetricsFunc = createMetrics }) } -// WithLogs overrides the default "error not supported" implementation for CreateLogsReceiver and the default "undefined" stability level. -func WithLogs(createLogsReceiver CreateLogsFunc, sl component.StabilityLevel) FactoryOption { +// WithLogs overrides the default "error not supported" implementation for Factory.CreateLogs and the default "undefined" stability level. +func WithLogs(createLogs CreateLogsFunc, sl component.StabilityLevel) FactoryOption { return factoryOptionFunc(func(o *factory) { o.logsStabilityLevel = sl - o.CreateLogsFunc = createLogsReceiver + o.CreateLogsFunc = createLogs }) } diff --git a/receiver/receiver_test.go b/receiver/receiver_test.go index 6eeadc50dca..772cc1cc387 100644 --- a/receiver/receiver_test.go +++ b/receiver/receiver_test.go @@ -23,11 +23,11 @@ func TestNewFactory(t *testing.T) { func() component.Config { return &defaultCfg }) assert.EqualValues(t, testType, factory.Type()) assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) - _, err := factory.CreateTracesReceiver(context.Background(), Settings{}, &defaultCfg, consumertest.NewNop()) + _, err := factory.CreateTraces(context.Background(), Settings{}, &defaultCfg, consumertest.NewNop()) require.Error(t, err) - _, err = factory.CreateMetricsReceiver(context.Background(), Settings{}, &defaultCfg, consumertest.NewNop()) + _, err = factory.CreateMetrics(context.Background(), Settings{}, &defaultCfg, consumertest.NewNop()) require.Error(t, err) - _, err = factory.CreateLogsReceiver(context.Background(), Settings{}, &defaultCfg, consumertest.NewNop()) + _, err = factory.CreateLogs(context.Background(), Settings{}, &defaultCfg, consumertest.NewNop()) assert.Error(t, err) } @@ -43,16 +43,16 @@ func TestNewFactoryWithOptions(t *testing.T) { assert.EqualValues(t, testType, factory.Type()) assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) - assert.Equal(t, component.StabilityLevelDeprecated, factory.TracesReceiverStability()) - _, err := factory.CreateTracesReceiver(context.Background(), Settings{}, &defaultCfg, nil) + assert.Equal(t, component.StabilityLevelDeprecated, factory.TracesStability()) + _, err := factory.CreateTraces(context.Background(), Settings{}, &defaultCfg, nil) require.NoError(t, err) - assert.Equal(t, component.StabilityLevelAlpha, factory.MetricsReceiverStability()) - _, err = factory.CreateMetricsReceiver(context.Background(), Settings{}, &defaultCfg, nil) + assert.Equal(t, component.StabilityLevelAlpha, factory.MetricsStability()) + _, err = factory.CreateMetrics(context.Background(), Settings{}, &defaultCfg, nil) require.NoError(t, err) - assert.Equal(t, component.StabilityLevelStable, factory.LogsReceiverStability()) - _, err = factory.CreateLogsReceiver(context.Background(), Settings{}, &defaultCfg, nil) + assert.Equal(t, component.StabilityLevelStable, factory.LogsStability()) + _, err = factory.CreateLogs(context.Background(), Settings{}, &defaultCfg, nil) assert.NoError(t, err) } diff --git a/receiver/receiverprofiles/profiles.go b/receiver/receiverprofiles/profiles.go index d3c560bb398..dea184810a9 100644 --- a/receiver/receiverprofiles/profiles.go +++ b/receiver/receiverprofiles/profiles.go @@ -28,28 +28,35 @@ type Profiles interface { type Factory interface { receiver.Factory - // CreateProfilesReceiver creates a ProfilesReceiver based on this config. + // CreateProfiles creates a Profiles based on this config. // If the receiver type does not support tracing or if the config is not valid - // an error will be returned instead. `nextConsumer` is never nil. - CreateProfilesReceiver(ctx context.Context, set receiver.Settings, cfg component.Config, nextConsumer consumerprofiles.Profiles) (Profiles, error) + // an error will be returned instead. `next` is never nil. + CreateProfiles(ctx context.Context, set receiver.Settings, cfg component.Config, next consumerprofiles.Profiles) (Profiles, error) - // ProfilesReceiverStability gets the stability level of the ProfilesReceiver. + // Deprecated: [v0.111.0] use CreateProfiles. + CreateProfilesReceiver(ctx context.Context, set receiver.Settings, cfg component.Config, next consumerprofiles.Profiles) (Profiles, error) + + // ProfilesStability gets the stability level of the ProfilesReceiver. + ProfilesStability() component.StabilityLevel + + // Deprecated: [v0.111.0] use ProfilesStability. ProfilesReceiverStability() component.StabilityLevel } // CreateProfilesFunc is the equivalent of Factory.CreateProfiles. type CreateProfilesFunc func(context.Context, receiver.Settings, component.Config, consumerprofiles.Profiles) (Profiles, error) -// CreateProfilesReceiver implements Factory.CreateProfilesReceiver(). -func (f CreateProfilesFunc) CreateProfilesReceiver( - ctx context.Context, - set receiver.Settings, - cfg component.Config, - nextConsumer consumerprofiles.Profiles) (Profiles, error) { +// CreateProfiles implements Factory.CreateProfiles. +func (f CreateProfilesFunc) CreateProfiles(ctx context.Context, set receiver.Settings, cfg component.Config, next consumerprofiles.Profiles) (Profiles, error) { if f == nil { return nil, pipeline.ErrSignalNotSupported } - return f(ctx, set, cfg, nextConsumer) + return f(ctx, set, cfg, next) +} + +// Deprecated: [v0.111.0] use CreateProfiles. +func (f CreateProfilesFunc) CreateProfilesReceiver(ctx context.Context, set receiver.Settings, cfg component.Config, next consumerprofiles.Profiles) (Profiles, error) { + return f.CreateProfiles(ctx, set, cfg, next) } // FactoryOption apply changes to ReceiverOptions. @@ -71,10 +78,15 @@ type factory struct { profilesStabilityLevel component.StabilityLevel } -func (f *factory) ProfilesReceiverStability() component.StabilityLevel { +func (f *factory) ProfilesStability() component.StabilityLevel { return f.profilesStabilityLevel } +// Deprecated: [v0.111.0] use ProfilesStability. +func (f *factory) ProfilesReceiverStability() component.StabilityLevel { + return f.ProfilesStability() +} + type factoryOpts struct { cfgType component.Type component.CreateDefaultConfigFunc @@ -83,32 +95,32 @@ type factoryOpts struct { profilesStabilityLevel component.StabilityLevel } -// WithTraces overrides the default "error not supported" implementation for CreateTracesReceiver and the default "undefined" stability level. -func WithTraces(createTracesReceiver receiver.CreateTracesFunc, sl component.StabilityLevel) FactoryOption { +// WithTraces overrides the default "error not supported" implementation for Factory.CreateTraces and the default "undefined" stability level. +func WithTraces(createTraces receiver.CreateTracesFunc, sl component.StabilityLevel) FactoryOption { return factoryOptionFunc(func(o *factoryOpts) { - o.opts = append(o.opts, receiver.WithTraces(createTracesReceiver, sl)) + o.opts = append(o.opts, receiver.WithTraces(createTraces, sl)) }) } -// WithMetrics overrides the default "error not supported" implementation for CreateMetricsReceiver and the default "undefined" stability level. -func WithMetrics(createMetricsReceiver receiver.CreateMetricsFunc, sl component.StabilityLevel) FactoryOption { +// WithMetrics overrides the default "error not supported" implementation for Factory.CreateMetrics and the default "undefined" stability level. +func WithMetrics(createMetrics receiver.CreateMetricsFunc, sl component.StabilityLevel) FactoryOption { return factoryOptionFunc(func(o *factoryOpts) { - o.opts = append(o.opts, receiver.WithMetrics(createMetricsReceiver, sl)) + o.opts = append(o.opts, receiver.WithMetrics(createMetrics, sl)) }) } -// WithLogs overrides the default "error not supported" implementation for CreateLogsReceiver and the default "undefined" stability level. -func WithLogs(createLogsReceiver receiver.CreateLogsFunc, sl component.StabilityLevel) FactoryOption { +// WithLogs overrides the default "error not supported" implementation for Factory.CreateLogs and the default "undefined" stability level. +func WithLogs(createLogs receiver.CreateLogsFunc, sl component.StabilityLevel) FactoryOption { return factoryOptionFunc(func(o *factoryOpts) { - o.opts = append(o.opts, receiver.WithLogs(createLogsReceiver, sl)) + o.opts = append(o.opts, receiver.WithLogs(createLogs, sl)) }) } -// WithProfiles overrides the default "error not supported" implementation for CreateProfilesReceiver and the default "undefined" stability level. -func WithProfiles(createProfilesReceiver CreateProfilesFunc, sl component.StabilityLevel) FactoryOption { +// WithProfiles overrides the default "error not supported" implementation for Factory.CreateProfiles and the default "undefined" stability level. +func WithProfiles(createProfiles CreateProfilesFunc, sl component.StabilityLevel) FactoryOption { return factoryOptionFunc(func(o *factoryOpts) { o.profilesStabilityLevel = sl - o.CreateProfilesFunc = createProfilesReceiver + o.CreateProfilesFunc = createProfiles }) } diff --git a/receiver/receiverprofiles/receiver_test.go b/receiver/receiverprofiles/receiver_test.go index eb094576756..7f30fb4a05f 100644 --- a/receiver/receiverprofiles/receiver_test.go +++ b/receiver/receiverprofiles/receiver_test.go @@ -26,8 +26,8 @@ func TestNewFactoryWithProfiles(t *testing.T) { assert.EqualValues(t, testType, factory.Type()) assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) - assert.Equal(t, component.StabilityLevelAlpha, factory.ProfilesReceiverStability()) - _, err := factory.CreateProfilesReceiver(context.Background(), receiver.Settings{}, &defaultCfg, nil) + assert.Equal(t, component.StabilityLevelAlpha, factory.ProfilesStability()) + _, err := factory.CreateProfiles(context.Background(), receiver.Settings{}, &defaultCfg, nil) assert.NoError(t, err) } diff --git a/receiver/receivertest/contract_checker.go b/receiver/receivertest/contract_checker.go index 7e24b507f48..9568071fcd3 100644 --- a/receiver/receivertest/contract_checker.go +++ b/receiver/receivertest/contract_checker.go @@ -134,11 +134,11 @@ func checkConsumeContractScenario(params CheckConsumeContractParams, decisionFun switch s { case pipeline.SignalLogs: - receiver, err = params.Factory.CreateLogsReceiver(ctx, NewNopSettings(), params.Config, consumer) + receiver, err = params.Factory.CreateLogs(ctx, NewNopSettings(), params.Config, consumer) case pipeline.SignalTraces: - receiver, err = params.Factory.CreateTracesReceiver(ctx, NewNopSettings(), params.Config, consumer) + receiver, err = params.Factory.CreateTraces(ctx, NewNopSettings(), params.Config, consumer) case pipeline.SignalMetrics: - receiver, err = params.Factory.CreateMetricsReceiver(ctx, NewNopSettings(), params.Config, consumer) + receiver, err = params.Factory.CreateMetrics(ctx, NewNopSettings(), params.Config, consumer) default: require.FailNow(params.T, "must specify a valid DataType to test for") } diff --git a/receiver/receivertest/nop_receiver_test.go b/receiver/receivertest/nop_receiver_test.go index 51943f92d06..09cff5a6697 100644 --- a/receiver/receivertest/nop_receiver_test.go +++ b/receiver/receivertest/nop_receiver_test.go @@ -25,22 +25,22 @@ func TestNewNopFactory(t *testing.T) { cfg := factory.CreateDefaultConfig() assert.Equal(t, &nopConfig{}, cfg) - traces, err := factory.CreateTracesReceiver(context.Background(), NewNopSettings(), cfg, consumertest.NewNop()) + traces, err := factory.CreateTraces(context.Background(), NewNopSettings(), cfg, consumertest.NewNop()) require.NoError(t, err) assert.NoError(t, traces.Start(context.Background(), componenttest.NewNopHost())) assert.NoError(t, traces.Shutdown(context.Background())) - metrics, err := factory.CreateMetricsReceiver(context.Background(), NewNopSettings(), cfg, consumertest.NewNop()) + metrics, err := factory.CreateMetrics(context.Background(), NewNopSettings(), cfg, consumertest.NewNop()) require.NoError(t, err) assert.NoError(t, metrics.Start(context.Background(), componenttest.NewNopHost())) assert.NoError(t, metrics.Shutdown(context.Background())) - logs, err := factory.CreateLogsReceiver(context.Background(), NewNopSettings(), cfg, consumertest.NewNop()) + logs, err := factory.CreateLogs(context.Background(), NewNopSettings(), cfg, consumertest.NewNop()) require.NoError(t, err) assert.NoError(t, logs.Start(context.Background(), componenttest.NewNopHost())) assert.NoError(t, logs.Shutdown(context.Background())) - profiles, err := factory.(receiverprofiles.Factory).CreateProfilesReceiver(context.Background(), NewNopSettings(), cfg, consumertest.NewNop()) + profiles, err := factory.(receiverprofiles.Factory).CreateProfiles(context.Background(), NewNopSettings(), cfg, consumertest.NewNop()) require.NoError(t, err) assert.NoError(t, profiles.Start(context.Background(), componenttest.NewNopHost())) assert.NoError(t, profiles.Shutdown(context.Background())) diff --git a/service/internal/builders/receiver.go b/service/internal/builders/receiver.go index 5831993d4bb..ceb78b8ef3a 100644 --- a/service/internal/builders/receiver.go +++ b/service/internal/builders/receiver.go @@ -44,8 +44,8 @@ func (b *ReceiverBuilder) CreateTraces(ctx context.Context, set receiver.Setting return nil, fmt.Errorf("receiver factory not available for: %q", set.ID) } - logStabilityLevel(set.Logger, f.TracesReceiverStability()) - return f.CreateTracesReceiver(ctx, set, cfg, next) + logStabilityLevel(set.Logger, f.TracesStability()) + return f.CreateTraces(ctx, set, cfg, next) } // CreateMetrics creates a Metrics receiver based on the settings and config. @@ -63,8 +63,8 @@ func (b *ReceiverBuilder) CreateMetrics(ctx context.Context, set receiver.Settin return nil, fmt.Errorf("receiver factory not available for: %q", set.ID) } - logStabilityLevel(set.Logger, f.MetricsReceiverStability()) - return f.CreateMetricsReceiver(ctx, set, cfg, next) + logStabilityLevel(set.Logger, f.MetricsStability()) + return f.CreateMetrics(ctx, set, cfg, next) } // CreateLogs creates a Logs receiver based on the settings and config. @@ -82,8 +82,8 @@ func (b *ReceiverBuilder) CreateLogs(ctx context.Context, set receiver.Settings, return nil, fmt.Errorf("receiver factory not available for: %q", set.ID) } - logStabilityLevel(set.Logger, f.LogsReceiverStability()) - return f.CreateLogsReceiver(ctx, set, cfg, next) + logStabilityLevel(set.Logger, f.LogsStability()) + return f.CreateLogs(ctx, set, cfg, next) } // CreateProfiles creates a Profiles receiver based on the settings and config. @@ -106,8 +106,8 @@ func (b *ReceiverBuilder) CreateProfiles(ctx context.Context, set receiver.Setti return nil, pipeline.ErrSignalNotSupported } - logStabilityLevel(set.Logger, f.ProfilesReceiverStability()) - return f.CreateProfilesReceiver(ctx, set, cfg, next) + logStabilityLevel(set.Logger, f.ProfilesStability()) + return f.CreateProfiles(ctx, set, cfg, next) } func (b *ReceiverBuilder) Factory(componentType component.Type) component.Factory { diff --git a/service/internal/builders/receiver_test.go b/service/internal/builders/receiver_test.go index 2bce4185187..561aca4eb3a 100644 --- a/service/internal/builders/receiver_test.go +++ b/service/internal/builders/receiver_test.go @@ -189,25 +189,25 @@ func TestNewNopReceiverConfigsAndFactories(t *testing.T) { set := receivertest.NewNopSettings() set.ID = component.NewID(nopType) - traces, err := factory.CreateTracesReceiver(context.Background(), set, cfg, consumertest.NewNop()) + traces, err := factory.CreateTraces(context.Background(), set, cfg, consumertest.NewNop()) require.NoError(t, err) bTraces, err := builder.CreateTraces(context.Background(), set, consumertest.NewNop()) require.NoError(t, err) assert.IsType(t, traces, bTraces) - metrics, err := factory.CreateMetricsReceiver(context.Background(), set, cfg, consumertest.NewNop()) + metrics, err := factory.CreateMetrics(context.Background(), set, cfg, consumertest.NewNop()) require.NoError(t, err) bMetrics, err := builder.CreateMetrics(context.Background(), set, consumertest.NewNop()) require.NoError(t, err) assert.IsType(t, metrics, bMetrics) - logs, err := factory.CreateLogsReceiver(context.Background(), set, cfg, consumertest.NewNop()) + logs, err := factory.CreateLogs(context.Background(), set, cfg, consumertest.NewNop()) require.NoError(t, err) bLogs, err := builder.CreateLogs(context.Background(), set, consumertest.NewNop()) require.NoError(t, err) assert.IsType(t, logs, bLogs) - profiles, err := factory.(receiverprofiles.Factory).CreateProfilesReceiver(context.Background(), set, cfg, consumertest.NewNop()) + profiles, err := factory.(receiverprofiles.Factory).CreateProfiles(context.Background(), set, cfg, consumertest.NewNop()) require.NoError(t, err) bProfiles, err := builder.CreateProfiles(context.Background(), set, consumertest.NewNop()) require.NoError(t, err) diff --git a/service/internal/testcomponents/example_receiver.go b/service/internal/testcomponents/example_receiver.go index 698df6cc208..2b2af303328 100644 --- a/service/internal/testcomponents/example_receiver.go +++ b/service/internal/testcomponents/example_receiver.go @@ -19,18 +19,18 @@ var receiverType = component.MustNewType("examplereceiver") var ExampleReceiverFactory = receiverprofiles.NewFactory( receiverType, createReceiverDefaultConfig, - receiverprofiles.WithTraces(createTracesReceiver, component.StabilityLevelDevelopment), - receiverprofiles.WithMetrics(createMetricsReceiver, component.StabilityLevelDevelopment), - receiverprofiles.WithLogs(createLogsReceiver, component.StabilityLevelDevelopment), - receiverprofiles.WithProfiles(createProfilesReceiver, component.StabilityLevelDevelopment), + receiverprofiles.WithTraces(createTraces, component.StabilityLevelDevelopment), + receiverprofiles.WithMetrics(createMetrics, component.StabilityLevelDevelopment), + receiverprofiles.WithLogs(createLogs, component.StabilityLevelDevelopment), + receiverprofiles.WithProfiles(createProfiles, component.StabilityLevelDevelopment), ) func createReceiverDefaultConfig() component.Config { return &struct{}{} } -// createTracesReceiver creates a trace receiver based on this config. -func createTracesReceiver( +// createTraces creates a receiver.Traces based on this config. +func createTraces( _ context.Context, _ receiver.Settings, cfg component.Config, @@ -41,8 +41,8 @@ func createTracesReceiver( return tr, nil } -// createMetricsReceiver creates a metrics receiver based on this config. -func createMetricsReceiver( +// createMetrics creates a receiver.Metrics based on this config. +func createMetrics( _ context.Context, _ receiver.Settings, cfg component.Config, @@ -53,7 +53,8 @@ func createMetricsReceiver( return mr, nil } -func createLogsReceiver( +// createLogs creates a receiver.Logs based on this config. +func createLogs( _ context.Context, _ receiver.Settings, cfg component.Config, @@ -64,8 +65,8 @@ func createLogsReceiver( return lr, nil } -// createProfilesReceiver creates a trace receiver based on this config. -func createProfilesReceiver( +// createProfiles creates a receiver.Profiles based on this config. +func createProfiles( _ context.Context, _ receiver.Settings, cfg component.Config, @@ -101,7 +102,7 @@ type ExampleReceiver struct { } // This is the map of already created example receivers for particular configurations. -// We maintain this map because the ReceiverFactory is asked trace and metric receivers separately -// when it gets CreateTracesReceiver() and CreateMetricsReceiver() but they must not +// We maintain this map because the receiver.Factory is asked trace and metric receivers separately +// when it gets CreateTraces() and CreateMetrics() but they must not // create separate objects, they must use one Receiver object per configuration. var exampleReceivers = map[component.Config]*ExampleReceiver{}