From 77bb849aa07eb984ddd95b8ef06b411b704307c9 Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Mon, 23 Sep 2024 08:38:59 -0600 Subject: [PATCH] [component] Refactor to use pipeline.ID and pipeline.Signal (#11204) #### Description Depends on https://github.com/open-telemetry/opentelemetry-collector/pull/11209 This PR is a non-breaking implementation of https://github.com/open-telemetry/opentelemetry-collector/pull/10947. It adds a new module, `pipeline`, which houses a `pipeline.ID` and `pipeline.Signal`. `pipeline.ID` is used to identify a pipeline within the service. `pipeline.Signal` is uses to identify the signal associated to a pipeline. I do this work begrudgingly. As the PR shows, this is a huge refactor when done in a non-breaking way, will require 3 full releases, and doesn't benefit our [End Users or, in my opinion, our Component Developers or Collector Library Users](https://github.com/open-telemetry/opentelemetry-collector/blob/main/CONTRIBUTING.md#target-audiences). I view this refactor as a Nice-To-Have, not a requirement for Component 1.0. #### Link to tracking issue Works towards https://github.com/open-telemetry/opentelemetry-collector/issues/9429 --- .chloggen/component-refactor-datatype-2.yaml | 25 + .chloggen/component-refactor-datatype-3.yaml | 25 + .chloggen/component-refactor-datatype-4.yaml | 25 + .chloggen/component-refactor-datatype-5.yaml | 25 + .chloggen/component-refactor-datatype-6.yaml | 25 + .chloggen/component-refactor-datatype.yaml | 25 + cmd/builder/internal/builder/main_test.go | 2 + cmd/builder/test/core.builder.yaml | 2 + cmd/mdatagen/go.mod | 9 + .../internal/templates/component_test.go.tmpl | 19 +- cmd/otelcorecol/builder-config.yaml | 2 + cmd/otelcorecol/go.mod | 6 + component/component.go | 7 +- component/componentprofiles/config.go | 10 +- component/componentprofiles/go.mod | 10 +- component/componentstatus/go.mod | 6 + component/componentstatus/instance.go | 65 +- component/componentstatus/instance_test.go | 49 +- component/config.go | 8 + component/go.mod | 6 + config/configauth/go.mod | 6 + config/configgrpc/go.mod | 6 + config/confighttp/go.mod | 6 + connector/connector_test.go | 37 +- connector/connectorprofiles/connector_test.go | 21 +- connector/connectorprofiles/go.mod | 6 + .../connectorprofiles/profiles_router.go | 9 +- .../connectorprofiles/profiles_router_test.go | 24 +- .../generated_component_test.go | 7 +- connector/forwardconnector/go.mod | 6 + connector/go.mod | 6 + connector/internal/factory.go | 37 +- connector/internal/router.go | 14 +- connector/logs_router.go | 14 +- connector/logs_router_test.go | 24 +- connector/metrics_router.go | 8 +- connector/metrics_router_test.go | 24 +- connector/traces_router.go | 8 +- connector/traces_router_test.go | 24 +- exporter/debugexporter/go.mod | 9 + .../exporterhelper/internal/base_exporter.go | 11 +- .../internal/base_exporter_test.go | 15 +- .../internal/batch_sender_test.go | 26 +- .../exporterhelper/internal/obsexporter.go | 33 +- .../exporterhelper/internal/queue_sender.go | 2 +- .../internal/queue_sender_test.go | 23 +- .../internal/retry_sender_test.go | 18 +- exporter/exporterhelper/logs.go | 5 +- exporter/exporterhelper/metrics.go | 5 +- exporter/exporterhelper/obsreport_test.go | 7 +- exporter/exporterhelper/traces.go | 5 +- exporter/exporterprofiles/go.mod | 8 + exporter/exporterqueue/queue.go | 14 +- exporter/exportertest/contract_checker.go | 14 +- .../exportertest/contract_checker_test.go | 7 +- exporter/go.mod | 9 + exporter/internal/factory.go | 17 +- exporter/internal/queue/persistent_queue.go | 7 +- .../internal/queue/persistent_queue_test.go | 11 +- exporter/loggingexporter/go.mod | 9 + exporter/nopexporter/go.mod | 9 + exporter/otlpexporter/go.mod | 9 + exporter/otlphttpexporter/go.mod | 9 + extension/auth/go.mod | 6 + extension/experimental/storage/go.mod | 6 + extension/extensioncapabilities/go.mod | 6 + extension/go.mod | 6 + extension/memorylimiterextension/go.mod | 6 + extension/zpagesextension/go.mod | 6 + go.mod | 6 + internal/e2e/consume_contract_test.go | 7 +- internal/e2e/go.mod | 6 + internal/e2e/status_test.go | 9 +- internal/iruntime/total_memory_other_test.go | 3 +- otelcol/config.go | 37 + otelcol/config_test.go | 21 +- otelcol/factories_test.go | 3 +- otelcol/go.mod | 6 + otelcol/otelcoltest/config_test.go | 5 +- otelcol/otelcoltest/go.mod | 6 + otelcol/unmarshaler_test.go | 2 +- pipeline/signal.go | 4 + processor/batchprocessor/go.mod | 6 + processor/go.mod | 6 + processor/internal/factory.go | 15 +- processor/memorylimiterprocessor/go.mod | 6 + processor/processorhelper/obsreport.go | 29 +- processor/processorprofiles/go.mod | 6 + processor/processortest/shutdown_verifier.go | 7 +- receiver/go.mod | 9 + receiver/internal/factory.go | 15 +- receiver/nopreceiver/go.mod | 9 + receiver/otlpreceiver/go.mod | 9 + receiver/receiverhelper/obsreport.go | 29 +- receiver/receiverprofiles/go.mod | 8 + receiver/receivertest/contract_checker.go | 27 +- .../receivertest/contract_checker_test.go | 7 +- receiver/receivertest/nop_receiver.go | 22 +- receiver/scraperhelper/obsreport.go | 3 +- service/config.go | 22 +- service/config_test.go | 11 +- service/extensions/extensions.go | 2 +- service/go.mod | 6 + service/internal/builders/connector_test.go | 45 +- service/internal/components/loggers.go | 9 +- service/internal/graph/graph.go | 131 ++-- service/internal/graph/graph_test.go | 675 +++++++++--------- service/internal/graph/host.go | 28 +- service/internal/graph/nodes.go | 105 +-- service/internal/graph/zpages.go | 2 +- .../internal/testcomponents/example_router.go | 5 +- .../testcomponents/example_router_test.go | 26 +- service/pipelines/config.go | 35 +- service/pipelines/config_test.go | 29 +- service/service.go | 15 +- service/service_test.go | 26 +- 116 files changed, 1582 insertions(+), 874 deletions(-) create mode 100644 .chloggen/component-refactor-datatype-2.yaml create mode 100644 .chloggen/component-refactor-datatype-3.yaml create mode 100644 .chloggen/component-refactor-datatype-4.yaml create mode 100644 .chloggen/component-refactor-datatype-5.yaml create mode 100644 .chloggen/component-refactor-datatype-6.yaml create mode 100644 .chloggen/component-refactor-datatype.yaml diff --git a/.chloggen/component-refactor-datatype-2.yaml b/.chloggen/component-refactor-datatype-2.yaml new file mode 100644 index 00000000000..93b78fce19c --- /dev/null +++ b/.chloggen/component-refactor-datatype-2.yaml @@ -0,0 +1,25 @@ +# 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: componentprofiles + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Deprecates `DataTypeProfiles`. Use `SignalProfiles` instead. + +# One or more tracking issues or pull requests related to the change +issues: [11204] + +# (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: + +# 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/.chloggen/component-refactor-datatype-3.yaml b/.chloggen/component-refactor-datatype-3.yaml new file mode 100644 index 00000000000..1fed4a06eb4 --- /dev/null +++ b/.chloggen/component-refactor-datatype-3.yaml @@ -0,0 +1,25 @@ +# 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: componentstatus + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Deprecates `NewInstanceID`, `AllPipelineIDs`, and `WithPipelines`. Use `NewInstanceIDWithPipelineIDs`, `AllPipelineIDsWithPipelineIDs`, and `WithPipelineIDs` instead. + +# One or more tracking issues or pull requests related to the change +issues: [11204] + +# (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: + +# 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/.chloggen/component-refactor-datatype-4.yaml b/.chloggen/component-refactor-datatype-4.yaml new file mode 100644 index 00000000000..a8490ebcbb8 --- /dev/null +++ b/.chloggen/component-refactor-datatype-4.yaml @@ -0,0 +1,25 @@ +# 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: exporterqueue + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Deprecates `Settings.DataType`. Use `Settings.Signal` instead. + +# One or more tracking issues or pull requests related to the change +issues: [11204] + +# (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: + +# 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/.chloggen/component-refactor-datatype-5.yaml b/.chloggen/component-refactor-datatype-5.yaml new file mode 100644 index 00000000000..98b6418583e --- /dev/null +++ b/.chloggen/component-refactor-datatype-5.yaml @@ -0,0 +1,25 @@ +# 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: service + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Deprecates `pipelines.Config`. Use `pipelines.ConfigWithPipelineID` instead. + +# One or more tracking issues or pull requests related to the change +issues: [11204] + +# (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: + +# 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/.chloggen/component-refactor-datatype-6.yaml b/.chloggen/component-refactor-datatype-6.yaml new file mode 100644 index 00000000000..7839b8b18c3 --- /dev/null +++ b/.chloggen/component-refactor-datatype-6.yaml @@ -0,0 +1,25 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: connector + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Change `TracesRouterAndConsumer`, `NewTracesRouter`, `MetricsRouterAndConsumer`, `NewMetricsRouter`, `LogsRouterAndConsumer`, and `NewLogsRouter` to use `pipeline.ID` instead of `component.ID`. + +# One or more tracking issues or pull requests related to the change +issues: [11204] + +# (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: + +# 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/.chloggen/component-refactor-datatype.yaml b/.chloggen/component-refactor-datatype.yaml new file mode 100644 index 00000000000..c149c319cdc --- /dev/null +++ b/.chloggen/component-refactor-datatype.yaml @@ -0,0 +1,25 @@ +# 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: component + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Deprecates `DataType`, `DataTypeTraces`, `DataTypeMetrics`, and `DataTypeLogs`. Use `pipeline.Signal`, `SignalTraces`, `SignalMetrics`, and `SignalLogs` instead. + +# One or more tracking issues or pull requests related to the change +issues: [11204] + +# (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: + +# 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/builder/internal/builder/main_test.go b/cmd/builder/internal/builder/main_test.go index fe7bb1c09f8..85a2eaf6ec5 100644 --- a/cmd/builder/internal/builder/main_test.go +++ b/cmd/builder/internal/builder/main_test.go @@ -78,6 +78,8 @@ var ( "/extension/zpagesextension", "/featuregate", "/internal/globalgates", + "/internal/globalsignal", + "/pipeline", "/processor", "/processor/batchprocessor", "/processor/memorylimiterprocessor", diff --git a/cmd/builder/test/core.builder.yaml b/cmd/builder/test/core.builder.yaml index 866a625a91b..a3deebbeb61 100644 --- a/cmd/builder/test/core.builder.yaml +++ b/cmd/builder/test/core.builder.yaml @@ -49,11 +49,13 @@ replaces: - go.opentelemetry.io/collector/extension/zpagesextension => ${WORKSPACE_DIR}/extension/zpagesextension - go.opentelemetry.io/collector/featuregate => ${WORKSPACE_DIR}/featuregate - go.opentelemetry.io/collector/internal/globalgates => ${WORKSPACE_DIR}/internal/globalgates + - go.opentelemetry.io/collector/internal/globalsignal => ${WORKSPACE_DIR}/internal/globalsignal - go.opentelemetry.io/collector/otelcol => ${WORKSPACE_DIR}/otelcol - go.opentelemetry.io/collector/otelcol/otelcoltest => ${WORKSPACE_DIR}/otelcol/otelcoltest - go.opentelemetry.io/collector/pdata => ${WORKSPACE_DIR}/pdata - go.opentelemetry.io/collector/pdata/pprofile => ${WORKSPACE_DIR}/pdata/pprofile - go.opentelemetry.io/collector/pdata/testdata => ${WORKSPACE_DIR}/pdata/testdata + - go.opentelemetry.io/collector/pipeline => ${WORKSPACE_DIR}/pipeline - go.opentelemetry.io/collector/processor => ${WORKSPACE_DIR}/processor - go.opentelemetry.io/collector/processor/processorprofiles => ${WORKSPACE_DIR}/processor/processorprofiles - go.opentelemetry.io/collector/receiver => ${WORKSPACE_DIR}/receiver diff --git a/cmd/mdatagen/go.mod b/cmd/mdatagen/go.mod index 300b5c6a8d6..306fdcb2eff 100644 --- a/cmd/mdatagen/go.mod +++ b/cmd/mdatagen/go.mod @@ -42,8 +42,11 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/spf13/pflag v1.0.5 // indirect + go.opentelemetry.io/collector/component/componentprofiles v0.109.0 // indirect go.opentelemetry.io/collector/consumer/consumerprofiles v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.109.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/collector/receiver/receiverprofiles v0.109.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect go.opentelemetry.io/otel/sdk v1.30.0 // indirect @@ -89,3 +92,9 @@ replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consume replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest replace go.opentelemetry.io/collector/receiver/receiverprofiles => ../../receiver/receiverprofiles + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal + +replace go.opentelemetry.io/collector/component/componentprofiles => ../../component/componentprofiles diff --git a/cmd/mdatagen/internal/templates/component_test.go.tmpl b/cmd/mdatagen/internal/templates/component_test.go.tmpl index 734286ebff1..c40f3f39d07 100644 --- a/cmd/mdatagen/internal/templates/component_test.go.tmpl +++ b/cmd/mdatagen/internal/templates/component_test.go.tmpl @@ -44,6 +44,7 @@ import ( "go.opentelemetry.io/collector/connector/connectortest" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/pipeline" {{- end }} {{- if or isExporter isProcessor }} "go.opentelemetry.io/collector/pdata/pcommon" @@ -372,7 +373,7 @@ func TestComponentLifecycle(t *testing.T) { { name: "logs_to_logs", createFn: func(ctx context.Context, set connector.Settings, cfg component.Config) (component.Component, error) { - router := connector.NewLogsRouter(map[component.ID]consumer.Logs{component.NewID(component.DataTypeLogs): consumertest.NewNop()}) + router := connector.NewLogsRouter(map[pipeline.ID]consumer.Logs{pipeline.NewID(pipeline.SignalLogs): consumertest.NewNop()}) return factory.CreateLogsToLogs(ctx, set, cfg, router) }, }, @@ -381,7 +382,7 @@ func TestComponentLifecycle(t *testing.T) { { name: "logs_to_metrics", createFn: func(ctx context.Context, set connector.Settings, cfg component.Config) (component.Component, error) { - router := connector.NewMetricsRouter(map[component.ID]consumer.Metrics{component.NewID(component.DataTypeMetrics): consumertest.NewNop()}) + router := connector.NewMetricsRouter(map[pipeline.ID]consumer.Metrics{pipeline.NewID(pipeline.SignalMetrics): consumertest.NewNop()}) return factory.CreateLogsToMetrics(ctx, set, cfg, router) }, }, @@ -390,7 +391,7 @@ func TestComponentLifecycle(t *testing.T) { { name: "logs_to_traces", createFn: func(ctx context.Context, set connector.Settings, cfg component.Config) (component.Component, error) { - router := connector.NewTracesRouter(map[component.ID]consumer.Traces{component.NewID(component.DataTypeTraces): consumertest.NewNop()}) + router := connector.NewTracesRouter(map[pipeline.ID]consumer.Traces{pipeline.NewID(pipeline.SignalTraces): consumertest.NewNop()}) return factory.CreateLogsToTraces(ctx, set, cfg, router) }, }, @@ -399,7 +400,7 @@ func TestComponentLifecycle(t *testing.T) { { name: "metrics_to_logs", createFn: func(ctx context.Context, set connector.Settings, cfg component.Config) (component.Component, error) { - router := connector.NewLogsRouter(map[component.ID]consumer.Logs{component.NewID(component.DataTypeLogs): consumertest.NewNop()}) + router := connector.NewLogsRouter(map[pipeline.ID]consumer.Logs{pipeline.NewID(pipeline.SignalLogs): consumertest.NewNop()}) return factory.CreateMetricsToLogs(ctx, set, cfg, router) }, }, @@ -408,7 +409,7 @@ func TestComponentLifecycle(t *testing.T) { { name: "metrics_to_metrics", createFn: func(ctx context.Context, set connector.Settings, cfg component.Config) (component.Component, error) { - router := connector.NewMetricsRouter(map[component.ID]consumer.Metrics{component.NewID(component.DataTypeMetrics): consumertest.NewNop()}) + router := connector.NewMetricsRouter(map[pipeline.ID]consumer.Metrics{pipeline.NewID(pipeline.SignalMetrics): consumertest.NewNop()}) return factory.CreateMetricsToMetrics(ctx, set, cfg, router) }, }, @@ -417,7 +418,7 @@ func TestComponentLifecycle(t *testing.T) { { name: "metrics_to_traces", createFn: func(ctx context.Context, set connector.Settings, cfg component.Config) (component.Component, error) { - router := connector.NewTracesRouter(map[component.ID]consumer.Traces{component.NewID(component.DataTypeTraces): consumertest.NewNop()}) + router := connector.NewTracesRouter(map[pipeline.ID]consumer.Traces{pipeline.NewID(pipeline.SignalTraces): consumertest.NewNop()}) return factory.CreateMetricsToTraces(ctx, set, cfg, router) }, }, @@ -426,7 +427,7 @@ func TestComponentLifecycle(t *testing.T) { { name: "traces_to_logs", createFn: func(ctx context.Context, set connector.Settings, cfg component.Config) (component.Component, error) { - router := connector.NewLogsRouter(map[component.ID]consumer.Logs{component.NewID(component.DataTypeLogs): consumertest.NewNop()}) + router := connector.NewLogsRouter(map[pipeline.ID]consumer.Logs{pipeline.NewID(pipeline.SignalLogs): consumertest.NewNop()}) return factory.CreateTracesToLogs(ctx, set, cfg, router) }, }, @@ -435,7 +436,7 @@ func TestComponentLifecycle(t *testing.T) { { name: "traces_to_metrics", createFn: func(ctx context.Context, set connector.Settings, cfg component.Config) (component.Component, error) { - router := connector.NewMetricsRouter(map[component.ID]consumer.Metrics{component.NewID(component.DataTypeMetrics): consumertest.NewNop()}) + router := connector.NewMetricsRouter(map[pipeline.ID]consumer.Metrics{pipeline.NewID(pipeline.SignalMetrics): consumertest.NewNop()}) return factory.CreateTracesToMetrics(ctx, set, cfg, router) }, }, @@ -444,7 +445,7 @@ func TestComponentLifecycle(t *testing.T) { { name: "traces_to_traces", createFn: func(ctx context.Context, set connector.Settings, cfg component.Config) (component.Component, error) { - router := connector.NewTracesRouter(map[component.ID]consumer.Traces{component.NewID(component.DataTypeTraces): consumertest.NewNop()}) + router := connector.NewTracesRouter(map[pipeline.ID]consumer.Traces{pipeline.NewID(pipeline.SignalTraces): consumertest.NewNop()}) return factory.CreateTracesToTraces(ctx, set, cfg, router) }, }, diff --git a/cmd/otelcorecol/builder-config.yaml b/cmd/otelcorecol/builder-config.yaml index b5a726e374b..493a7ae0e25 100644 --- a/cmd/otelcorecol/builder-config.yaml +++ b/cmd/otelcorecol/builder-config.yaml @@ -41,6 +41,7 @@ providers: replaces: - go.opentelemetry.io/collector => ../../ - go.opentelemetry.io/collector/internal/globalgates => ../../internal/globalgates + - go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal - go.opentelemetry.io/collector/client => ../../client - go.opentelemetry.io/collector/otelcol => ../../otelcol - go.opentelemetry.io/collector/component => ../../component @@ -85,6 +86,7 @@ replaces: - go.opentelemetry.io/collector/pdata => ../../pdata - go.opentelemetry.io/collector/pdata/testdata => ../../pdata/testdata - go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile + - go.opentelemetry.io/collector/pipeline => ../../pipeline - go.opentelemetry.io/collector/processor => ../../processor - go.opentelemetry.io/collector/processor/batchprocessor => ../../processor/batchprocessor - go.opentelemetry.io/collector/processor/memorylimiterprocessor => ../../processor/memorylimiterprocessor diff --git a/cmd/otelcorecol/go.mod b/cmd/otelcorecol/go.mod index cc72b0ca351..71fb8ee9329 100644 --- a/cmd/otelcorecol/go.mod +++ b/cmd/otelcorecol/go.mod @@ -103,9 +103,11 @@ require ( go.opentelemetry.io/collector/extension/extensioncapabilities v0.109.0 // indirect go.opentelemetry.io/collector/featuregate v1.15.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata v1.15.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.109.0 // indirect go.opentelemetry.io/collector/pdata/testdata v0.109.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/collector/processor/processorprofiles v0.109.0 // indirect go.opentelemetry.io/collector/receiver/receiverprofiles v0.109.0 // indirect go.opentelemetry.io/collector/semconv v0.109.0 // indirect @@ -150,6 +152,8 @@ replace go.opentelemetry.io/collector => ../../ replace go.opentelemetry.io/collector/internal/globalgates => ../../internal/globalgates +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal + replace go.opentelemetry.io/collector/client => ../../client replace go.opentelemetry.io/collector/otelcol => ../../otelcol @@ -238,6 +242,8 @@ replace go.opentelemetry.io/collector/pdata/testdata => ../../pdata/testdata replace go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + replace go.opentelemetry.io/collector/processor => ../../processor replace go.opentelemetry.io/collector/processor/batchprocessor => ../../processor/batchprocessor diff --git a/component/component.go b/component/component.go index 2f2da6f098f..40267a416ab 100644 --- a/component/component.go +++ b/component/component.go @@ -7,13 +7,16 @@ package component // import "go.opentelemetry.io/collector/component" import ( "context" - "errors" + + "go.opentelemetry.io/collector/pipeline" ) var ( // ErrDataTypeIsNotSupported can be returned by receiver, exporter, processor or connector factory funcs that create the // Component if the particular telemetry data type is not supported by the receiver, exporter, processor or connector factory. - ErrDataTypeIsNotSupported = errors.New("telemetry type is not supported") + // + // Deprecated: [v0.110.0] Use pipeline.ErrSignalNotSupported instead + ErrDataTypeIsNotSupported = pipeline.ErrSignalNotSupported ) // Component is either a receiver, exporter, processor, connector, or an extension. diff --git a/component/componentprofiles/config.go b/component/componentprofiles/config.go index 85b4e90ca80..1a8152b1192 100644 --- a/component/componentprofiles/config.go +++ b/component/componentprofiles/config.go @@ -3,13 +3,21 @@ package componentprofiles // import "go.opentelemetry.io/collector/component/componentprofiles" -import "go.opentelemetry.io/collector/component" +import ( + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/internal/globalsignal" +) +// nolint func mustNewDataType(strType string) component.DataType { return component.MustNewType(strType) } var ( // DataTypeProfiles is the data type tag for profiles. + // + // Deprecated: [v0.110.0] Use SignalProfiles instead DataTypeProfiles = mustNewDataType("profiles") + + SignalProfiles = globalsignal.MustNewSignal("profiles") ) diff --git a/component/componentprofiles/go.mod b/component/componentprofiles/go.mod index a4ef0dde22b..27f11d5bb31 100644 --- a/component/componentprofiles/go.mod +++ b/component/componentprofiles/go.mod @@ -2,12 +2,16 @@ module go.opentelemetry.io/collector/component/componentprofiles go 1.22.0 -require go.opentelemetry.io/collector/component v0.109.0 +require ( + go.opentelemetry.io/collector/component v0.109.0 + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 +) require ( github.com/gogo/protobuf v1.3.2 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect go.opentelemetry.io/collector/pdata v1.15.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect go.opentelemetry.io/otel/metric v1.30.0 // indirect go.opentelemetry.io/otel/trace v1.30.0 // indirect @@ -26,3 +30,7 @@ replace go.opentelemetry.io/collector/pdata => ../../pdata replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry replace go.opentelemetry.io/collector/component => ../ + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline diff --git a/component/componentstatus/go.mod b/component/componentstatus/go.mod index b7e239d2831..de8857b3441 100644 --- a/component/componentstatus/go.mod +++ b/component/componentstatus/go.mod @@ -5,6 +5,7 @@ go 1.22.0 require ( github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.109.0 + go.opentelemetry.io/collector/pipeline v0.109.0 ) require ( @@ -12,6 +13,7 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata v1.15.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect go.opentelemetry.io/otel/metric v1.30.0 // indirect @@ -32,3 +34,7 @@ replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/con replace go.opentelemetry.io/collector/component => ../ replace go.opentelemetry.io/collector/pdata => ../../pdata + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal diff --git a/component/componentstatus/instance.go b/component/componentstatus/instance.go index 71668b6d351..96475510fef 100644 --- a/component/componentstatus/instance.go +++ b/component/componentstatus/instance.go @@ -9,6 +9,7 @@ import ( "strings" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/pipeline" ) // pipelineDelim is the delimiter for internal representation of pipeline @@ -26,7 +27,19 @@ type InstanceID struct { } // NewInstanceID returns an ID that uniquely identifies a component. +// +// Deprecated: [v0.110.0] Use NewInstanceIDWithPipelineID instead func NewInstanceID(componentID component.ID, kind component.Kind, pipelineIDs ...component.ID) *InstanceID { + instanceID := &InstanceID{ + componentID: componentID, + kind: kind, + } + instanceID.addPipelines(convertToPipelineIDs(pipelineIDs)) + return instanceID +} + +// NewInstanceIDWithPipelineIDs returns an InstanceID that uniquely identifies a component. +func NewInstanceIDWithPipelineIDs(componentID component.ID, kind component.Kind, pipelineIDs ...pipeline.ID) *InstanceID { instanceID := &InstanceID{ componentID: componentID, kind: kind, @@ -47,6 +60,8 @@ func (id *InstanceID) Kind() component.Kind { // AllPipelineIDs calls f for each pipeline this instance is associated with. If // f returns false it will stop iteration. +// +// Deprecated: [v0.110.0] Use AllPipelineIDsWithPipelineIDs instead. func (id *InstanceID) AllPipelineIDs(f func(component.ID) bool) { var bs []byte for _, b := range []byte(id.pipelineIDs) { @@ -66,9 +81,44 @@ func (id *InstanceID) AllPipelineIDs(f func(component.ID) bool) { } } +// AllPipelineIDsWithPipelineIDs calls f for each pipeline this instance is associated with. If +// f returns false it will stop iteration. +func (id *InstanceID) AllPipelineIDsWithPipelineIDs(f func(pipeline.ID) bool) { + var bs []byte + for _, b := range []byte(id.pipelineIDs) { + if b != pipelineDelim { + bs = append(bs, b) + continue + } + pipelineID := pipeline.ID{} + err := pipelineID.UnmarshalText(bs) + bs = bs[:0] + if err != nil { + continue + } + if !f(pipelineID) { + break + } + } +} + // WithPipelines returns a new InstanceID updated to include the given // pipelineIDs. +// +// Deprecated: [v0.110.0] Use WithPipelineIDs instead func (id *InstanceID) WithPipelines(pipelineIDs ...component.ID) *InstanceID { + instanceID := &InstanceID{ + componentID: id.componentID, + kind: id.kind, + pipelineIDs: id.pipelineIDs, + } + instanceID.addPipelines(convertToPipelineIDs(pipelineIDs)) + return instanceID +} + +// WithPipelineIDs returns a new InstanceID updated to include the given +// pipelineIDs. +func (id *InstanceID) WithPipelineIDs(pipelineIDs ...pipeline.ID) *InstanceID { instanceID := &InstanceID{ componentID: id.componentID, kind: id.kind, @@ -78,7 +128,7 @@ func (id *InstanceID) WithPipelines(pipelineIDs ...component.ID) *InstanceID { return instanceID } -func (id *InstanceID) addPipelines(pipelineIDs []component.ID) { +func (id *InstanceID) addPipelines(pipelineIDs []pipeline.ID) { delim := string(pipelineDelim) strIDs := strings.Split(id.pipelineIDs, delim) for _, pID := range pipelineIDs { @@ -88,3 +138,16 @@ func (id *InstanceID) addPipelines(pipelineIDs []component.ID) { strIDs = slices.Compact(strIDs) id.pipelineIDs = strings.Join(strIDs, delim) + delim } + +func convertToPipelineIDs(ids []component.ID) []pipeline.ID { + pipelineIDs := make([]pipeline.ID, len(ids)) + for i, id := range ids { + if id.Name() != "" { + pipelineIDs[i] = pipeline.MustNewIDWithName(id.Type().String(), id.Name()) + } else { + pipelineIDs[i] = pipeline.MustNewID(id.Type().String()) + } + + } + return pipelineIDs +} diff --git a/component/componentstatus/instance_test.go b/component/componentstatus/instance_test.go index 486607ae8dd..7c8b0d4691a 100644 --- a/component/componentstatus/instance_test.go +++ b/component/componentstatus/instance_test.go @@ -9,21 +9,22 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/pipeline" ) func TestInstanceID(t *testing.T) { traces := component.MustNewID("traces") - tracesA := component.MustNewIDWithName("traces", "a") - tracesB := component.MustNewIDWithName("traces", "b") - tracesC := component.MustNewIDWithName("traces", "c") + tracesA := pipeline.MustNewIDWithName("traces", "a") + tracesB := pipeline.MustNewIDWithName("traces", "b") + tracesC := pipeline.MustNewIDWithName("traces", "c") - idTracesA := NewInstanceID(traces, component.KindReceiver, tracesA) - idTracesAll := NewInstanceID(traces, component.KindReceiver, tracesA, tracesB, tracesC) + idTracesA := NewInstanceIDWithPipelineIDs(traces, component.KindReceiver, tracesA) + idTracesAll := NewInstanceIDWithPipelineIDs(traces, component.KindReceiver, tracesA, tracesB, tracesC) assert.NotEqual(t, idTracesA, idTracesAll) - assertHasPipelines := func(t *testing.T, instanceID *InstanceID, expectedPipelineIDs []component.ID) { - var pipelineIDs []component.ID - instanceID.AllPipelineIDs(func(id component.ID) bool { + assertHasPipelines := func(t *testing.T, instanceID *InstanceID, expectedPipelineIDs []pipeline.ID) { + var pipelineIDs []pipeline.ID + instanceID.AllPipelineIDsWithPipelineIDs(func(id pipeline.ID) bool { pipelineIDs = append(pipelineIDs, id) return true }) @@ -34,31 +35,31 @@ func TestInstanceID(t *testing.T) { name string id1 *InstanceID id2 *InstanceID - pipelineIDs []component.ID + pipelineIDs []pipeline.ID }{ { name: "equal instances", id1: idTracesA, - id2: NewInstanceID(traces, component.KindReceiver, tracesA), - pipelineIDs: []component.ID{tracesA}, + id2: NewInstanceIDWithPipelineIDs(traces, component.KindReceiver, tracesA), + pipelineIDs: []pipeline.ID{tracesA}, }, { name: "equal instances - out of order", id1: idTracesAll, - id2: NewInstanceID(traces, component.KindReceiver, tracesC, tracesB, tracesA), - pipelineIDs: []component.ID{tracesA, tracesB, tracesC}, + id2: NewInstanceIDWithPipelineIDs(traces, component.KindReceiver, tracesC, tracesB, tracesA), + pipelineIDs: []pipeline.ID{tracesA, tracesB, tracesC}, }, { name: "with pipelines", id1: idTracesAll, - id2: idTracesA.WithPipelines(tracesB, tracesC), - pipelineIDs: []component.ID{tracesA, tracesB, tracesC}, + id2: idTracesA.WithPipelineIDs(tracesB, tracesC), + pipelineIDs: []pipeline.ID{tracesA, tracesB, tracesC}, }, { name: "with pipelines - out of order", id1: idTracesAll, - id2: idTracesA.WithPipelines(tracesC, tracesB), - pipelineIDs: []component.ID{tracesA, tracesB, tracesC}, + id2: idTracesA.WithPipelineIDs(tracesC, tracesB), + pipelineIDs: []pipeline.ID{tracesA, tracesB, tracesC}, }, } { t.Run(tc.name, func(t *testing.T) { @@ -69,24 +70,24 @@ func TestInstanceID(t *testing.T) { } } -func TestAllPipelineIDs(t *testing.T) { - instanceID := NewInstanceID( +func TestAllPipelineIDsWithPipelineIDs(t *testing.T) { + instanceID := NewInstanceIDWithPipelineIDs( component.MustNewID("traces"), component.KindReceiver, - component.MustNewIDWithName("traces", "a"), - component.MustNewIDWithName("traces", "b"), - component.MustNewIDWithName("traces", "c"), + pipeline.MustNewIDWithName("traces", "a"), + pipeline.MustNewIDWithName("traces", "b"), + pipeline.MustNewIDWithName("traces", "c"), ) count := 0 - instanceID.AllPipelineIDs(func(component.ID) bool { + instanceID.AllPipelineIDsWithPipelineIDs(func(pipeline.ID) bool { count++ return true }) assert.Equal(t, 3, count) count = 0 - instanceID.AllPipelineIDs(func(component.ID) bool { + instanceID.AllPipelineIDsWithPipelineIDs(func(pipeline.ID) bool { count++ return false }) diff --git a/component/config.go b/component/config.go index 8eadee0c1f5..001b18916cd 100644 --- a/component/config.go +++ b/component/config.go @@ -147,6 +147,8 @@ func MustNewType(strType string) Type { // DataType is a special Type that represents the data types supported by the collector. We currently support // collecting metrics, traces and logs, this can expand in the future. +// +// Deprecated: [v0.110.0] Use pipeline.Signal instead. type DataType = Type func mustNewDataType(strType string) DataType { @@ -156,12 +158,18 @@ func mustNewDataType(strType string) DataType { // Currently supported data types. Add new data types here when new types are supported in the future. var ( // DataTypeTraces is the data type tag for traces. + // + // Deprecated: [v0.110.0] Use pipeline.SignalTraces instead. DataTypeTraces = mustNewDataType("traces") // DataTypeMetrics is the data type tag for metrics. + // + // Deprecated: [v0.110.0] Use pipeline.SignalMetrics instead. DataTypeMetrics = mustNewDataType("metrics") // DataTypeLogs is the data type tag for logs. + // + // Deprecated: [v0.110.0] Use pipeline.SignalLogs instead. DataTypeLogs = mustNewDataType("logs") ) diff --git a/component/go.mod b/component/go.mod index 13cf8958d1c..ceefdd8dfa7 100644 --- a/component/go.mod +++ b/component/go.mod @@ -6,6 +6,7 @@ require ( github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/config/configtelemetry v0.109.0 go.opentelemetry.io/collector/pdata v1.15.0 + go.opentelemetry.io/collector/pipeline v0.109.0 go.opentelemetry.io/otel v1.30.0 go.opentelemetry.io/otel/metric v1.30.0 go.opentelemetry.io/otel/sdk v1.30.0 @@ -23,6 +24,7 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect golang.org/x/net v0.28.0 // indirect golang.org/x/sys v0.25.0 // indirect golang.org/x/text v0.17.0 // indirect @@ -40,3 +42,7 @@ retract ( v0.76.0 // Depends on retracted pdata v1.0.0-rc10 module, use v0.76.1 v0.69.0 // Release failed, use v0.69.1 ) + +replace go.opentelemetry.io/collector/pipeline => ../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../internal/globalsignal diff --git a/config/configauth/go.mod b/config/configauth/go.mod index 6ed0d7dc393..b30371be0d3 100644 --- a/config/configauth/go.mod +++ b/config/configauth/go.mod @@ -15,7 +15,9 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata v1.15.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect go.opentelemetry.io/otel/metric v1.30.0 // indirect go.opentelemetry.io/otel/trace v1.30.0 // indirect @@ -39,3 +41,7 @@ replace go.opentelemetry.io/collector/config/configtelemetry => ../configtelemet replace go.opentelemetry.io/collector/extension => ../../extension replace go.opentelemetry.io/collector/extension/auth => ../../extension/auth + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal diff --git a/config/configgrpc/go.mod b/config/configgrpc/go.mod index a79022764cb..6af67ac6161 100644 --- a/config/configgrpc/go.mod +++ b/config/configgrpc/go.mod @@ -41,7 +41,9 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/extension v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.109.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/otel/metric v1.30.0 // indirect go.opentelemetry.io/otel/sdk v1.30.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.30.0 // indirect @@ -88,3 +90,7 @@ replace go.opentelemetry.io/collector/component => ../../component replace go.opentelemetry.io/collector/consumer => ../../consumer replace go.opentelemetry.io/collector/internal/globalgates => ../../internal/globalgates + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline diff --git a/config/confighttp/go.mod b/config/confighttp/go.mod index 8cfbc955d97..0c4a9e45d1c 100644 --- a/config/confighttp/go.mod +++ b/config/confighttp/go.mod @@ -37,7 +37,9 @@ require ( github.com/hashicorp/go-version v1.7.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/extension v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata v1.15.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/otel/sdk v1.30.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.30.0 // indirect go.opentelemetry.io/otel/trace v1.30.0 // indirect @@ -81,3 +83,7 @@ replace go.opentelemetry.io/collector/pdata/testdata => ../../pdata/testdata replace go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile replace go.opentelemetry.io/collector/internal/globalgates => ../../internal/globalgates + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline diff --git a/connector/connector_test.go b/connector/connector_test.go index 9b94cee7636..6dcff6d6a97 100644 --- a/connector/connector_test.go +++ b/connector/connector_test.go @@ -14,6 +14,7 @@ import ( "go.opentelemetry.io/collector/connector/internal" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/pipeline" ) var ( @@ -28,25 +29,25 @@ func TestNewFactoryNoOptions(t *testing.T) { assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) _, err := factory.CreateTracesToTraces(context.Background(), Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeTraces, component.DataTypeTraces)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalTraces, pipeline.SignalTraces)) _, err = factory.CreateTracesToMetrics(context.Background(), Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeTraces, component.DataTypeMetrics)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalTraces, pipeline.SignalMetrics)) _, err = factory.CreateTracesToLogs(context.Background(), Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeTraces, component.DataTypeLogs)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalTraces, pipeline.SignalLogs)) _, err = factory.CreateMetricsToTraces(context.Background(), Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeMetrics, component.DataTypeTraces)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalMetrics, pipeline.SignalTraces)) _, err = factory.CreateMetricsToMetrics(context.Background(), Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeMetrics, component.DataTypeMetrics)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalMetrics, pipeline.SignalMetrics)) _, err = factory.CreateMetricsToLogs(context.Background(), Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeMetrics, component.DataTypeLogs)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalMetrics, pipeline.SignalLogs)) _, err = factory.CreateLogsToTraces(context.Background(), Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeLogs, component.DataTypeTraces)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalLogs, pipeline.SignalTraces)) _, err = factory.CreateLogsToMetrics(context.Background(), Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeLogs, component.DataTypeMetrics)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalLogs, pipeline.SignalMetrics)) _, err = factory.CreateLogsToLogs(context.Background(), Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeLogs, component.DataTypeLogs)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalLogs, pipeline.SignalLogs)) } func TestNewFactoryWithSameTypes(t *testing.T) { @@ -71,19 +72,19 @@ func TestNewFactoryWithSameTypes(t *testing.T) { require.NoError(t, err) _, err = factory.CreateTracesToMetrics(context.Background(), Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeTraces, component.DataTypeMetrics)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalTraces, pipeline.SignalMetrics)) _, err = factory.CreateTracesToLogs(context.Background(), Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeTraces, component.DataTypeLogs)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalTraces, pipeline.SignalLogs)) _, err = factory.CreateMetricsToTraces(context.Background(), Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeMetrics, component.DataTypeTraces)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalMetrics, pipeline.SignalTraces)) _, err = factory.CreateMetricsToLogs(context.Background(), Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeMetrics, component.DataTypeLogs)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalMetrics, pipeline.SignalLogs)) _, err = factory.CreateLogsToTraces(context.Background(), Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeLogs, component.DataTypeTraces)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalLogs, pipeline.SignalTraces)) _, err = factory.CreateLogsToMetrics(context.Background(), Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeLogs, component.DataTypeMetrics)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalLogs, pipeline.SignalMetrics)) } func TestNewFactoryWithTranslateTypes(t *testing.T) { @@ -99,11 +100,11 @@ func TestNewFactoryWithTranslateTypes(t *testing.T) { assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) _, err := factory.CreateTracesToTraces(context.Background(), Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeTraces, component.DataTypeTraces)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalTraces, pipeline.SignalTraces)) _, err = factory.CreateMetricsToMetrics(context.Background(), Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeMetrics, component.DataTypeMetrics)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalMetrics, pipeline.SignalMetrics)) _, err = factory.CreateLogsToLogs(context.Background(), Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeLogs, component.DataTypeLogs)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalLogs, pipeline.SignalLogs)) assert.Equal(t, component.StabilityLevelDevelopment, factory.TracesToMetricsStability()) _, err = factory.CreateTracesToMetrics(context.Background(), Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) diff --git a/connector/connectorprofiles/connector_test.go b/connector/connectorprofiles/connector_test.go index 93493213c79..e50374fa657 100644 --- a/connector/connectorprofiles/connector_test.go +++ b/connector/connectorprofiles/connector_test.go @@ -17,6 +17,7 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumerprofiles" "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/pipeline" ) var ( @@ -31,18 +32,18 @@ func TestNewFactoryNoOptions(t *testing.T) { assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) _, err := factory.CreateTracesToProfiles(context.Background(), connector.Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeTraces, componentprofiles.DataTypeProfiles)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalTraces, componentprofiles.SignalProfiles)) _, err = factory.CreateMetricsToProfiles(context.Background(), connector.Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeMetrics, componentprofiles.DataTypeProfiles)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalMetrics, componentprofiles.SignalProfiles)) _, err = factory.CreateLogsToProfiles(context.Background(), connector.Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, component.DataTypeLogs, componentprofiles.DataTypeProfiles)) + assert.Equal(t, err, internal.ErrDataTypes(testID, pipeline.SignalLogs, componentprofiles.SignalProfiles)) _, err = factory.CreateProfilesToTraces(context.Background(), connector.Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, componentprofiles.DataTypeProfiles, component.DataTypeTraces)) + assert.Equal(t, err, internal.ErrDataTypes(testID, componentprofiles.SignalProfiles, pipeline.SignalTraces)) _, err = factory.CreateProfilesToMetrics(context.Background(), connector.Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, componentprofiles.DataTypeProfiles, component.DataTypeMetrics)) + assert.Equal(t, err, internal.ErrDataTypes(testID, componentprofiles.SignalProfiles, pipeline.SignalMetrics)) _, err = factory.CreateProfilesToLogs(context.Background(), connector.Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, componentprofiles.DataTypeProfiles, component.DataTypeLogs)) + assert.Equal(t, err, internal.ErrDataTypes(testID, componentprofiles.SignalProfiles, pipeline.SignalLogs)) } func TestNewFactoryWithSameTypes(t *testing.T) { @@ -58,11 +59,11 @@ func TestNewFactoryWithSameTypes(t *testing.T) { require.NoError(t, err) _, err = factory.CreateProfilesToTraces(context.Background(), connector.Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, componentprofiles.DataTypeProfiles, component.DataTypeTraces)) + assert.Equal(t, err, internal.ErrDataTypes(testID, componentprofiles.SignalProfiles, pipeline.SignalTraces)) _, err = factory.CreateProfilesToMetrics(context.Background(), connector.Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, componentprofiles.DataTypeProfiles, component.DataTypeMetrics)) + assert.Equal(t, err, internal.ErrDataTypes(testID, componentprofiles.SignalProfiles, pipeline.SignalMetrics)) _, err = factory.CreateProfilesToLogs(context.Background(), connector.Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, componentprofiles.DataTypeProfiles, component.DataTypeLogs)) + assert.Equal(t, err, internal.ErrDataTypes(testID, componentprofiles.SignalProfiles, pipeline.SignalLogs)) } func TestNewFactoryWithTranslateTypes(t *testing.T) { @@ -80,7 +81,7 @@ func TestNewFactoryWithTranslateTypes(t *testing.T) { assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig()) _, err := factory.CreateProfilesToProfiles(context.Background(), connector.Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) - assert.Equal(t, err, internal.ErrDataTypes(testID, componentprofiles.DataTypeProfiles, componentprofiles.DataTypeProfiles)) + assert.Equal(t, err, internal.ErrDataTypes(testID, componentprofiles.SignalProfiles, componentprofiles.SignalProfiles)) assert.Equal(t, component.StabilityLevelBeta, factory.TracesToProfilesStability()) _, err = factory.CreateTracesToProfiles(context.Background(), connector.Settings{ID: testID}, &defaultCfg, consumertest.NewNop()) diff --git a/connector/connectorprofiles/go.mod b/connector/connectorprofiles/go.mod index 00df565781f..7f63c504773 100644 --- a/connector/connectorprofiles/go.mod +++ b/connector/connectorprofiles/go.mod @@ -13,6 +13,7 @@ require ( go.opentelemetry.io/collector/consumer/consumertest v0.109.0 go.opentelemetry.io/collector/pdata/pprofile v0.109.0 go.opentelemetry.io/collector/pdata/testdata v0.109.0 + go.opentelemetry.io/collector/pipeline v0.109.0 ) require ( @@ -23,6 +24,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata v1.15.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect go.opentelemetry.io/otel/metric v1.30.0 // indirect @@ -63,3 +65,7 @@ replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/con replace go.opentelemetry.io/collector/pdata/testdata => ../../pdata/testdata replace go.opentelemetry.io/collector/component/componentstatus => ../../component/componentstatus + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal diff --git a/connector/connectorprofiles/profiles_router.go b/connector/connectorprofiles/profiles_router.go index 73e427f1d52..c171d166ef2 100644 --- a/connector/connectorprofiles/profiles_router.go +++ b/connector/connectorprofiles/profiles_router.go @@ -4,17 +4,16 @@ package connectorprofiles // import "go.opentelemetry.io/collector/connector/connectorprofiles" import ( - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/connector/internal" "go.opentelemetry.io/collector/consumer/consumerprofiles" "go.opentelemetry.io/collector/internal/fanoutconsumer" + "go.opentelemetry.io/collector/pipeline" ) -// ProfilesRouterAndConsumer feeds the first consumerprofiles.Profiles in each of the specified pipelines. type ProfilesRouterAndConsumer interface { consumerprofiles.Profiles - Consumer(...component.ID) (consumerprofiles.Profiles, error) - PipelineIDs() []component.ID + Consumer(...pipeline.ID) (consumerprofiles.Profiles, error) + PipelineIDs() []pipeline.ID privateFunc() } @@ -23,7 +22,7 @@ type profilesRouter struct { internal.BaseRouter[consumerprofiles.Profiles] } -func NewProfilesRouter(cm map[component.ID]consumerprofiles.Profiles) ProfilesRouterAndConsumer { +func NewProfilesRouter(cm map[pipeline.ID]consumerprofiles.Profiles) ProfilesRouterAndConsumer { consumers := make([]consumerprofiles.Profiles, 0, len(cm)) for _, cons := range cm { consumers = append(consumers, cons) diff --git a/connector/connectorprofiles/profiles_router_test.go b/connector/connectorprofiles/profiles_router_test.go index 0eb69a12be9..b28fc1a581e 100644 --- a/connector/connectorprofiles/profiles_router_test.go +++ b/connector/connectorprofiles/profiles_router_test.go @@ -12,12 +12,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumerprofiles" "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/pdata/pprofile" "go.opentelemetry.io/collector/pdata/testdata" + "go.opentelemetry.io/collector/pipeline" ) type mutatingProfilesSink struct { @@ -44,13 +44,13 @@ func TestProfilesRouterMultiplexing(t *testing.T) { func fuzzProfiles(numIDs, numCons, numProfiles int) func(*testing.T) { return func(t *testing.T) { - allIDs := make([]component.ID, 0, numCons) + allIDs := make([]pipeline.ID, 0, numCons) allCons := make([]consumerprofiles.Profiles, 0, numCons) - allConsMap := make(map[component.ID]consumerprofiles.Profiles) + allConsMap := make(map[pipeline.ID]consumerprofiles.Profiles) // If any consumer is mutating, the router must report mutating for i := 0; i < numCons; i++ { - allIDs = append(allIDs, component.MustNewIDWithName("sink", strconv.Itoa(numCons))) + allIDs = append(allIDs, pipeline.MustNewIDWithName("sink", strconv.Itoa(numCons))) // Random chance for each consumer to be mutating if (numCons+numProfiles+i)%4 == 0 { allCons = append(allCons, &mutatingProfilesSink{ProfilesSink: new(consumertest.ProfilesSink)}) @@ -65,11 +65,11 @@ func fuzzProfiles(numIDs, numCons, numProfiles int) func(*testing.T) { // Keep track of how many logs each consumer should receive. // This will be validated after every call to RouteProfiles. - expected := make(map[component.ID]int, numCons) + expected := make(map[pipeline.ID]int, numCons) for i := 0; i < numProfiles; i++ { // Build a random set of ids (no duplicates) - randCons := make(map[component.ID]bool, numIDs) + randCons := make(map[pipeline.ID]bool, numIDs) for j := 0; j < numIDs; j++ { // This number should be pretty random and less than numCons conNum := (numCons + numIDs + i + j) % numCons @@ -77,7 +77,7 @@ func fuzzProfiles(numIDs, numCons, numProfiles int) func(*testing.T) { } // Convert to slice, update expectations - conIDs := make([]component.ID, 0, len(randCons)) + conIDs := make([]pipeline.ID, 0, len(randCons)) for id := range randCons { conIDs = append(conIDs, id) expected[id]++ @@ -110,16 +110,16 @@ func TestProfilessRouterConsumer(t *testing.T) { ctx := context.Background() td := testdata.GenerateProfiles(1) - fooID := component.MustNewID("foo") - barID := component.MustNewID("bar") + fooID := pipeline.MustNewID("foo") + barID := pipeline.MustNewID("bar") foo := new(consumertest.ProfilesSink) bar := new(consumertest.ProfilesSink) - r := NewProfilesRouter(map[component.ID]consumerprofiles.Profiles{fooID: foo, barID: bar}) + r := NewProfilesRouter(map[pipeline.ID]consumerprofiles.Profiles{fooID: foo, barID: bar}) rcs := r.PipelineIDs() assert.Len(t, rcs, 2) - assert.ElementsMatch(t, []component.ID{fooID, barID}, rcs) + assert.ElementsMatch(t, []pipeline.ID{fooID, barID}, rcs) assert.Empty(t, foo.AllProfiles()) assert.Empty(t, bar.AllProfiles()) @@ -152,7 +152,7 @@ func TestProfilessRouterConsumer(t *testing.T) { assert.Nil(t, none) require.Error(t, err) - fake, err := r.Consumer(component.MustNewID("fake")) + fake, err := r.Consumer(pipeline.MustNewID("fake")) assert.Nil(t, fake) assert.Error(t, err) } diff --git a/connector/forwardconnector/generated_component_test.go b/connector/forwardconnector/generated_component_test.go index 8c7da3bc1fb..dcab04cfe6b 100644 --- a/connector/forwardconnector/generated_component_test.go +++ b/connector/forwardconnector/generated_component_test.go @@ -15,6 +15,7 @@ import ( "go.opentelemetry.io/collector/connector/connectortest" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/pipeline" ) func TestComponentFactoryType(t *testing.T) { @@ -36,7 +37,7 @@ func TestComponentLifecycle(t *testing.T) { { name: "logs_to_logs", createFn: func(ctx context.Context, set connector.Settings, cfg component.Config) (component.Component, error) { - router := connector.NewLogsRouter(map[component.ID]consumer.Logs{component.NewID(component.DataTypeLogs): consumertest.NewNop()}) + router := connector.NewLogsRouter(map[pipeline.ID]consumer.Logs{pipeline.NewID(pipeline.SignalLogs): consumertest.NewNop()}) return factory.CreateLogsToLogs(ctx, set, cfg, router) }, }, @@ -44,7 +45,7 @@ func TestComponentLifecycle(t *testing.T) { { name: "metrics_to_metrics", createFn: func(ctx context.Context, set connector.Settings, cfg component.Config) (component.Component, error) { - router := connector.NewMetricsRouter(map[component.ID]consumer.Metrics{component.NewID(component.DataTypeMetrics): consumertest.NewNop()}) + router := connector.NewMetricsRouter(map[pipeline.ID]consumer.Metrics{pipeline.NewID(pipeline.SignalMetrics): consumertest.NewNop()}) return factory.CreateMetricsToMetrics(ctx, set, cfg, router) }, }, @@ -52,7 +53,7 @@ func TestComponentLifecycle(t *testing.T) { { name: "traces_to_traces", createFn: func(ctx context.Context, set connector.Settings, cfg component.Config) (component.Component, error) { - router := connector.NewTracesRouter(map[component.ID]consumer.Traces{component.NewID(component.DataTypeTraces): consumertest.NewNop()}) + router := connector.NewTracesRouter(map[pipeline.ID]consumer.Traces{pipeline.NewID(pipeline.SignalTraces): consumertest.NewNop()}) return factory.CreateTracesToTraces(ctx, set, cfg, router) }, }, diff --git a/connector/forwardconnector/go.mod b/connector/forwardconnector/go.mod index 4811873feff..0408decece8 100644 --- a/connector/forwardconnector/go.mod +++ b/connector/forwardconnector/go.mod @@ -10,6 +10,7 @@ require ( go.opentelemetry.io/collector/consumer v0.109.0 go.opentelemetry.io/collector/consumer/consumertest v0.109.0 go.opentelemetry.io/collector/pdata v1.15.0 + go.opentelemetry.io/collector/pipeline v0.109.0 go.uber.org/goleak v1.3.0 ) @@ -34,6 +35,7 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect go.opentelemetry.io/collector/connector/connectorprofiles v0.109.0 // indirect go.opentelemetry.io/collector/consumer/consumerprofiles v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.109.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect go.opentelemetry.io/otel/metric v1.30.0 // indirect @@ -83,3 +85,7 @@ replace go.opentelemetry.io/collector/component/componentprofiles => ../../compo replace go.opentelemetry.io/collector/component/componentstatus => ../../component/componentstatus replace go.opentelemetry.io/collector/connector/connectorprofiles => ../connectorprofiles + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal diff --git a/connector/go.mod b/connector/go.mod index 15b5727cf76..a84d9c115e4 100644 --- a/connector/go.mod +++ b/connector/go.mod @@ -15,6 +15,7 @@ require ( go.opentelemetry.io/collector/pdata v1.15.0 go.opentelemetry.io/collector/pdata/pprofile v0.109.0 go.opentelemetry.io/collector/pdata/testdata v0.109.0 + go.opentelemetry.io/collector/pipeline v0.109.0 go.uber.org/goleak v1.3.0 go.uber.org/multierr v1.11.0 ) @@ -29,6 +30,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect go.opentelemetry.io/otel/metric v1.30.0 // indirect go.opentelemetry.io/otel/sdk v1.30.0 // indirect @@ -69,3 +71,7 @@ replace go.opentelemetry.io/collector/component/componentprofiles => ../componen replace go.opentelemetry.io/collector/component/componentstatus => ../component/componentstatus replace go.opentelemetry.io/collector/connector/connectorprofiles => ./connectorprofiles + +replace go.opentelemetry.io/collector/pipeline => ../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../internal/globalsignal diff --git a/connector/internal/factory.go b/connector/internal/factory.go index 09f6c2ddbf5..df09ab6e5a6 100644 --- a/connector/internal/factory.go +++ b/connector/internal/factory.go @@ -11,6 +11,7 @@ import ( "go.opentelemetry.io/collector/component/componentprofiles" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumerprofiles" + "go.opentelemetry.io/collector/pipeline" ) // Factory is a factory interface for connectors. @@ -143,7 +144,7 @@ func (f CreateTracesToTracesFunc) CreateTracesToTraces( cfg component.Config, nextConsumer consumer.Traces) (Traces, error) { if f == nil { - return nil, ErrDataTypes(set.ID, component.DataTypeTraces, component.DataTypeTraces) + return nil, ErrDataTypes(set.ID, pipeline.SignalTraces, pipeline.SignalTraces) } return f(ctx, set, cfg, nextConsumer) } @@ -159,7 +160,7 @@ func (f CreateTracesToMetricsFunc) CreateTracesToMetrics( nextConsumer consumer.Metrics, ) (Traces, error) { if f == nil { - return nil, ErrDataTypes(set.ID, component.DataTypeTraces, component.DataTypeMetrics) + return nil, ErrDataTypes(set.ID, pipeline.SignalTraces, pipeline.SignalMetrics) } return f(ctx, set, cfg, nextConsumer) } @@ -175,7 +176,7 @@ func (f CreateTracesToLogsFunc) CreateTracesToLogs( nextConsumer consumer.Logs, ) (Traces, error) { if f == nil { - return nil, ErrDataTypes(set.ID, component.DataTypeTraces, component.DataTypeLogs) + return nil, ErrDataTypes(set.ID, pipeline.SignalTraces, pipeline.SignalLogs) } return f(ctx, set, cfg, nextConsumer) } @@ -191,7 +192,7 @@ func (f CreateTracesToProfilesFunc) CreateTracesToProfiles( nextConsumer consumerprofiles.Profiles, ) (Traces, error) { if f == nil { - return nil, ErrDataTypes(set.ID, component.DataTypeTraces, componentprofiles.DataTypeProfiles) + return nil, ErrDataTypes(set.ID, pipeline.SignalTraces, componentprofiles.SignalProfiles) } return f(ctx, set, cfg, nextConsumer) } @@ -207,7 +208,7 @@ func (f CreateMetricsToTracesFunc) CreateMetricsToTraces( nextConsumer consumer.Traces, ) (Metrics, error) { if f == nil { - return nil, ErrDataTypes(set.ID, component.DataTypeMetrics, component.DataTypeTraces) + return nil, ErrDataTypes(set.ID, pipeline.SignalMetrics, pipeline.SignalTraces) } return f(ctx, set, cfg, nextConsumer) } @@ -223,7 +224,7 @@ func (f CreateMetricsToMetricsFunc) CreateMetricsToMetrics( nextConsumer consumer.Metrics, ) (Metrics, error) { if f == nil { - return nil, ErrDataTypes(set.ID, component.DataTypeMetrics, component.DataTypeMetrics) + return nil, ErrDataTypes(set.ID, pipeline.SignalMetrics, pipeline.SignalMetrics) } return f(ctx, set, cfg, nextConsumer) } @@ -239,7 +240,7 @@ func (f CreateMetricsToLogsFunc) CreateMetricsToLogs( nextConsumer consumer.Logs, ) (Metrics, error) { if f == nil { - return nil, ErrDataTypes(set.ID, component.DataTypeMetrics, component.DataTypeLogs) + return nil, ErrDataTypes(set.ID, pipeline.SignalMetrics, pipeline.SignalLogs) } return f(ctx, set, cfg, nextConsumer) } @@ -255,7 +256,7 @@ func (f CreateMetricsToProfilesFunc) CreateMetricsToProfiles( nextConsumer consumerprofiles.Profiles, ) (Metrics, error) { if f == nil { - return nil, ErrDataTypes(set.ID, component.DataTypeMetrics, componentprofiles.DataTypeProfiles) + return nil, ErrDataTypes(set.ID, pipeline.SignalMetrics, componentprofiles.SignalProfiles) } return f(ctx, set, cfg, nextConsumer) } @@ -271,7 +272,7 @@ func (f CreateLogsToTracesFunc) CreateLogsToTraces( nextConsumer consumer.Traces, ) (Logs, error) { if f == nil { - return nil, ErrDataTypes(set.ID, component.DataTypeLogs, component.DataTypeTraces) + return nil, ErrDataTypes(set.ID, pipeline.SignalLogs, pipeline.SignalTraces) } return f(ctx, set, cfg, nextConsumer) } @@ -287,7 +288,7 @@ func (f CreateLogsToMetricsFunc) CreateLogsToMetrics( nextConsumer consumer.Metrics, ) (Logs, error) { if f == nil { - return nil, ErrDataTypes(set.ID, component.DataTypeLogs, component.DataTypeMetrics) + return nil, ErrDataTypes(set.ID, pipeline.SignalLogs, pipeline.SignalMetrics) } return f(ctx, set, cfg, nextConsumer) } @@ -303,7 +304,7 @@ func (f CreateLogsToLogsFunc) CreateLogsToLogs( nextConsumer consumer.Logs, ) (Logs, error) { if f == nil { - return nil, ErrDataTypes(set.ID, component.DataTypeLogs, component.DataTypeLogs) + return nil, ErrDataTypes(set.ID, pipeline.SignalLogs, pipeline.SignalLogs) } return f(ctx, set, cfg, nextConsumer) } @@ -319,7 +320,7 @@ func (f CreateLogsToProfilesFunc) CreateLogsToProfiles( nextConsumer consumerprofiles.Profiles, ) (Logs, error) { if f == nil { - return nil, ErrDataTypes(set.ID, component.DataTypeLogs, componentprofiles.DataTypeProfiles) + return nil, ErrDataTypes(set.ID, pipeline.SignalLogs, componentprofiles.SignalProfiles) } return f(ctx, set, cfg, nextConsumer) } @@ -335,7 +336,7 @@ func (f CreateProfilesToProfilesFunc) CreateProfilesToProfiles( nextConsumer consumerprofiles.Profiles, ) (Profiles, error) { if f == nil { - return nil, ErrDataTypes(set.ID, componentprofiles.DataTypeProfiles, componentprofiles.DataTypeProfiles) + return nil, ErrDataTypes(set.ID, componentprofiles.SignalProfiles, componentprofiles.SignalProfiles) } return f(ctx, set, cfg, nextConsumer) } @@ -351,7 +352,7 @@ func (f CreateProfilesToTracesFunc) CreateProfilesToTraces( nextConsumer consumer.Traces, ) (Profiles, error) { if f == nil { - return nil, ErrDataTypes(set.ID, componentprofiles.DataTypeProfiles, component.DataTypeTraces) + return nil, ErrDataTypes(set.ID, componentprofiles.SignalProfiles, pipeline.SignalTraces) } return f(ctx, set, cfg, nextConsumer) } @@ -367,7 +368,7 @@ func (f CreateProfilesToMetricsFunc) CreateProfilesToMetrics( nextConsumer consumer.Metrics, ) (Profiles, error) { if f == nil { - return nil, ErrDataTypes(set.ID, componentprofiles.DataTypeProfiles, component.DataTypeMetrics) + return nil, ErrDataTypes(set.ID, componentprofiles.SignalProfiles, pipeline.SignalMetrics) } return f(ctx, set, cfg, nextConsumer) } @@ -383,7 +384,7 @@ func (f CreateProfilesToLogsFunc) CreateProfilesToLogs( nextConsumer consumer.Logs, ) (Profiles, error) { if f == nil { - return nil, ErrDataTypes(set.ID, componentprofiles.DataTypeProfiles, component.DataTypeLogs) + return nil, ErrDataTypes(set.ID, componentprofiles.SignalProfiles, pipeline.SignalLogs) } return f(ctx, set, cfg, nextConsumer) } @@ -599,6 +600,6 @@ func WithProfilesToLogs(createProfilesToLogs CreateProfilesToLogsFunc, sl compon }) } -func ErrDataTypes(id component.ID, from, to component.DataType) error { - return fmt.Errorf("connector %q cannot connect from %s to %s: %w", id, from, to, component.ErrDataTypeIsNotSupported) +func ErrDataTypes(id component.ID, from, to pipeline.Signal) error { + return fmt.Errorf("connector %q cannot connect from %s to %s: %w", id, from, to, pipeline.ErrSignalNotSupported) } diff --git a/connector/internal/router.go b/connector/internal/router.go index 18c684807cb..9360ff948a8 100644 --- a/connector/internal/router.go +++ b/connector/internal/router.go @@ -8,31 +8,31 @@ import ( "go.uber.org/multierr" - "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/pipeline" ) type BaseRouter[T any] struct { fanout func([]T) T - Consumers map[component.ID]T + Consumers map[pipeline.ID]T } -func NewBaseRouter[T any](fanout func([]T) T, cm map[component.ID]T) BaseRouter[T] { - consumers := make(map[component.ID]T, len(cm)) +func NewBaseRouter[T any](fanout func([]T) T, cm map[pipeline.ID]T) BaseRouter[T] { + consumers := make(map[pipeline.ID]T, len(cm)) for k, v := range cm { consumers[k] = v } return BaseRouter[T]{fanout: fanout, Consumers: consumers} } -func (r *BaseRouter[T]) PipelineIDs() []component.ID { - ids := make([]component.ID, 0, len(r.Consumers)) +func (r *BaseRouter[T]) PipelineIDs() []pipeline.ID { + ids := make([]pipeline.ID, 0, len(r.Consumers)) for id := range r.Consumers { ids = append(ids, id) } return ids } -func (r *BaseRouter[T]) Consumer(pipelineIDs ...component.ID) (T, error) { +func (r *BaseRouter[T]) Consumer(pipelineIDs ...pipeline.ID) (T, error) { var ret T if len(pipelineIDs) == 0 { return ret, fmt.Errorf("missing consumers") diff --git a/connector/logs_router.go b/connector/logs_router.go index 37a3831038e..ff6190aa643 100644 --- a/connector/logs_router.go +++ b/connector/logs_router.go @@ -8,17 +8,17 @@ import ( "go.uber.org/multierr" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/connector/internal" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/internal/fanoutconsumer" + "go.opentelemetry.io/collector/pipeline" ) // LogsRouterAndConsumer feeds the first consumer.Logs in each of the specified pipelines. type LogsRouterAndConsumer interface { consumer.Logs - Consumer(...component.ID) (consumer.Logs, error) - PipelineIDs() []component.ID + Consumer(...pipeline.ID) (consumer.Logs, error) + PipelineIDs() []pipeline.ID privateFunc() } @@ -27,7 +27,7 @@ type logsRouter struct { internal.BaseRouter[consumer.Logs] } -func NewLogsRouter(cm map[component.ID]consumer.Logs) LogsRouterAndConsumer { +func NewLogsRouter(cm map[pipeline.ID]consumer.Logs) LogsRouterAndConsumer { consumers := make([]consumer.Logs, 0, len(cm)) for _, cons := range cm { consumers = append(consumers, cons) @@ -38,15 +38,15 @@ func NewLogsRouter(cm map[component.ID]consumer.Logs) LogsRouterAndConsumer { } } -func (r *logsRouter) PipelineIDs() []component.ID { - ids := make([]component.ID, 0, len(r.Consumers)) +func (r *logsRouter) PipelineIDs() []pipeline.ID { + ids := make([]pipeline.ID, 0, len(r.Consumers)) for id := range r.Consumers { ids = append(ids, id) } return ids } -func (r *logsRouter) Consumer(pipelineIDs ...component.ID) (consumer.Logs, error) { +func (r *logsRouter) Consumer(pipelineIDs ...pipeline.ID) (consumer.Logs, error) { if len(pipelineIDs) == 0 { return nil, fmt.Errorf("missing consumers") } diff --git a/connector/logs_router_test.go b/connector/logs_router_test.go index d4d70c3fec2..591c25e6a7c 100644 --- a/connector/logs_router_test.go +++ b/connector/logs_router_test.go @@ -12,11 +12,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/pdata/testdata" + "go.opentelemetry.io/collector/pipeline" ) type mutatingLogsSink struct { @@ -43,13 +43,13 @@ func TestLogsRouterMultiplexing(t *testing.T) { func fuzzLogs(numIDs, numCons, numLogs int) func(*testing.T) { return func(t *testing.T) { - allIDs := make([]component.ID, 0, numCons) + allIDs := make([]pipeline.ID, 0, numCons) allCons := make([]consumer.Logs, 0, numCons) - allConsMap := make(map[component.ID]consumer.Logs) + allConsMap := make(map[pipeline.ID]consumer.Logs) // If any consumer is mutating, the router must report mutating for i := 0; i < numCons; i++ { - allIDs = append(allIDs, component.MustNewIDWithName("sink", strconv.Itoa(numCons))) + allIDs = append(allIDs, pipeline.MustNewIDWithName("sink", strconv.Itoa(numCons))) // Random chance for each consumer to be mutating if (numCons+numLogs+i)%4 == 0 { allCons = append(allCons, &mutatingLogsSink{LogsSink: new(consumertest.LogsSink)}) @@ -64,11 +64,11 @@ func fuzzLogs(numIDs, numCons, numLogs int) func(*testing.T) { // Keep track of how many logs each consumer should receive. // This will be validated after every call to RouteLogs. - expected := make(map[component.ID]int, numCons) + expected := make(map[pipeline.ID]int, numCons) for i := 0; i < numLogs; i++ { // Build a random set of ids (no duplicates) - randCons := make(map[component.ID]bool, numIDs) + randCons := make(map[pipeline.ID]bool, numIDs) for j := 0; j < numIDs; j++ { // This number should be pretty random and less than numCons conNum := (numCons + numIDs + i + j) % numCons @@ -76,7 +76,7 @@ func fuzzLogs(numIDs, numCons, numLogs int) func(*testing.T) { } // Convert to slice, update expectations - conIDs := make([]component.ID, 0, len(randCons)) + conIDs := make([]pipeline.ID, 0, len(randCons)) for id := range randCons { conIDs = append(conIDs, id) expected[id]++ @@ -109,16 +109,16 @@ func TestLogsRouterConsumers(t *testing.T) { ctx := context.Background() ld := testdata.GenerateLogs(1) - fooID := component.MustNewID("foo") - barID := component.MustNewID("bar") + fooID := pipeline.MustNewID("foo") + barID := pipeline.MustNewID("bar") foo := new(consumertest.LogsSink) bar := new(consumertest.LogsSink) - r := NewLogsRouter(map[component.ID]consumer.Logs{fooID: foo, barID: bar}) + r := NewLogsRouter(map[pipeline.ID]consumer.Logs{fooID: foo, barID: bar}) rcs := r.PipelineIDs() assert.Len(t, rcs, 2) - assert.ElementsMatch(t, []component.ID{fooID, barID}, rcs) + assert.ElementsMatch(t, []pipeline.ID{fooID, barID}, rcs) assert.Empty(t, foo.AllLogs()) assert.Empty(t, bar.AllLogs()) @@ -151,7 +151,7 @@ func TestLogsRouterConsumers(t *testing.T) { assert.Nil(t, none) require.Error(t, err) - fake, err := r.Consumer(component.MustNewID("fake")) + fake, err := r.Consumer(pipeline.MustNewID("fake")) assert.Nil(t, fake) assert.Error(t, err) } diff --git a/connector/metrics_router.go b/connector/metrics_router.go index 67ba27f86a0..a45a6397fe0 100644 --- a/connector/metrics_router.go +++ b/connector/metrics_router.go @@ -4,17 +4,17 @@ package connector // import "go.opentelemetry.io/collector/connector" import ( - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/connector/internal" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/internal/fanoutconsumer" + "go.opentelemetry.io/collector/pipeline" ) // MetricsRouterAndConsumer feeds the first consumer.Metrics in each of the specified pipelines. type MetricsRouterAndConsumer interface { consumer.Metrics - Consumer(...component.ID) (consumer.Metrics, error) - PipelineIDs() []component.ID + Consumer(...pipeline.ID) (consumer.Metrics, error) + PipelineIDs() []pipeline.ID privateFunc() } @@ -23,7 +23,7 @@ type metricsRouter struct { internal.BaseRouter[consumer.Metrics] } -func NewMetricsRouter(cm map[component.ID]consumer.Metrics) MetricsRouterAndConsumer { +func NewMetricsRouter(cm map[pipeline.ID]consumer.Metrics) MetricsRouterAndConsumer { consumers := make([]consumer.Metrics, 0, len(cm)) for _, cons := range cm { consumers = append(consumers, cons) diff --git a/connector/metrics_router_test.go b/connector/metrics_router_test.go index 7fb12de9b1d..728174a3d41 100644 --- a/connector/metrics_router_test.go +++ b/connector/metrics_router_test.go @@ -12,11 +12,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/pdata/pmetric" "go.opentelemetry.io/collector/pdata/testdata" + "go.opentelemetry.io/collector/pipeline" ) type mutatingMetricsSink struct { @@ -43,13 +43,13 @@ func TestMetricsRouterMultiplexing(t *testing.T) { func fuzzMetrics(numIDs, numCons, numMetrics int) func(*testing.T) { return func(t *testing.T) { - allIDs := make([]component.ID, 0, numCons) + allIDs := make([]pipeline.ID, 0, numCons) allCons := make([]consumer.Metrics, 0, numCons) - allConsMap := make(map[component.ID]consumer.Metrics) + allConsMap := make(map[pipeline.ID]consumer.Metrics) // If any consumer is mutating, the router must report mutating for i := 0; i < numCons; i++ { - allIDs = append(allIDs, component.MustNewIDWithName("sink", strconv.Itoa(numCons))) + allIDs = append(allIDs, pipeline.MustNewIDWithName("sink", strconv.Itoa(numCons))) // Random chance for each consumer to be mutating if (numCons+numMetrics+i)%4 == 0 { allCons = append(allCons, &mutatingMetricsSink{MetricsSink: new(consumertest.MetricsSink)}) @@ -64,11 +64,11 @@ func fuzzMetrics(numIDs, numCons, numMetrics int) func(*testing.T) { // Keep track of how many logs each consumer should receive. // This will be validated after every call to RouteMetrics. - expected := make(map[component.ID]int, numCons) + expected := make(map[pipeline.ID]int, numCons) for i := 0; i < numMetrics; i++ { // Build a random set of ids (no duplicates) - randCons := make(map[component.ID]bool, numIDs) + randCons := make(map[pipeline.ID]bool, numIDs) for j := 0; j < numIDs; j++ { // This number should be pretty random and less than numCons conNum := (numCons + numIDs + i + j) % numCons @@ -76,7 +76,7 @@ func fuzzMetrics(numIDs, numCons, numMetrics int) func(*testing.T) { } // Convert to slice, update expectations - conIDs := make([]component.ID, 0, len(randCons)) + conIDs := make([]pipeline.ID, 0, len(randCons)) for id := range randCons { conIDs = append(conIDs, id) expected[id]++ @@ -109,16 +109,16 @@ func TestMetricsRouterConsumers(t *testing.T) { ctx := context.Background() md := testdata.GenerateMetrics(1) - fooID := component.MustNewID("foo") - barID := component.MustNewID("bar") + fooID := pipeline.MustNewID("foo") + barID := pipeline.MustNewID("bar") foo := new(consumertest.MetricsSink) bar := new(consumertest.MetricsSink) - r := NewMetricsRouter(map[component.ID]consumer.Metrics{fooID: foo, barID: bar}) + r := NewMetricsRouter(map[pipeline.ID]consumer.Metrics{fooID: foo, barID: bar}) rcs := r.PipelineIDs() assert.Len(t, rcs, 2) - assert.ElementsMatch(t, []component.ID{fooID, barID}, rcs) + assert.ElementsMatch(t, []pipeline.ID{fooID, barID}, rcs) assert.Empty(t, foo.AllMetrics()) assert.Empty(t, bar.AllMetrics()) @@ -151,7 +151,7 @@ func TestMetricsRouterConsumers(t *testing.T) { assert.Nil(t, none) require.Error(t, err) - fake, err := r.Consumer(component.MustNewID("fake")) + fake, err := r.Consumer(pipeline.MustNewID("fake")) assert.Nil(t, fake) assert.Error(t, err) } diff --git a/connector/traces_router.go b/connector/traces_router.go index 40cfbdd18a0..5622b78bf94 100644 --- a/connector/traces_router.go +++ b/connector/traces_router.go @@ -4,17 +4,17 @@ package connector // import "go.opentelemetry.io/collector/connector" import ( - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/connector/internal" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/internal/fanoutconsumer" + "go.opentelemetry.io/collector/pipeline" ) // TracesRouterAndConsumer feeds the first consumer.Traces in each of the specified pipelines. type TracesRouterAndConsumer interface { consumer.Traces - Consumer(...component.ID) (consumer.Traces, error) - PipelineIDs() []component.ID + Consumer(...pipeline.ID) (consumer.Traces, error) + PipelineIDs() []pipeline.ID privateFunc() } @@ -23,7 +23,7 @@ type tracesRouter struct { internal.BaseRouter[consumer.Traces] } -func NewTracesRouter(cm map[component.ID]consumer.Traces) TracesRouterAndConsumer { +func NewTracesRouter(cm map[pipeline.ID]consumer.Traces) TracesRouterAndConsumer { consumers := make([]consumer.Traces, 0, len(cm)) for _, cons := range cm { consumers = append(consumers, cons) diff --git a/connector/traces_router_test.go b/connector/traces_router_test.go index a54b1006012..125d159cabf 100644 --- a/connector/traces_router_test.go +++ b/connector/traces_router_test.go @@ -12,11 +12,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/pdata/ptrace" "go.opentelemetry.io/collector/pdata/testdata" + "go.opentelemetry.io/collector/pipeline" ) type mutatingTracesSink struct { @@ -43,13 +43,13 @@ func TestTracesRouterMultiplexing(t *testing.T) { func fuzzTraces(numIDs, numCons, numTraces int) func(*testing.T) { return func(t *testing.T) { - allIDs := make([]component.ID, 0, numCons) + allIDs := make([]pipeline.ID, 0, numCons) allCons := make([]consumer.Traces, 0, numCons) - allConsMap := make(map[component.ID]consumer.Traces) + allConsMap := make(map[pipeline.ID]consumer.Traces) // If any consumer is mutating, the router must report mutating for i := 0; i < numCons; i++ { - allIDs = append(allIDs, component.MustNewIDWithName("sink", strconv.Itoa(numCons))) + allIDs = append(allIDs, pipeline.MustNewIDWithName("sink", strconv.Itoa(numCons))) // Random chance for each consumer to be mutating if (numCons+numTraces+i)%4 == 0 { allCons = append(allCons, &mutatingTracesSink{TracesSink: new(consumertest.TracesSink)}) @@ -64,11 +64,11 @@ func fuzzTraces(numIDs, numCons, numTraces int) func(*testing.T) { // Keep track of how many logs each consumer should receive. // This will be validated after every call to RouteTraces. - expected := make(map[component.ID]int, numCons) + expected := make(map[pipeline.ID]int, numCons) for i := 0; i < numTraces; i++ { // Build a random set of ids (no duplicates) - randCons := make(map[component.ID]bool, numIDs) + randCons := make(map[pipeline.ID]bool, numIDs) for j := 0; j < numIDs; j++ { // This number should be pretty random and less than numCons conNum := (numCons + numIDs + i + j) % numCons @@ -76,7 +76,7 @@ func fuzzTraces(numIDs, numCons, numTraces int) func(*testing.T) { } // Convert to slice, update expectations - conIDs := make([]component.ID, 0, len(randCons)) + conIDs := make([]pipeline.ID, 0, len(randCons)) for id := range randCons { conIDs = append(conIDs, id) expected[id]++ @@ -109,16 +109,16 @@ func TestTracesRouterConsumer(t *testing.T) { ctx := context.Background() td := testdata.GenerateTraces(1) - fooID := component.MustNewID("foo") - barID := component.MustNewID("bar") + fooID := pipeline.MustNewID("foo") + barID := pipeline.MustNewID("bar") foo := new(consumertest.TracesSink) bar := new(consumertest.TracesSink) - r := NewTracesRouter(map[component.ID]consumer.Traces{fooID: foo, barID: bar}) + r := NewTracesRouter(map[pipeline.ID]consumer.Traces{fooID: foo, barID: bar}) rcs := r.PipelineIDs() assert.Len(t, rcs, 2) - assert.ElementsMatch(t, []component.ID{fooID, barID}, rcs) + assert.ElementsMatch(t, []pipeline.ID{fooID, barID}, rcs) assert.Empty(t, foo.AllTraces()) assert.Empty(t, bar.AllTraces()) @@ -151,7 +151,7 @@ func TestTracesRouterConsumer(t *testing.T) { assert.Nil(t, none) require.Error(t, err) - fake, err := r.Consumer(component.MustNewID("fake")) + fake, err := r.Consumer(pipeline.MustNewID("fake")) assert.Nil(t, fake) assert.Error(t, err) } diff --git a/exporter/debugexporter/go.mod b/exporter/debugexporter/go.mod index 4570dd859ad..51a74c39491 100644 --- a/exporter/debugexporter/go.mod +++ b/exporter/debugexporter/go.mod @@ -32,13 +32,16 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + go.opentelemetry.io/collector/component/componentprofiles v0.109.0 // indirect go.opentelemetry.io/collector/config/configretry v1.15.0 // indirect go.opentelemetry.io/collector/consumer/consumerprofiles v0.109.0 // indirect go.opentelemetry.io/collector/consumer/consumertest v0.109.0 // indirect go.opentelemetry.io/collector/exporter/exporterprofiles v0.109.0 // indirect go.opentelemetry.io/collector/extension v0.109.0 // indirect go.opentelemetry.io/collector/extension/experimental/storage v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.109.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/collector/receiver v0.109.0 // indirect go.opentelemetry.io/collector/receiver/receiverprofiles v0.109.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect @@ -87,3 +90,9 @@ replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/co replace go.opentelemetry.io/collector/receiver/receiverprofiles => ../../receiver/receiverprofiles replace go.opentelemetry.io/collector/exporter/exporterprofiles => ../exporterprofiles + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal + +replace go.opentelemetry.io/collector/component/componentprofiles => ../../component/componentprofiles diff --git a/exporter/exporterhelper/internal/base_exporter.go b/exporter/exporterhelper/internal/base_exporter.go index 922dbc9b34a..9d2713c01c0 100644 --- a/exporter/exporterhelper/internal/base_exporter.go +++ b/exporter/exporterhelper/internal/base_exporter.go @@ -21,6 +21,7 @@ import ( "go.opentelemetry.io/collector/exporter/exporterbatcher" "go.opentelemetry.io/collector/exporter/exporterqueue" // BaseExporter contains common fields between different exporter types. "go.opentelemetry.io/collector/exporter/internal" + "go.opentelemetry.io/collector/pipeline" ) type ObsrepSenderFactory = func(obsrep *ObsReport) RequestSender @@ -35,7 +36,7 @@ type BaseExporter struct { component.StartFunc component.ShutdownFunc - Signal component.DataType + Signal pipeline.Signal BatchMergeFunc exporterbatcher.BatchMergeFunc[internal.Request] BatchMergeSplitfunc exporterbatcher.BatchMergeSplitFunc[internal.Request] @@ -66,8 +67,8 @@ type BaseExporter struct { BatcherOpts []BatcherOption } -func NewBaseExporter(set exporter.Settings, signal component.DataType, osf ObsrepSenderFactory, options ...Option) (*BaseExporter, error) { - obsReport, err := NewExporter(ObsReportSettings{ExporterID: set.ID, ExporterCreateSettings: set, DataType: signal}) +func NewBaseExporter(set exporter.Settings, signal pipeline.Signal, osf ObsrepSenderFactory, options ...Option) (*BaseExporter, error) { + obsReport, err := NewExporter(ObsReportSettings{ExporterID: set.ID, ExporterCreateSettings: set, Signal: signal}) if err != nil { return nil, err } @@ -105,7 +106,7 @@ func NewBaseExporter(set exporter.Settings, signal component.DataType, osf Obsre if be.QueueCfg.Enabled { set := exporterqueue.Settings{ - DataType: be.Signal, + Signal: be.Signal, ExporterSettings: be.Set, } be.QueueSender = NewQueueSender(be.QueueFactory(context.Background(), set, be.QueueCfg), be.Set, be.QueueCfg.NumConsumers, be.ExportFailureMessage, be.Obsrep) @@ -234,7 +235,7 @@ func WithQueue(config QueueConfig) Option { Unmarshaler: o.Unmarshaler, }) q := qf(context.Background(), exporterqueue.Settings{ - DataType: o.Signal, + Signal: o.Signal, ExporterSettings: o.Set, }, exporterqueue.Config{ Enabled: config.Enabled, diff --git a/exporter/exporterhelper/internal/base_exporter_test.go b/exporter/exporterhelper/internal/base_exporter_test.go index f9c5975a171..028b0127627 100644 --- a/exporter/exporterhelper/internal/base_exporter_test.go +++ b/exporter/exporterhelper/internal/base_exporter_test.go @@ -19,11 +19,12 @@ import ( "go.opentelemetry.io/collector/exporter/exporterqueue" "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/exporter/internal" + "go.opentelemetry.io/collector/pipeline" ) var ( defaultType = component.MustNewType("test") - defaultDataType = component.DataTypeMetrics + defaultSignal = pipeline.SignalMetrics defaultID = component.NewID(defaultType) defaultSettings = func() exporter.Settings { set := exportertest.NewNopSettings() @@ -37,7 +38,7 @@ func newNoopObsrepSender(*ObsReport) RequestSender { } func TestBaseExporter(t *testing.T) { - be, err := NewBaseExporter(defaultSettings, defaultDataType, newNoopObsrepSender) + be, err := NewBaseExporter(defaultSettings, defaultSignal, newNoopObsrepSender) require.NoError(t, err) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) require.NoError(t, be.Shutdown(context.Background())) @@ -46,7 +47,7 @@ func TestBaseExporter(t *testing.T) { func TestBaseExporterWithOptions(t *testing.T) { want := errors.New("my error") be, err := NewBaseExporter( - defaultSettings, defaultDataType, newNoopObsrepSender, + defaultSettings, defaultSignal, newNoopObsrepSender, WithStart(func(context.Context, component.Host) error { return want }), WithShutdown(func(context.Context) error { return want }), WithTimeout(NewDefaultTimeoutConfig()), @@ -57,16 +58,16 @@ func TestBaseExporterWithOptions(t *testing.T) { } func TestQueueOptionsWithRequestExporter(t *testing.T) { - bs, err := NewBaseExporter(exportertest.NewNopSettings(), defaultDataType, newNoopObsrepSender, + bs, err := NewBaseExporter(exportertest.NewNopSettings(), defaultSignal, newNoopObsrepSender, WithRetry(configretry.NewDefaultBackOffConfig())) require.NoError(t, err) require.Nil(t, bs.Marshaler) require.Nil(t, bs.Unmarshaler) - _, err = NewBaseExporter(exportertest.NewNopSettings(), defaultDataType, newNoopObsrepSender, + _, err = NewBaseExporter(exportertest.NewNopSettings(), defaultSignal, newNoopObsrepSender, WithRetry(configretry.NewDefaultBackOffConfig()), WithQueue(NewDefaultQueueConfig())) require.Error(t, err) - _, err = NewBaseExporter(exportertest.NewNopSettings(), defaultDataType, newNoopObsrepSender, + _, err = NewBaseExporter(exportertest.NewNopSettings(), defaultSignal, newNoopObsrepSender, WithMarshaler(mockRequestMarshaler), WithUnmarshaler(mockRequestUnmarshaler(&mockRequest{})), WithRetry(configretry.NewDefaultBackOffConfig()), WithRequestQueue(exporterqueue.NewDefaultConfig(), exporterqueue.NewMemoryQueueFactory[internal.Request]())) @@ -79,7 +80,7 @@ func TestBaseExporterLogging(t *testing.T) { set.Logger = zap.New(logger) rCfg := configretry.NewDefaultBackOffConfig() rCfg.Enabled = false - bs, err := NewBaseExporter(set, defaultDataType, newNoopObsrepSender, WithRetry(rCfg)) + bs, err := NewBaseExporter(set, defaultSignal, newNoopObsrepSender, WithRetry(rCfg)) require.NoError(t, err) sendErr := bs.Send(context.Background(), newErrorRequest()) require.Error(t, sendErr) diff --git a/exporter/exporterhelper/internal/batch_sender_test.go b/exporter/exporterhelper/internal/batch_sender_test.go index 53ef9451137..c9f6cc084e2 100644 --- a/exporter/exporterhelper/internal/batch_sender_test.go +++ b/exporter/exporterhelper/internal/batch_sender_test.go @@ -211,7 +211,7 @@ func TestBatchSender_Disabled(t *testing.T) { cfg := exporterbatcher.NewDefaultConfig() cfg.Enabled = false cfg.MaxSizeItems = 5 - be, err := NewBaseExporter(defaultSettings, defaultDataType, newNoopObsrepSender, + be, err := NewBaseExporter(defaultSettings, defaultSignal, newNoopObsrepSender, WithBatcher(cfg, WithRequestBatchFuncs(fakeBatchMergeFunc, fakeBatchMergeSplitFunc))) require.NotNil(t, be) require.NoError(t, err) @@ -259,7 +259,7 @@ func TestBatchSender_InvalidMergeSplitFunc(t *testing.T) { } func TestBatchSender_PostShutdown(t *testing.T) { - be, err := NewBaseExporter(defaultSettings, defaultDataType, newNoopObsrepSender, + be, err := NewBaseExporter(defaultSettings, defaultSignal, newNoopObsrepSender, WithBatcher(exporterbatcher.NewDefaultConfig(), WithRequestBatchFuncs(fakeBatchMergeFunc, fakeBatchMergeSplitFunc))) require.NotNil(t, be) @@ -322,7 +322,7 @@ func TestBatchSender_ConcurrencyLimitReached(t *testing.T) { t.Run(tt.name, func(t *testing.T) { qCfg := exporterqueue.NewDefaultConfig() qCfg.NumConsumers = 2 - be, err := NewBaseExporter(defaultSettings, defaultDataType, newNoopObsrepSender, + be, err := NewBaseExporter(defaultSettings, defaultSignal, newNoopObsrepSender, WithBatcher(tt.batcherCfg, WithRequestBatchFuncs(fakeBatchMergeFunc, fakeBatchMergeSplitFunc)), WithRequestQueue(qCfg, exporterqueue.NewMemoryQueueFactory[internal.Request]())) require.NotNil(t, be) @@ -377,7 +377,7 @@ func TestBatchSender_ConcurrencyLimitReached(t *testing.T) { func TestBatchSender_BatchBlocking(t *testing.T) { bCfg := exporterbatcher.NewDefaultConfig() bCfg.MinSizeItems = 3 - be, err := NewBaseExporter(defaultSettings, defaultDataType, newNoopObsrepSender, + be, err := NewBaseExporter(defaultSettings, defaultSignal, newNoopObsrepSender, WithBatcher(bCfg, WithRequestBatchFuncs(fakeBatchMergeFunc, fakeBatchMergeSplitFunc))) require.NotNil(t, be) require.NoError(t, err) @@ -407,7 +407,7 @@ func TestBatchSender_BatchBlocking(t *testing.T) { func TestBatchSender_BatchCancelled(t *testing.T) { bCfg := exporterbatcher.NewDefaultConfig() bCfg.MinSizeItems = 2 - be, err := NewBaseExporter(defaultSettings, defaultDataType, newNoopObsrepSender, + be, err := NewBaseExporter(defaultSettings, defaultSignal, newNoopObsrepSender, WithBatcher(bCfg, WithRequestBatchFuncs(fakeBatchMergeFunc, fakeBatchMergeSplitFunc))) require.NotNil(t, be) require.NoError(t, err) @@ -442,7 +442,7 @@ func TestBatchSender_BatchCancelled(t *testing.T) { func TestBatchSender_DrainActiveRequests(t *testing.T) { bCfg := exporterbatcher.NewDefaultConfig() bCfg.MinSizeItems = 2 - be, err := NewBaseExporter(defaultSettings, defaultDataType, newNoopObsrepSender, + be, err := NewBaseExporter(defaultSettings, defaultSignal, newNoopObsrepSender, WithBatcher(bCfg, WithRequestBatchFuncs(fakeBatchMergeFunc, fakeBatchMergeSplitFunc))) require.NotNil(t, be) require.NoError(t, err) @@ -505,7 +505,7 @@ func TestBatchSender_WithBatcherOption(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - be, err := NewBaseExporter(defaultSettings, defaultDataType, newNoopObsrepSender, tt.opts...) + be, err := NewBaseExporter(defaultSettings, defaultSignal, newNoopObsrepSender, tt.opts...) if tt.expectedErr { assert.Nil(t, be) assert.Error(t, err) @@ -518,7 +518,7 @@ func TestBatchSender_WithBatcherOption(t *testing.T) { } func TestBatchSender_UnstartedShutdown(t *testing.T) { - be, err := NewBaseExporter(defaultSettings, defaultDataType, newNoopObsrepSender, + be, err := NewBaseExporter(defaultSettings, defaultSignal, newNoopObsrepSender, WithBatcher(exporterbatcher.NewDefaultConfig(), WithRequestBatchFuncs(fakeBatchMergeFunc, fakeBatchMergeSplitFunc))) require.NoError(t, err) @@ -542,7 +542,7 @@ func TestBatchSender_ShutdownDeadlock(t *testing.T) { bCfg := exporterbatcher.NewDefaultConfig() bCfg.FlushTimeout = 10 * time.Minute // high timeout to avoid the timeout to trigger - be, err := NewBaseExporter(defaultSettings, defaultDataType, newNoopObsrepSender, + be, err := NewBaseExporter(defaultSettings, defaultSignal, newNoopObsrepSender, WithBatcher(bCfg, WithRequestBatchFuncs(blockedBatchMergeFunc, fakeBatchMergeSplitFunc))) require.NoError(t, err) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) @@ -578,7 +578,7 @@ func TestBatchSenderWithTimeout(t *testing.T) { bCfg.MinSizeItems = 10 tCfg := NewDefaultTimeoutConfig() tCfg.Timeout = 50 * time.Millisecond - be, err := NewBaseExporter(defaultSettings, defaultDataType, newNoopObsrepSender, + be, err := NewBaseExporter(defaultSettings, defaultSignal, newNoopObsrepSender, WithBatcher(bCfg, WithRequestBatchFuncs(fakeBatchMergeFunc, fakeBatchMergeSplitFunc)), WithTimeout(tCfg)) require.NoError(t, err) @@ -637,7 +637,7 @@ func TestBatchSenderTimerResetNoConflict(t *testing.T) { bCfg := exporterbatcher.NewDefaultConfig() bCfg.MinSizeItems = 8 bCfg.FlushTimeout = 50 * time.Millisecond - be, err := NewBaseExporter(defaultSettings, defaultDataType, newNoopObsrepSender, + be, err := NewBaseExporter(defaultSettings, defaultSignal, newNoopObsrepSender, WithBatcher(bCfg, WithRequestBatchFuncs(delayBatchMergeFunc, fakeBatchMergeSplitFunc))) require.NoError(t, err) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) @@ -668,7 +668,7 @@ func TestBatchSenderTimerFlush(t *testing.T) { bCfg := exporterbatcher.NewDefaultConfig() bCfg.MinSizeItems = 8 bCfg.FlushTimeout = 100 * time.Millisecond - be, err := NewBaseExporter(defaultSettings, defaultDataType, newNoopObsrepSender, + be, err := NewBaseExporter(defaultSettings, defaultSignal, newNoopObsrepSender, WithBatcher(bCfg, WithRequestBatchFuncs(fakeBatchMergeFunc, fakeBatchMergeSplitFunc))) require.NoError(t, err) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) @@ -705,7 +705,7 @@ func TestBatchSenderTimerFlush(t *testing.T) { } func queueBatchExporter(t *testing.T, batchOption Option) *BaseExporter { - be, err := NewBaseExporter(defaultSettings, defaultDataType, newNoopObsrepSender, batchOption, + be, err := NewBaseExporter(defaultSettings, defaultSignal, newNoopObsrepSender, batchOption, WithRequestQueue(exporterqueue.NewDefaultConfig(), exporterqueue.NewMemoryQueueFactory[internal.Request]())) require.NotNil(t, be) require.NoError(t, err) diff --git a/exporter/exporterhelper/internal/obsexporter.go b/exporter/exporterhelper/internal/obsexporter.go index 2bb60f13544..0805c5ac542 100644 --- a/exporter/exporterhelper/internal/obsexporter.go +++ b/exporter/exporterhelper/internal/obsexporter.go @@ -14,13 +14,14 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/exporter/exporterhelper/internal/metadata" + "go.opentelemetry.io/collector/pipeline" ) // ObsReport is a helper to add observability to an exporter. type ObsReport struct { spanNamePrefix string tracer trace.Tracer - DataType component.DataType + Signal pipeline.Signal otelAttrs []attribute.KeyValue TelemetryBuilder *metadata.TelemetryBuilder @@ -30,7 +31,7 @@ type ObsReport struct { type ObsReportSettings struct { ExporterID component.ID ExporterCreateSettings exporter.Settings - DataType component.DataType + Signal pipeline.Signal } func NewExporter(cfg ObsReportSettings) (*ObsReport, error) { @@ -42,7 +43,7 @@ func NewExporter(cfg ObsReportSettings) (*ObsReport, error) { return &ObsReport{ spanNamePrefix: ExporterPrefix + cfg.ExporterID.String(), tracer: cfg.ExporterCreateSettings.TracerProvider.Tracer(cfg.ExporterID.String()), - DataType: cfg.DataType, + Signal: cfg.Signal, otelAttrs: []attribute.KeyValue{ attribute.String(ExporterKey, cfg.ExporterID.String()), }, @@ -60,7 +61,7 @@ func (or *ObsReport) StartTracesOp(ctx context.Context) context.Context { // EndTracesOp completes the export operation that was started with startTracesOp. func (or *ObsReport) EndTracesOp(ctx context.Context, numSpans int, err error) { numSent, numFailedToSend := toNumItems(numSpans, err) - or.recordMetrics(context.WithoutCancel(ctx), component.DataTypeTraces, numSent, numFailedToSend) + or.recordMetrics(context.WithoutCancel(ctx), pipeline.SignalTraces, numSent, numFailedToSend) endSpan(ctx, err, numSent, numFailedToSend, SentSpansKey, FailedToSendSpansKey) } @@ -77,7 +78,7 @@ func (or *ObsReport) StartMetricsOp(ctx context.Context) context.Context { // If needed, report your use case in https://github.com/open-telemetry/opentelemetry-collector/issues/10592. func (or *ObsReport) EndMetricsOp(ctx context.Context, numMetricPoints int, err error) { numSent, numFailedToSend := toNumItems(numMetricPoints, err) - or.recordMetrics(context.WithoutCancel(ctx), component.DataTypeMetrics, numSent, numFailedToSend) + or.recordMetrics(context.WithoutCancel(ctx), pipeline.SignalMetrics, numSent, numFailedToSend) endSpan(ctx, err, numSent, numFailedToSend, SentMetricPointsKey, FailedToSendMetricPointsKey) } @@ -91,7 +92,7 @@ func (or *ObsReport) StartLogsOp(ctx context.Context) context.Context { // EndLogsOp completes the export operation that was started with startLogsOp. func (or *ObsReport) EndLogsOp(ctx context.Context, numLogRecords int, err error) { numSent, numFailedToSend := toNumItems(numLogRecords, err) - or.recordMetrics(context.WithoutCancel(ctx), component.DataTypeLogs, numSent, numFailedToSend) + or.recordMetrics(context.WithoutCancel(ctx), pipeline.SignalLogs, numSent, numFailedToSend) endSpan(ctx, err, numSent, numFailedToSend, SentLogRecordsKey, FailedToSendLogRecordsKey) } @@ -103,16 +104,16 @@ func (or *ObsReport) startOp(ctx context.Context, operationSuffix string) contex return ctx } -func (or *ObsReport) recordMetrics(ctx context.Context, dataType component.DataType, sent, failed int64) { +func (or *ObsReport) recordMetrics(ctx context.Context, signal pipeline.Signal, sent, failed int64) { var sentMeasure, failedMeasure metric.Int64Counter - switch dataType { - case component.DataTypeTraces: + switch signal { + case pipeline.SignalTraces: sentMeasure = or.TelemetryBuilder.ExporterSentSpans failedMeasure = or.TelemetryBuilder.ExporterSendFailedSpans - case component.DataTypeMetrics: + case pipeline.SignalMetrics: sentMeasure = or.TelemetryBuilder.ExporterSentMetricPoints failedMeasure = or.TelemetryBuilder.ExporterSendFailedMetricPoints - case component.DataTypeLogs: + case pipeline.SignalLogs: sentMeasure = or.TelemetryBuilder.ExporterSentLogRecords failedMeasure = or.TelemetryBuilder.ExporterSendFailedLogRecords } @@ -143,14 +144,14 @@ func toNumItems(numExportedItems int, err error) (int64, int64) { return int64(numExportedItems), 0 } -func (or *ObsReport) RecordEnqueueFailure(ctx context.Context, dataType component.DataType, failed int64) { +func (or *ObsReport) RecordEnqueueFailure(ctx context.Context, signal pipeline.Signal, failed int64) { var enqueueFailedMeasure metric.Int64Counter - switch dataType { - case component.DataTypeTraces: + switch signal { + case pipeline.SignalTraces: enqueueFailedMeasure = or.TelemetryBuilder.ExporterEnqueueFailedSpans - case component.DataTypeMetrics: + case pipeline.SignalMetrics: enqueueFailedMeasure = or.TelemetryBuilder.ExporterEnqueueFailedMetricPoints - case component.DataTypeLogs: + case pipeline.SignalLogs: enqueueFailedMeasure = or.TelemetryBuilder.ExporterEnqueueFailedLogRecords } diff --git a/exporter/exporterhelper/internal/queue_sender.go b/exporter/exporterhelper/internal/queue_sender.go index 60a94966336..99f63c022d5 100644 --- a/exporter/exporterhelper/internal/queue_sender.go +++ b/exporter/exporterhelper/internal/queue_sender.go @@ -112,7 +112,7 @@ func (qs *QueueSender) Start(ctx context.Context, host component.Host) error { return err } - dataTypeAttr := attribute.String(DataTypeKey, qs.obsrep.DataType.String()) + dataTypeAttr := attribute.String(DataTypeKey, qs.obsrep.Signal.String()) return multierr.Append( qs.obsrep.TelemetryBuilder.InitExporterQueueSize(func() int64 { return int64(qs.queue.Size()) }, metric.WithAttributeSet(attribute.NewSet(qs.traceAttribute, dataTypeAttr))), diff --git a/exporter/exporterhelper/internal/queue_sender_test.go b/exporter/exporterhelper/internal/queue_sender_test.go index a9dd5ab7cea..30b8f28745f 100644 --- a/exporter/exporterhelper/internal/queue_sender_test.go +++ b/exporter/exporterhelper/internal/queue_sender_test.go @@ -23,13 +23,14 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/exporter/internal" "go.opentelemetry.io/collector/exporter/internal/queue" + "go.opentelemetry.io/collector/pipeline" ) func TestQueuedRetry_StopWhileWaiting(t *testing.T) { qCfg := NewDefaultQueueConfig() qCfg.NumConsumers = 1 rCfg := configretry.NewDefaultBackOffConfig() - be, err := NewBaseExporter(defaultSettings, defaultDataType, newObservabilityConsumerSender, + be, err := NewBaseExporter(defaultSettings, defaultSignal, newObservabilityConsumerSender, WithMarshaler(mockRequestMarshaler), WithUnmarshaler(mockRequestUnmarshaler(&mockRequest{})), WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -63,7 +64,7 @@ func TestQueuedRetry_DoNotPreserveCancellation(t *testing.T) { qCfg := NewDefaultQueueConfig() qCfg.NumConsumers = 1 rCfg := configretry.NewDefaultBackOffConfig() - be, err := NewBaseExporter(defaultSettings, defaultDataType, newObservabilityConsumerSender, + be, err := NewBaseExporter(defaultSettings, defaultSignal, newObservabilityConsumerSender, WithMarshaler(mockRequestMarshaler), WithUnmarshaler(mockRequestUnmarshaler(&mockRequest{})), WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -95,7 +96,7 @@ func TestQueuedRetry_RejectOnFull(t *testing.T) { set := exportertest.NewNopSettings() logger, observed := observer.New(zap.ErrorLevel) set.Logger = zap.New(logger) - be, err := NewBaseExporter(set, defaultDataType, newNoopObsrepSender, + be, err := NewBaseExporter(set, defaultSignal, newNoopObsrepSender, WithMarshaler(mockRequestMarshaler), WithUnmarshaler(mockRequestUnmarshaler(&mockRequest{})), WithQueue(qCfg)) require.NoError(t, err) @@ -168,7 +169,7 @@ func TestQueuedRetryHappyPath(t *testing.T) { t.Cleanup(func() { require.NoError(t, tel.Shutdown(context.Background())) }) set := exporter.Settings{ID: defaultID, TelemetrySettings: tel.TelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo()} - be, err := NewBaseExporter(set, defaultDataType, newObservabilityConsumerSender, tt.queueOptions...) + be, err := NewBaseExporter(set, defaultSignal, newObservabilityConsumerSender, tt.queueOptions...) require.NoError(t, err) ocs := be.ObsrepSender.(*observabilityConsumerSender) @@ -205,7 +206,7 @@ func TestQueuedRetryHappyPath(t *testing.T) { } func TestQueuedRetry_QueueMetricsReported(t *testing.T) { - dataTypes := []component.DataType{component.DataTypeLogs, component.DataTypeTraces, component.DataTypeMetrics} + dataTypes := []pipeline.Signal{pipeline.SignalLogs, pipeline.SignalTraces, pipeline.SignalMetrics} for _, dataType := range dataTypes { tt, err := componenttest.SetupTelemetry(defaultID) require.NoError(t, err) @@ -299,7 +300,7 @@ func TestQueueRetryWithDisabledQueue(t *testing.T) { set := exportertest.NewNopSettings() logger, observed := observer.New(zap.ErrorLevel) set.Logger = zap.New(logger) - be, err := NewBaseExporter(set, component.DataTypeLogs, newObservabilityConsumerSender, tt.queueOptions...) + be, err := NewBaseExporter(set, pipeline.SignalLogs, newObservabilityConsumerSender, tt.queueOptions...) require.NoError(t, err) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) ocs := be.ObsrepSender.(*observabilityConsumerSender) @@ -323,7 +324,7 @@ func TestQueueFailedRequestDropped(t *testing.T) { set := exportertest.NewNopSettings() logger, observed := observer.New(zap.ErrorLevel) set.Logger = zap.New(logger) - be, err := NewBaseExporter(set, component.DataTypeLogs, newNoopObsrepSender, + be, err := NewBaseExporter(set, pipeline.SignalLogs, newNoopObsrepSender, WithRequestQueue(exporterqueue.NewDefaultConfig(), exporterqueue.NewMemoryQueueFactory[internal.Request]())) require.NoError(t, err) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) @@ -345,7 +346,7 @@ func TestQueuedRetryPersistenceEnabled(t *testing.T) { qCfg.StorageID = &storageID // enable persistence rCfg := configretry.NewDefaultBackOffConfig() set := exporter.Settings{ID: defaultID, TelemetrySettings: tt.TelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo()} - be, err := NewBaseExporter(set, defaultDataType, newObservabilityConsumerSender, + be, err := NewBaseExporter(set, defaultSignal, newObservabilityConsumerSender, WithMarshaler(mockRequestMarshaler), WithUnmarshaler(mockRequestUnmarshaler(&mockRequest{})), WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -371,7 +372,7 @@ func TestQueuedRetryPersistenceEnabledStorageError(t *testing.T) { qCfg.StorageID = &storageID // enable persistence rCfg := configretry.NewDefaultBackOffConfig() set := exporter.Settings{ID: defaultID, TelemetrySettings: tt.TelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo()} - be, err := NewBaseExporter(set, defaultDataType, newObservabilityConsumerSender, WithMarshaler(mockRequestMarshaler), + be, err := NewBaseExporter(set, defaultSignal, newObservabilityConsumerSender, WithMarshaler(mockRequestMarshaler), WithUnmarshaler(mockRequestUnmarshaler(&mockRequest{})), WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -395,7 +396,7 @@ func TestQueuedRetryPersistentEnabled_NoDataLossOnShutdown(t *testing.T) { rCfg.MaxElapsedTime = 0 // retry infinitely so shutdown can be triggered mockReq := newErrorRequest() - be, err := NewBaseExporter(defaultSettings, defaultDataType, newNoopObsrepSender, WithMarshaler(mockRequestMarshaler), + be, err := NewBaseExporter(defaultSettings, defaultSignal, newNoopObsrepSender, WithMarshaler(mockRequestMarshaler), WithUnmarshaler(mockRequestUnmarshaler(mockReq)), WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -419,7 +420,7 @@ func TestQueuedRetryPersistentEnabled_NoDataLossOnShutdown(t *testing.T) { // start the exporter again replacing the preserved mockRequest in the unmarshaler with a new one that doesn't fail. replacedReq := newMockRequest(1, nil) - be, err = NewBaseExporter(defaultSettings, defaultDataType, newNoopObsrepSender, WithMarshaler(mockRequestMarshaler), + be, err = NewBaseExporter(defaultSettings, defaultSignal, newNoopObsrepSender, WithMarshaler(mockRequestMarshaler), WithUnmarshaler(mockRequestUnmarshaler(replacedReq)), WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) require.NoError(t, be.Start(context.Background(), host)) diff --git a/exporter/exporterhelper/internal/retry_sender_test.go b/exporter/exporterhelper/internal/retry_sender_test.go index f4cc0f5ee0b..13d8acd0732 100644 --- a/exporter/exporterhelper/internal/retry_sender_test.go +++ b/exporter/exporterhelper/internal/retry_sender_test.go @@ -16,7 +16,6 @@ import ( "go.uber.org/zap" "go.uber.org/zap/zaptest/observer" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config/configretry" "go.opentelemetry.io/collector/consumer/consumererror" @@ -24,6 +23,7 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/exporter/internal" "go.opentelemetry.io/collector/pdata/testdata" + "go.opentelemetry.io/collector/pipeline" ) func mockRequestUnmarshaler(mr internal.Request) exporterqueue.Unmarshaler[internal.Request] { @@ -40,7 +40,7 @@ func TestQueuedRetry_DropOnPermanentError(t *testing.T) { qCfg := NewDefaultQueueConfig() rCfg := configretry.NewDefaultBackOffConfig() mockR := newMockRequest(2, consumererror.NewPermanent(errors.New("bad data"))) - be, err := NewBaseExporter(defaultSettings, defaultDataType, newObservabilityConsumerSender, + be, err := NewBaseExporter(defaultSettings, defaultSignal, newObservabilityConsumerSender, WithMarshaler(mockRequestMarshaler), WithUnmarshaler(mockRequestUnmarshaler(mockR)), WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) ocs := be.ObsrepSender.(*observabilityConsumerSender) @@ -64,7 +64,7 @@ func TestQueuedRetry_DropOnNoRetry(t *testing.T) { qCfg := NewDefaultQueueConfig() rCfg := configretry.NewDefaultBackOffConfig() rCfg.Enabled = false - be, err := NewBaseExporter(defaultSettings, defaultDataType, newObservabilityConsumerSender, WithMarshaler(mockRequestMarshaler), + be, err := NewBaseExporter(defaultSettings, defaultSignal, newObservabilityConsumerSender, WithMarshaler(mockRequestMarshaler), WithUnmarshaler(mockRequestUnmarshaler(newMockRequest(2, errors.New("transient error")))), WithQueue(qCfg), WithRetry(rCfg)) require.NoError(t, err) @@ -91,7 +91,7 @@ func TestQueuedRetry_OnError(t *testing.T) { qCfg.NumConsumers = 1 rCfg := configretry.NewDefaultBackOffConfig() rCfg.InitialInterval = 0 - be, err := NewBaseExporter(defaultSettings, defaultDataType, newObservabilityConsumerSender, + be, err := NewBaseExporter(defaultSettings, defaultSignal, newObservabilityConsumerSender, WithMarshaler(mockRequestMarshaler), WithUnmarshaler(mockRequestUnmarshaler(&mockRequest{})), WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -121,7 +121,7 @@ func TestQueuedRetry_MaxElapsedTime(t *testing.T) { rCfg := configretry.NewDefaultBackOffConfig() rCfg.InitialInterval = time.Millisecond rCfg.MaxElapsedTime = 100 * time.Millisecond - be, err := NewBaseExporter(defaultSettings, defaultDataType, newObservabilityConsumerSender, + be, err := NewBaseExporter(defaultSettings, defaultSignal, newObservabilityConsumerSender, WithMarshaler(mockRequestMarshaler), WithUnmarshaler(mockRequestUnmarshaler(&mockRequest{})), WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -169,7 +169,7 @@ func TestQueuedRetry_ThrottleError(t *testing.T) { qCfg.NumConsumers = 1 rCfg := configretry.NewDefaultBackOffConfig() rCfg.InitialInterval = 10 * time.Millisecond - be, err := NewBaseExporter(defaultSettings, defaultDataType, newObservabilityConsumerSender, + be, err := NewBaseExporter(defaultSettings, defaultSignal, newObservabilityConsumerSender, WithMarshaler(mockRequestMarshaler), WithUnmarshaler(mockRequestUnmarshaler(&mockRequest{})), WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -203,7 +203,7 @@ func TestQueuedRetry_RetryOnError(t *testing.T) { qCfg.QueueSize = 1 rCfg := configretry.NewDefaultBackOffConfig() rCfg.InitialInterval = 0 - be, err := NewBaseExporter(defaultSettings, defaultDataType, newObservabilityConsumerSender, + be, err := NewBaseExporter(defaultSettings, defaultSignal, newObservabilityConsumerSender, WithMarshaler(mockRequestMarshaler), WithUnmarshaler(mockRequestUnmarshaler(&mockRequest{})), WithRetry(rCfg), WithQueue(qCfg)) require.NoError(t, err) @@ -230,7 +230,7 @@ func TestQueuedRetry_RetryOnError(t *testing.T) { func TestQueueRetryWithNoQueue(t *testing.T) { rCfg := configretry.NewDefaultBackOffConfig() rCfg.MaxElapsedTime = time.Nanosecond // fail fast - be, err := NewBaseExporter(exportertest.NewNopSettings(), component.DataTypeLogs, newObservabilityConsumerSender, WithRetry(rCfg)) + be, err := NewBaseExporter(exportertest.NewNopSettings(), pipeline.SignalLogs, newObservabilityConsumerSender, WithRetry(rCfg)) require.NoError(t, err) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) ocs := be.ObsrepSender.(*observabilityConsumerSender) @@ -251,7 +251,7 @@ func TestQueueRetryWithDisabledRetires(t *testing.T) { set := exportertest.NewNopSettings() logger, observed := observer.New(zap.ErrorLevel) set.Logger = zap.New(logger) - be, err := NewBaseExporter(set, component.DataTypeLogs, newObservabilityConsumerSender, WithRetry(rCfg)) + be, err := NewBaseExporter(set, pipeline.SignalLogs, newObservabilityConsumerSender, WithRetry(rCfg)) require.NoError(t, err) require.NoError(t, be.Start(context.Background(), componenttest.NewNopHost())) ocs := be.ObsrepSender.(*observabilityConsumerSender) diff --git a/exporter/exporterhelper/logs.go b/exporter/exporterhelper/logs.go index 795bf91408e..f2219f4db8c 100644 --- a/exporter/exporterhelper/logs.go +++ b/exporter/exporterhelper/logs.go @@ -17,6 +17,7 @@ import ( "go.opentelemetry.io/collector/exporter/exporterqueue" "go.opentelemetry.io/collector/exporter/internal/queue" "go.opentelemetry.io/collector/pdata/plog" + "go.opentelemetry.io/collector/pipeline" ) var logsMarshaler = &plog.ProtoMarshaler{} @@ -119,7 +120,7 @@ func NewLogsRequestExporter( return nil, errNilLogsConverter } - be, err := internal.NewBaseExporter(set, component.DataTypeLogs, newLogsExporterWithObservability, options...) + be, err := internal.NewBaseExporter(set, pipeline.SignalLogs, newLogsExporterWithObservability, options...) if err != nil { return nil, err } @@ -134,7 +135,7 @@ func NewLogsRequestExporter( } sErr := be.Send(ctx, req) if errors.Is(sErr, queue.ErrQueueIsFull) { - be.Obsrep.RecordEnqueueFailure(ctx, component.DataTypeLogs, int64(req.ItemsCount())) + be.Obsrep.RecordEnqueueFailure(ctx, pipeline.SignalLogs, int64(req.ItemsCount())) } return sErr }, be.ConsumerOptions...) diff --git a/exporter/exporterhelper/metrics.go b/exporter/exporterhelper/metrics.go index f78fc2fc972..cbc76d81a54 100644 --- a/exporter/exporterhelper/metrics.go +++ b/exporter/exporterhelper/metrics.go @@ -17,6 +17,7 @@ import ( "go.opentelemetry.io/collector/exporter/exporterqueue" "go.opentelemetry.io/collector/exporter/internal/queue" "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pipeline" ) var metricsMarshaler = &pmetric.ProtoMarshaler{} @@ -119,7 +120,7 @@ func NewMetricsRequestExporter( return nil, errNilMetricsConverter } - be, err := internal.NewBaseExporter(set, component.DataTypeMetrics, newMetricsSenderWithObservability, options...) + be, err := internal.NewBaseExporter(set, pipeline.SignalMetrics, newMetricsSenderWithObservability, options...) if err != nil { return nil, err } @@ -134,7 +135,7 @@ func NewMetricsRequestExporter( } sErr := be.Send(ctx, req) if errors.Is(sErr, queue.ErrQueueIsFull) { - be.Obsrep.RecordEnqueueFailure(ctx, component.DataTypeMetrics, int64(req.ItemsCount())) + be.Obsrep.RecordEnqueueFailure(ctx, pipeline.SignalMetrics, int64(req.ItemsCount())) } return sErr }, be.ConsumerOptions...) diff --git a/exporter/exporterhelper/obsreport_test.go b/exporter/exporterhelper/obsreport_test.go index 80134bc8a62..38d34a15c23 100644 --- a/exporter/exporterhelper/obsreport_test.go +++ b/exporter/exporterhelper/obsreport_test.go @@ -13,6 +13,7 @@ import ( "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/exporter/exporterhelper/internal" + "go.opentelemetry.io/collector/pipeline" ) var exporterID = component.MustNewID("fakeExporter") @@ -29,14 +30,14 @@ func TestExportEnqueueFailure(t *testing.T) { require.NoError(t, err) logRecords := int64(7) - obsrep.RecordEnqueueFailure(context.Background(), component.DataTypeLogs, logRecords) + obsrep.RecordEnqueueFailure(context.Background(), pipeline.SignalLogs, logRecords) require.NoError(t, tt.CheckExporterEnqueueFailedLogs(logRecords)) spans := int64(12) - obsrep.RecordEnqueueFailure(context.Background(), component.DataTypeTraces, spans) + obsrep.RecordEnqueueFailure(context.Background(), pipeline.SignalTraces, spans) require.NoError(t, tt.CheckExporterEnqueueFailedTraces(spans)) metricPoints := int64(21) - obsrep.RecordEnqueueFailure(context.Background(), component.DataTypeMetrics, metricPoints) + obsrep.RecordEnqueueFailure(context.Background(), pipeline.SignalMetrics, metricPoints) require.NoError(t, tt.CheckExporterEnqueueFailedMetrics(metricPoints)) } diff --git a/exporter/exporterhelper/traces.go b/exporter/exporterhelper/traces.go index da057a861bf..32cb45fd879 100644 --- a/exporter/exporterhelper/traces.go +++ b/exporter/exporterhelper/traces.go @@ -17,6 +17,7 @@ import ( "go.opentelemetry.io/collector/exporter/exporterqueue" "go.opentelemetry.io/collector/exporter/internal/queue" "go.opentelemetry.io/collector/pdata/ptrace" + "go.opentelemetry.io/collector/pipeline" ) var tracesMarshaler = &ptrace.ProtoMarshaler{} @@ -119,7 +120,7 @@ func NewTracesRequestExporter( return nil, errNilTracesConverter } - be, err := internal.NewBaseExporter(set, component.DataTypeTraces, newTracesExporterWithObservability, options...) + be, err := internal.NewBaseExporter(set, pipeline.SignalTraces, newTracesExporterWithObservability, options...) if err != nil { return nil, err } @@ -134,7 +135,7 @@ func NewTracesRequestExporter( } sErr := be.Send(ctx, req) if errors.Is(sErr, queue.ErrQueueIsFull) { - be.Obsrep.RecordEnqueueFailure(ctx, component.DataTypeTraces, int64(req.ItemsCount())) + be.Obsrep.RecordEnqueueFailure(ctx, pipeline.SignalTraces, int64(req.ItemsCount())) } return sErr }, be.ConsumerOptions...) diff --git a/exporter/exporterprofiles/go.mod b/exporter/exporterprofiles/go.mod index c839aad6b28..b52c7beed3b 100644 --- a/exporter/exporterprofiles/go.mod +++ b/exporter/exporterprofiles/go.mod @@ -19,8 +19,10 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect go.opentelemetry.io/collector/consumer v0.109.0 // indirect go.opentelemetry.io/collector/consumer/consumerprofiles v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata v1.15.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.109.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect go.opentelemetry.io/otel/metric v1.30.0 // indirect go.opentelemetry.io/otel/trace v1.30.0 // indirect @@ -62,3 +64,9 @@ replace go.opentelemetry.io/collector/consumer => ../../consumer replace go.opentelemetry.io/collector/exporter => ../ replace go.opentelemetry.io/collector/receiver/receiverprofiles => ../../receiver/receiverprofiles + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal + +replace go.opentelemetry.io/collector/component/componentprofiles => ../../component/componentprofiles diff --git a/exporter/exporterqueue/queue.go b/exporter/exporterqueue/queue.go index f47196ba124..58e0b1eab74 100644 --- a/exporter/exporterqueue/queue.go +++ b/exporter/exporterqueue/queue.go @@ -9,6 +9,8 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/exporter/internal/queue" + "go.opentelemetry.io/collector/internal/globalsignal" + "go.opentelemetry.io/collector/pipeline" ) // ErrQueueIsFull is the error that Queue returns when full. @@ -24,7 +26,11 @@ type Queue[T any] queue.Queue[T] // Settings defines settings for creating a queue. type Settings struct { - DataType component.DataType + + // Deprecated: [v0.110.0] Use Signal instead + DataType component.DataType // nolint + + Signal pipeline.Signal ExporterSettings exporter.Settings } @@ -74,10 +80,14 @@ func NewPersistentQueueFactory[T itemsCounter](storageID *component.ID, factoryS return NewMemoryQueueFactory[T]() } return func(_ context.Context, set Settings, cfg Config) Queue[T] { + signal := set.Signal + if set.DataType.String() != "" { + signal = globalsignal.MustNewSignal(set.DataType.String()) + } return queue.NewPersistentQueue[T](queue.PersistentQueueSettings[T]{ Sizer: sizerFromConfig[T](cfg), Capacity: capacityFromConfig(cfg), - DataType: set.DataType, + Signal: signal, StorageID: *storageID, Marshaler: factorySettings.Marshaler, Unmarshaler: factorySettings.Unmarshaler, diff --git a/exporter/exportertest/contract_checker.go b/exporter/exportertest/contract_checker.go index 58c74b55118..52c85c33a0f 100644 --- a/exporter/exportertest/contract_checker.go +++ b/exporter/exportertest/contract_checker.go @@ -19,6 +19,7 @@ import ( "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/pdata/pmetric" "go.opentelemetry.io/collector/pdata/ptrace" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/receiver/receivertest" ) @@ -33,7 +34,12 @@ type CheckConsumeContractParams struct { T *testing.T NumberOfTestElements int // DataType to test for. + // + // Deprecated: [v0.110.0] Use Signal instead + // nolint DataType component.DataType + + Signal pipeline.Signal // ExporterFactory to create an exporter to be tested. ExporterFactory exporter.Factory ExporterConfig component.Config @@ -84,18 +90,18 @@ func CheckConsumeContract(params CheckConsumeContractParams) { func checkConsumeContractScenario(t *testing.T, params CheckConsumeContractParams, decisionFunc func() error, checkIfTestPassed func(*testing.T, int, requestCounter)) { mockConsumerInstance := newMockConsumer(decisionFunc) - switch params.DataType { - case component.DataTypeLogs: + switch params.Signal { + case pipeline.SignalLogs: r, err := params.ReceiverFactory.CreateLogsReceiver(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 component.DataTypeTraces: + case pipeline.SignalTraces: r, err := params.ReceiverFactory.CreateTracesReceiver(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 component.DataTypeMetrics: + case pipeline.SignalMetrics: r, err := params.ReceiverFactory.CreateMetricsReceiver(context.Background(), receivertest.NewNopSettings(), params.ReceiverConfig, &mockConsumerInstance) require.NoError(t, err) require.NoError(t, r.Start(context.Background(), componenttest.NewNopHost())) diff --git a/exporter/exportertest/contract_checker_test.go b/exporter/exportertest/contract_checker_test.go index 652f6bc5ac9..1d2ffb73314 100644 --- a/exporter/exportertest/contract_checker_test.go +++ b/exporter/exportertest/contract_checker_test.go @@ -13,6 +13,7 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/exporter/exporterhelper" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/receiver" ) @@ -109,7 +110,7 @@ func TestCheckConsumeContractLogs(t *testing.T) { params := CheckConsumeContractParams{ T: t, ExporterFactory: newMockExporterFactory(mr), - DataType: component.DataTypeLogs, + Signal: pipeline.SignalLogs, ExporterConfig: nopConfig{}, NumberOfTestElements: 10, ReceiverFactory: newMockReceiverFactory(mr), @@ -123,7 +124,7 @@ func TestCheckConsumeContractMetrics(t *testing.T) { CheckConsumeContract(CheckConsumeContractParams{ T: t, ExporterFactory: newMockExporterFactory(mr), - DataType: component.DataTypeMetrics, // Change to the appropriate data type + Signal: pipeline.SignalMetrics, // Change to the appropriate data type ExporterConfig: nopConfig{}, NumberOfTestElements: 10, ReceiverFactory: newMockReceiverFactory(mr), @@ -135,7 +136,7 @@ func TestCheckConsumeContractTraces(t *testing.T) { CheckConsumeContract(CheckConsumeContractParams{ T: t, ExporterFactory: newMockExporterFactory(mr), - DataType: component.DataTypeTraces, + Signal: pipeline.SignalTraces, ExporterConfig: nopConfig{}, NumberOfTestElements: 10, ReceiverFactory: newMockReceiverFactory(mr), diff --git a/exporter/go.mod b/exporter/go.mod index b8e888b4c4c..c52984e18f0 100644 --- a/exporter/go.mod +++ b/exporter/go.mod @@ -15,9 +15,11 @@ require ( go.opentelemetry.io/collector/exporter/exporterprofiles v0.109.0 go.opentelemetry.io/collector/extension v0.109.0 go.opentelemetry.io/collector/extension/experimental/storage v0.109.0 + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 go.opentelemetry.io/collector/pdata v1.15.0 go.opentelemetry.io/collector/pdata/pprofile v0.109.0 go.opentelemetry.io/collector/pdata/testdata v0.109.0 + go.opentelemetry.io/collector/pipeline v0.109.0 go.opentelemetry.io/collector/receiver v0.109.0 go.opentelemetry.io/otel v1.30.0 go.opentelemetry.io/otel/metric v1.30.0 @@ -40,6 +42,7 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + go.opentelemetry.io/collector/component/componentprofiles v0.109.0 // indirect go.opentelemetry.io/collector/receiver/receiverprofiles v0.109.0 // indirect golang.org/x/net v0.28.0 // indirect golang.org/x/text v0.17.0 // indirect @@ -62,6 +65,8 @@ replace go.opentelemetry.io/collector/pdata/testdata => ../pdata/testdata replace go.opentelemetry.io/collector/pdata/pprofile => ../pdata/pprofile +replace go.opentelemetry.io/collector/pipeline => ../pipeline + replace go.opentelemetry.io/collector/receiver => ../receiver retract v0.76.0 // Depends on retracted pdata v1.0.0-rc10 module @@ -77,3 +82,7 @@ replace go.opentelemetry.io/collector/consumer/consumertest => ../consumer/consu replace go.opentelemetry.io/collector/receiver/receiverprofiles => ../receiver/receiverprofiles replace go.opentelemetry.io/collector/exporter/exporterprofiles => ./exporterprofiles + +replace go.opentelemetry.io/collector/internal/globalsignal => ../internal/globalsignal + +replace go.opentelemetry.io/collector/component/componentprofiles => ../component/componentprofiles diff --git a/exporter/internal/factory.go b/exporter/internal/factory.go index 65bbe36b62f..b30f2ebdddf 100644 --- a/exporter/internal/factory.go +++ b/exporter/internal/factory.go @@ -7,6 +7,7 @@ import ( "context" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/pipeline" ) // Factory is a factory interface for exporters. @@ -17,7 +18,7 @@ type Factory interface { // CreateTracesExporter creates a TracesExporter based on this config. // If the exporter type does not support tracing, - // this function returns the error [component.ErrDataTypeIsNotSupported]. + // this function returns the error [pipeline.ErrSignalNotSupported]. CreateTracesExporter(ctx context.Context, set Settings, cfg component.Config) (Traces, error) // TracesExporterStability gets the stability level of the TracesExporter. @@ -25,7 +26,7 @@ type Factory interface { // CreateMetricsExporter creates a MetricsExporter based on this config. // If the exporter type does not support metrics, - // this function returns the error [component.ErrDataTypeIsNotSupported]. + // this function returns the error [pipeline.ErrSignalNotSupported]. CreateMetricsExporter(ctx context.Context, set Settings, cfg component.Config) (Metrics, error) // MetricsExporterStability gets the stability level of the MetricsExporter. @@ -33,7 +34,7 @@ type Factory interface { // CreateLogsExporter creates a LogsExporter based on the config. // If the exporter type does not support logs, - // this function returns the error [component.ErrDataTypeIsNotSupported]. + // this function returns the error [pipeline.ErrSignalNotSupported]. CreateLogsExporter(ctx context.Context, set Settings, cfg component.Config) (Logs, error) // LogsExporterStability gets the stability level of the LogsExporter. @@ -41,7 +42,7 @@ type Factory interface { // CreateProfilesExporter creates a ProfilesExporter based on this config. // If the exporter type does not support tracing, - // this function returns the error [component.ErrDataTypeIsNotSupported]. + // this function returns the error [pipeline.ErrSignalNotSupported]. CreateProfilesExporter(ctx context.Context, set Settings, cfg component.Config) (Profiles, error) // ProfilesExporterStability gets the stability level of the ProfilesExporter. @@ -71,7 +72,7 @@ type CreateTracesFunc func(context.Context, Settings, component.Config) (Traces, // CreateTracesExporter implements ExporterFactory.CreateTracesExporter(). func (f CreateTracesFunc) CreateTracesExporter(ctx context.Context, set Settings, cfg component.Config) (Traces, error) { if f == nil { - return nil, component.ErrDataTypeIsNotSupported + return nil, pipeline.ErrSignalNotSupported } return f(ctx, set, cfg) } @@ -82,7 +83,7 @@ type CreateMetricsFunc func(context.Context, Settings, component.Config) (Metric // CreateMetricsExporter implements ExporterFactory.CreateMetricsExporter(). func (f CreateMetricsFunc) CreateMetricsExporter(ctx context.Context, set Settings, cfg component.Config) (Metrics, error) { if f == nil { - return nil, component.ErrDataTypeIsNotSupported + return nil, pipeline.ErrSignalNotSupported } return f(ctx, set, cfg) } @@ -93,7 +94,7 @@ type CreateLogsFunc func(context.Context, Settings, component.Config) (Logs, err // CreateLogsExporter implements Factory.CreateLogsExporter(). func (f CreateLogsFunc) CreateLogsExporter(ctx context.Context, set Settings, cfg component.Config) (Logs, error) { if f == nil { - return nil, component.ErrDataTypeIsNotSupported + return nil, pipeline.ErrSignalNotSupported } return f(ctx, set, cfg) } @@ -104,7 +105,7 @@ type CreateProfilesFunc func(context.Context, Settings, component.Config) (Profi // CreateProfilesExporter implements ExporterFactory.CreateProfilesExporter(). func (f CreateProfilesFunc) CreateProfilesExporter(ctx context.Context, set Settings, cfg component.Config) (Profiles, error) { if f == nil { - return nil, component.ErrDataTypeIsNotSupported + return nil, pipeline.ErrSignalNotSupported } return f(ctx, set, cfg) } diff --git a/exporter/internal/queue/persistent_queue.go b/exporter/internal/queue/persistent_queue.go index 7dd646c6ef3..71fb910c78f 100644 --- a/exporter/internal/queue/persistent_queue.go +++ b/exporter/internal/queue/persistent_queue.go @@ -18,6 +18,7 @@ import ( "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/exporter/internal/experr" "go.opentelemetry.io/collector/extension/experimental/storage" + "go.opentelemetry.io/collector/pipeline" ) // persistentQueue provides a persistent queue implementation backed by file storage extension @@ -85,7 +86,7 @@ var ( type PersistentQueueSettings[T any] struct { Sizer Sizer[T] Capacity int64 - DataType component.DataType + Signal pipeline.Signal StorageID component.ID Marshaler func(req T) ([]byte, error) Unmarshaler func([]byte) (T, error) @@ -104,7 +105,7 @@ func NewPersistentQueue[T any](set PersistentQueueSettings[T]) Queue[T] { // Start starts the persistentQueue with the given number of consumers. func (pq *persistentQueue[T]) Start(ctx context.Context, host component.Host) error { - storageClient, err := toStorageClient(ctx, pq.set.StorageID, host, pq.set.ExporterSettings.ID, pq.set.DataType) + storageClient, err := toStorageClient(ctx, pq.set.StorageID, host, pq.set.ExporterSettings.ID, pq.set.Signal) if err != nil { return err } @@ -485,7 +486,7 @@ func (pq *persistentQueue[T]) itemDispatchingFinish(ctx context.Context, index u return nil } -func toStorageClient(ctx context.Context, storageID component.ID, host component.Host, ownerID component.ID, signal component.DataType) (storage.Client, error) { +func toStorageClient(ctx context.Context, storageID component.ID, host component.Host, ownerID component.ID, signal pipeline.Signal) (storage.Client, error) { ext, found := host.GetExtensions()[storageID] if !found { return nil, errNoStorageClient diff --git a/exporter/internal/queue/persistent_queue_test.go b/exporter/internal/queue/persistent_queue_test.go index 8c825e0d5cb..88c65de666a 100644 --- a/exporter/internal/queue/persistent_queue_test.go +++ b/exporter/internal/queue/persistent_queue_test.go @@ -24,6 +24,7 @@ import ( "go.opentelemetry.io/collector/extension/extensiontest" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/ptrace" + "go.opentelemetry.io/collector/pipeline" ) type tracesRequest struct { @@ -60,7 +61,7 @@ func createAndStartTestPersistentQueue(t *testing.T, sizer Sizer[tracesRequest], pq := NewPersistentQueue[tracesRequest](PersistentQueueSettings[tracesRequest]{ Sizer: sizer, Capacity: capacity, - DataType: component.DataTypeTraces, + Signal: pipeline.SignalTraces, StorageID: component.ID{}, Marshaler: marshalTracesRequest, Unmarshaler: unmarshalTracesRequest, @@ -81,7 +82,7 @@ func createTestPersistentQueueWithClient(client storage.Client) *persistentQueue pq := NewPersistentQueue[tracesRequest](PersistentQueueSettings[tracesRequest]{ Sizer: &RequestSizer[tracesRequest]{}, Capacity: 1000, - DataType: component.DataTypeTraces, + Signal: pipeline.SignalTraces, StorageID: component.ID{}, Marshaler: marshalTracesRequest, Unmarshaler: unmarshalTracesRequest, @@ -104,7 +105,7 @@ func createTestPersistentQueueWithCapacityLimiter(t testing.TB, ext storage.Exte pq := NewPersistentQueue[tracesRequest](PersistentQueueSettings[tracesRequest]{ Sizer: sizer, Capacity: capacity, - DataType: component.DataTypeTraces, + Signal: pipeline.SignalTraces, StorageID: component.ID{}, Marshaler: marshalTracesRequest, Unmarshaler: unmarshalTracesRequest, @@ -305,7 +306,7 @@ func TestToStorageClient(t *testing.T) { ownerID := component.MustNewID("foo_exporter") // execute - client, err := toStorageClient(context.Background(), storageID, host, ownerID, component.DataTypeTraces) + client, err := toStorageClient(context.Background(), storageID, host, ownerID, pipeline.SignalTraces) // verify if tt.expectedError != nil { @@ -335,7 +336,7 @@ func TestInvalidStorageExtensionType(t *testing.T) { ownerID := component.MustNewID("foo_exporter") // execute - client, err := toStorageClient(context.Background(), storageID, host, ownerID, component.DataTypeTraces) + client, err := toStorageClient(context.Background(), storageID, host, ownerID, pipeline.SignalTraces) // we should get an error about the extension type require.ErrorIs(t, err, errWrongExtensionType) diff --git a/exporter/loggingexporter/go.mod b/exporter/loggingexporter/go.mod index a0cf6641972..9695d59fcd6 100644 --- a/exporter/loggingexporter/go.mod +++ b/exporter/loggingexporter/go.mod @@ -31,6 +31,7 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + go.opentelemetry.io/collector/component/componentprofiles v0.109.0 // indirect go.opentelemetry.io/collector/config/configretry v1.15.0 // indirect go.opentelemetry.io/collector/consumer v0.109.0 // indirect go.opentelemetry.io/collector/consumer/consumerprofiles v0.109.0 // indirect @@ -38,7 +39,9 @@ require ( go.opentelemetry.io/collector/exporter/exporterprofiles v0.109.0 // indirect go.opentelemetry.io/collector/extension v0.109.0 // indirect go.opentelemetry.io/collector/extension/experimental/storage v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.109.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/collector/receiver v0.109.0 // indirect go.opentelemetry.io/collector/receiver/receiverprofiles v0.109.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect @@ -92,3 +95,9 @@ replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/co replace go.opentelemetry.io/collector/receiver/receiverprofiles => ../../receiver/receiverprofiles replace go.opentelemetry.io/collector/exporter/exporterprofiles => ../exporterprofiles + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal + +replace go.opentelemetry.io/collector/component/componentprofiles => ../../component/componentprofiles diff --git a/exporter/nopexporter/go.mod b/exporter/nopexporter/go.mod index a25b1a44c71..d792cb30303 100644 --- a/exporter/nopexporter/go.mod +++ b/exporter/nopexporter/go.mod @@ -28,11 +28,14 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + go.opentelemetry.io/collector/component/componentprofiles v0.109.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect go.opentelemetry.io/collector/consumer v0.109.0 // indirect go.opentelemetry.io/collector/consumer/consumerprofiles v0.109.0 // indirect go.opentelemetry.io/collector/exporter/exporterprofiles v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.109.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/collector/receiver v0.109.0 // indirect go.opentelemetry.io/collector/receiver/receiverprofiles v0.109.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect @@ -82,3 +85,9 @@ replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/co replace go.opentelemetry.io/collector/receiver/receiverprofiles => ../../receiver/receiverprofiles replace go.opentelemetry.io/collector/exporter/exporterprofiles => ../exporterprofiles + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal + +replace go.opentelemetry.io/collector/component/componentprofiles => ../../component/componentprofiles diff --git a/exporter/otlpexporter/go.mod b/exporter/otlpexporter/go.mod index 2eea2738b61..313a8a3c008 100644 --- a/exporter/otlpexporter/go.mod +++ b/exporter/otlpexporter/go.mod @@ -47,6 +47,7 @@ require ( github.com/mostynb/go-grpc-compression v1.2.3 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/client v1.15.0 // indirect + go.opentelemetry.io/collector/component/componentprofiles v0.109.0 // indirect go.opentelemetry.io/collector/config/confignet v0.109.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect go.opentelemetry.io/collector/config/internal v0.109.1-0.20240916143658-74729e731d3b // indirect @@ -58,7 +59,9 @@ require ( go.opentelemetry.io/collector/extension/experimental/storage v0.109.0 // indirect go.opentelemetry.io/collector/featuregate v1.15.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.109.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/collector/receiver v0.109.0 // indirect go.opentelemetry.io/collector/receiver/receiverprofiles v0.109.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.55.0 // indirect @@ -136,3 +139,9 @@ replace go.opentelemetry.io/collector/receiver/receiverprofiles => ../../receive replace go.opentelemetry.io/collector/exporter/exporterprofiles => ../exporterprofiles replace go.opentelemetry.io/collector/internal/globalgates => ../../internal/globalgates + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal + +replace go.opentelemetry.io/collector/component/componentprofiles => ../../component/componentprofiles diff --git a/exporter/otlphttpexporter/go.mod b/exporter/otlphttpexporter/go.mod index 52e7733bee7..5cf53187bd3 100644 --- a/exporter/otlphttpexporter/go.mod +++ b/exporter/otlphttpexporter/go.mod @@ -46,6 +46,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rs/cors v1.11.1 // indirect go.opentelemetry.io/collector/client v1.15.0 // indirect + go.opentelemetry.io/collector/component/componentprofiles v0.109.0 // indirect go.opentelemetry.io/collector/config/configauth v0.109.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect go.opentelemetry.io/collector/config/internal v0.109.1-0.20240916143658-74729e731d3b // indirect @@ -57,7 +58,9 @@ require ( go.opentelemetry.io/collector/extension/experimental/storage v0.109.0 // indirect go.opentelemetry.io/collector/featuregate v1.15.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.109.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/collector/receiver v0.109.0 // indirect go.opentelemetry.io/collector/receiver/receiverprofiles v0.109.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0 // indirect @@ -133,3 +136,9 @@ replace go.opentelemetry.io/collector/receiver/receiverprofiles => ../../receive replace go.opentelemetry.io/collector/exporter/exporterprofiles => ../exporterprofiles replace go.opentelemetry.io/collector/internal/globalgates => ../../internal/globalgates + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal + +replace go.opentelemetry.io/collector/component/componentprofiles => ../../component/componentprofiles diff --git a/extension/auth/go.mod b/extension/auth/go.mod index 026871eb7b7..c20635c7cd0 100644 --- a/extension/auth/go.mod +++ b/extension/auth/go.mod @@ -18,7 +18,9 @@ require ( github.com/google/uuid v1.6.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata v1.15.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect go.opentelemetry.io/otel/metric v1.30.0 // indirect go.opentelemetry.io/otel/sdk v1.30.0 // indirect @@ -41,3 +43,7 @@ replace go.opentelemetry.io/collector/extension => ../ replace go.opentelemetry.io/collector/pdata => ../../pdata replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal diff --git a/extension/experimental/storage/go.mod b/extension/experimental/storage/go.mod index 62d2e3e2e60..99572cfff72 100644 --- a/extension/experimental/storage/go.mod +++ b/extension/experimental/storage/go.mod @@ -10,7 +10,9 @@ require ( require ( github.com/gogo/protobuf v1.3.2 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata v1.15.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect go.opentelemetry.io/otel/metric v1.30.0 // indirect go.opentelemetry.io/otel/trace v1.30.0 // indirect @@ -31,3 +33,7 @@ replace go.opentelemetry.io/collector/component => ../../../component replace go.opentelemetry.io/collector/pdata => ../../../pdata replace go.opentelemetry.io/collector/config/configtelemetry => ../../../config/configtelemetry + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../../internal/globalsignal + +replace go.opentelemetry.io/collector/pipeline => ../../../pipeline diff --git a/extension/extensioncapabilities/go.mod b/extension/extensioncapabilities/go.mod index 7a4c8143639..4a6d18212bd 100644 --- a/extension/extensioncapabilities/go.mod +++ b/extension/extensioncapabilities/go.mod @@ -17,7 +17,9 @@ require ( github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata v1.15.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect go.opentelemetry.io/otel/metric v1.30.0 // indirect go.opentelemetry.io/otel/trace v1.30.0 // indirect @@ -41,3 +43,7 @@ replace go.opentelemetry.io/collector/confmap => ../../confmap replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry replace go.opentelemetry.io/collector/component => ../../component + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal diff --git a/extension/go.mod b/extension/go.mod index f6ea19672ff..5970c8be39c 100644 --- a/extension/go.mod +++ b/extension/go.mod @@ -16,7 +16,9 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata v1.15.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect go.opentelemetry.io/otel/metric v1.30.0 // indirect go.opentelemetry.io/otel/sdk v1.30.0 // indirect @@ -38,3 +40,7 @@ replace go.opentelemetry.io/collector/component => ../component replace go.opentelemetry.io/collector/pdata => ../pdata replace go.opentelemetry.io/collector/config/configtelemetry => ../config/configtelemetry + +replace go.opentelemetry.io/collector/pipeline => ../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../internal/globalsignal diff --git a/extension/memorylimiterextension/go.mod b/extension/memorylimiterextension/go.mod index 984be879f91..a5c7c07e983 100644 --- a/extension/memorylimiterextension/go.mod +++ b/extension/memorylimiterextension/go.mod @@ -33,7 +33,9 @@ require ( github.com/tklauser/numcpus v0.6.1 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata v1.15.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect go.opentelemetry.io/otel/metric v1.30.0 // indirect go.opentelemetry.io/otel/sdk v1.30.0 // indirect @@ -72,3 +74,7 @@ replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consume replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest replace go.opentelemetry.io/collector/component/componentstatus => ../../component/componentstatus + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal diff --git a/extension/zpagesextension/go.mod b/extension/zpagesextension/go.mod index 5ed935d0d35..085d645e487 100644 --- a/extension/zpagesextension/go.mod +++ b/extension/zpagesextension/go.mod @@ -46,7 +46,9 @@ require ( go.opentelemetry.io/collector/extension/auth v0.109.0 // indirect go.opentelemetry.io/collector/featuregate v1.15.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata v1.15.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect go.opentelemetry.io/otel/metric v1.30.0 // indirect @@ -109,3 +111,7 @@ replace go.opentelemetry.io/collector/client => ../../client replace go.opentelemetry.io/collector/component/componentstatus => ../../component/componentstatus replace go.opentelemetry.io/collector/internal/globalgates => ../../internal/globalgates + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal diff --git a/go.mod b/go.mod index 2f3a995a25b..6b8627b0ef1 100644 --- a/go.mod +++ b/go.mod @@ -52,6 +52,8 @@ require ( github.com/tklauser/numcpus v0.6.1 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect go.opentelemetry.io/otel/metric v1.30.0 // indirect go.opentelemetry.io/otel/sdk v1.30.0 // indirect @@ -92,3 +94,7 @@ retract ( replace go.opentelemetry.io/collector/pdata/pprofile => ./pdata/pprofile replace go.opentelemetry.io/collector/consumer/consumerprofiles => ./consumer/consumerprofiles + +replace go.opentelemetry.io/collector/pipeline => ./pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ./internal/globalsignal diff --git a/internal/e2e/consume_contract_test.go b/internal/e2e/consume_contract_test.go index 98beb5cd361..88ddfc3eb4d 100644 --- a/internal/e2e/consume_contract_test.go +++ b/internal/e2e/consume_contract_test.go @@ -15,6 +15,7 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/exporter/otlpexporter" "go.opentelemetry.io/collector/internal/testutil" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/receiver/otlpreceiver" ) @@ -48,7 +49,7 @@ func TestConsumeContractOtlpLogs(t *testing.T) { T: t, NumberOfTestElements: 10, ExporterFactory: otlpexporter.NewFactory(), - DataType: component.DataTypeLogs, + Signal: pipeline.SignalLogs, ExporterConfig: testExporterConfig(addr), ReceiverFactory: otlpreceiver.NewFactory(), ReceiverConfig: testReceiverConfig(addr), @@ -60,7 +61,7 @@ func TestConsumeContractOtlpTraces(t *testing.T) { exportertest.CheckConsumeContract(exportertest.CheckConsumeContractParams{ T: t, NumberOfTestElements: 10, - DataType: component.DataTypeTraces, + Signal: pipeline.SignalTraces, ExporterFactory: otlpexporter.NewFactory(), ExporterConfig: testExporterConfig(addr), ReceiverFactory: otlpreceiver.NewFactory(), @@ -74,7 +75,7 @@ func TestConsumeContractOtlpMetrics(t *testing.T) { T: t, NumberOfTestElements: 10, ExporterFactory: otlpexporter.NewFactory(), - DataType: component.DataTypeMetrics, + Signal: pipeline.SignalMetrics, ExporterConfig: testExporterConfig(addr), ReceiverFactory: otlpreceiver.NewFactory(), ReceiverConfig: testReceiverConfig(addr), diff --git a/internal/e2e/go.mod b/internal/e2e/go.mod index 26f9adfc491..72cff9287c8 100644 --- a/internal/e2e/go.mod +++ b/internal/e2e/go.mod @@ -23,6 +23,7 @@ require ( go.opentelemetry.io/collector/extension v0.109.0 go.opentelemetry.io/collector/pdata v1.15.0 go.opentelemetry.io/collector/pdata/testdata v0.109.0 + go.opentelemetry.io/collector/pipeline v0.109.0 go.opentelemetry.io/collector/receiver v0.109.0 go.opentelemetry.io/collector/receiver/otlpreceiver v0.109.0 go.opentelemetry.io/collector/service v0.109.0 @@ -84,6 +85,7 @@ require ( go.opentelemetry.io/collector/extension/extensioncapabilities v0.109.0 // indirect go.opentelemetry.io/collector/featuregate v1.15.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.109.0 // indirect go.opentelemetry.io/collector/processor v0.109.0 // indirect go.opentelemetry.io/collector/processor/processorprofiles v0.109.0 // indirect @@ -206,3 +208,7 @@ replace go.opentelemetry.io/collector/processor/processorprofiles => ../../proce replace go.opentelemetry.io/collector/connector/connectorprofiles => ../../connector/connectorprofiles replace go.opentelemetry.io/collector/exporter/exporterprofiles => ../../exporter/exporterprofiles + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../globalsignal diff --git a/internal/e2e/status_test.go b/internal/e2e/status_test.go index 6cb3fd40ce5..78ba605a1df 100644 --- a/internal/e2e/status_test.go +++ b/internal/e2e/status_test.go @@ -26,6 +26,7 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/extension" "go.opentelemetry.io/collector/internal/sharedcomponent" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/service" "go.opentelemetry.io/collector/service/extensions" @@ -100,12 +101,12 @@ func Test_ComponentStatusReporting_SharedInstance(t *testing.T) { Level: configtelemetry.LevelNone, }, }, - Pipelines: pipelines.Config{ - component.MustNewID("traces"): { + PipelinesWithPipelineID: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.NewID(component.MustNewType("test"))}, Exporters: []component.ID{component.NewID(nopType)}, }, - component.MustNewID("metrics"): { + pipeline.MustNewID("metrics"): { Receivers: []component.ID{component.NewID(component.MustNewType("test"))}, Exporters: []component.ID{component.NewID(nopType)}, }, @@ -127,7 +128,7 @@ func Test_ComponentStatusReporting_SharedInstance(t *testing.T) { for instanceID, events := range eventsReceived { pipelineIDs := "" - instanceID.AllPipelineIDs(func(id component.ID) bool { + instanceID.AllPipelineIDsWithPipelineIDs(func(id pipeline.ID) bool { pipelineIDs += id.String() + "," return true }) diff --git a/internal/iruntime/total_memory_other_test.go b/internal/iruntime/total_memory_other_test.go index 195dc1f196a..edaa4d9708e 100644 --- a/internal/iruntime/total_memory_other_test.go +++ b/internal/iruntime/total_memory_other_test.go @@ -9,10 +9,11 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestTotalMemory(t *testing.T) { totalMemory, err := TotalMemory() - assert.NoError(t, err) + require.NoError(t, err) assert.Positive(t, totalMemory) } diff --git a/otelcol/config.go b/otelcol/config.go index e622617721b..64973418b0d 100644 --- a/otelcol/config.go +++ b/otelcol/config.go @@ -119,6 +119,7 @@ func (cfg *Config) Validate() error { } // Check that all pipelines reference only configured components. + // nolint for pipelineID, pipeline := range cfg.Service.Pipelines { // Validate pipeline receiver name references. for _, ref := range pipeline.Receivers { @@ -153,5 +154,41 @@ func (cfg *Config) Validate() error { return fmt.Errorf("service::pipelines::%s: references exporter %q which is not configured", pipelineID, ref) } } + + // Check that all pipelines reference only configured components. + for pipelineID, pipeline := range cfg.Service.PipelinesWithPipelineID { + // Validate pipeline receiver name references. + for _, ref := range pipeline.Receivers { + // Check that the name referenced in the pipeline's receivers exists in the top-level receivers. + if _, ok := cfg.Receivers[ref]; ok { + continue + } + + if _, ok := cfg.Connectors[ref]; ok { + continue + } + return fmt.Errorf("service::pipelines::%s: references receiver %q which is not configured", pipelineID.String(), ref) + } + + // Validate pipeline processor name references. + for _, ref := range pipeline.Processors { + // Check that the name referenced in the pipeline's processors exists in the top-level processors. + if cfg.Processors[ref] == nil { + return fmt.Errorf("service::pipelines::%s: references processor %q which is not configured", pipelineID.String(), ref) + } + } + + // Validate pipeline exporter name references. + for _, ref := range pipeline.Exporters { + // Check that the name referenced in the pipeline's Exporters exists in the top-level Exporters. + if _, ok := cfg.Exporters[ref]; ok { + continue + } + if _, ok := cfg.Connectors[ref]; ok { + continue + } + return fmt.Errorf("service::pipelines::%s: references exporter %q which is not configured", pipelineID.String(), ref) + } + } return nil } diff --git a/otelcol/config_test.go b/otelcol/config_test.go index 1de5369759c..25b1417cd2c 100644 --- a/otelcol/config_test.go +++ b/otelcol/config_test.go @@ -13,6 +13,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config/configtelemetry" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/service" "go.opentelemetry.io/collector/service/pipelines" "go.opentelemetry.io/collector/service/telemetry" @@ -98,7 +99,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-receiver-reference", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.MustNewID("traces")] + pipe := cfg.Service.PipelinesWithPipelineID[pipeline.MustNewID("traces")] pipe.Receivers = append(pipe.Receivers, component.MustNewIDWithName("nop", "2")) return cfg }, @@ -108,7 +109,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-processor-reference", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.MustNewID("traces")] + pipe := cfg.Service.PipelinesWithPipelineID[pipeline.MustNewID("traces")] pipe.Processors = append(pipe.Processors, component.MustNewIDWithName("nop", "2")) return cfg }, @@ -118,7 +119,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-exporter-reference", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.MustNewID("traces")] + pipe := cfg.Service.PipelinesWithPipelineID[pipeline.MustNewID("traces")] pipe.Exporters = append(pipe.Exporters, component.MustNewIDWithName("nop", "2")) return cfg }, @@ -185,7 +186,7 @@ func TestConfigValidate(t *testing.T) { cfg := generateConfig() cfg.Receivers[component.MustNewID("nop2")] = &errConfig{} cfg.Connectors[component.MustNewID("nop2")] = &errConfig{} - pipe := cfg.Service.Pipelines[component.MustNewID("traces")] + pipe := cfg.Service.PipelinesWithPipelineID[pipeline.MustNewID("traces")] pipe.Receivers = append(pipe.Receivers, component.MustNewIDWithName("nop", "2")) pipe.Exporters = append(pipe.Exporters, component.MustNewIDWithName("nop", "2")) return cfg @@ -198,7 +199,7 @@ func TestConfigValidate(t *testing.T) { cfg := generateConfig() cfg.Exporters[component.MustNewID("nop2")] = &errConfig{} cfg.Connectors[component.MustNewID("nop2")] = &errConfig{} - pipe := cfg.Service.Pipelines[component.MustNewID("traces")] + pipe := cfg.Service.PipelinesWithPipelineID[pipeline.MustNewID("traces")] pipe.Receivers = append(pipe.Receivers, component.MustNewIDWithName("nop", "2")) pipe.Exporters = append(pipe.Exporters, component.MustNewIDWithName("nop", "2")) return cfg @@ -209,7 +210,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-connector-reference-as-receiver", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.MustNewID("traces")] + pipe := cfg.Service.PipelinesWithPipelineID[pipeline.MustNewID("traces")] pipe.Receivers = append(pipe.Receivers, component.MustNewIDWithName("nop", "conn2")) return cfg }, @@ -219,7 +220,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-connector-reference-as-receiver", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Service.Pipelines[component.MustNewID("traces")] + pipe := cfg.Service.PipelinesWithPipelineID[pipeline.MustNewID("traces")] pipe.Exporters = append(pipe.Exporters, component.MustNewIDWithName("nop", "conn2")) return cfg }, @@ -229,7 +230,7 @@ func TestConfigValidate(t *testing.T) { name: "invalid-service-config", cfgFn: func() *Config { cfg := generateConfig() - cfg.Service.Pipelines = nil + cfg.Service.PipelinesWithPipelineID = nil return cfg }, expected: fmt.Errorf(`service::pipelines config validation failed: %w`, errors.New(`service must have at least one pipeline`)), @@ -279,8 +280,8 @@ func generateConfig() *Config { }, }, Extensions: []component.ID{component.MustNewID("nop")}, - Pipelines: pipelines.Config{ - component.MustNewID("traces"): { + PipelinesWithPipelineID: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("nop")}, diff --git a/otelcol/factories_test.go b/otelcol/factories_test.go index 19d6fe6accc..fb0b67d1402 100644 --- a/otelcol/factories_test.go +++ b/otelcol/factories_test.go @@ -11,6 +11,7 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/extension" "go.opentelemetry.io/collector/extension/extensiontest" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/processor" "go.opentelemetry.io/collector/processor/processortest" "go.opentelemetry.io/collector/receiver" @@ -37,7 +38,7 @@ func nopFactories() (Factories, error) { factories.ExtensionModules[ext.Type()] = "go.opentelemetry.io/collector/extension/extensiontest v1.2.3" } - if factories.Receivers, err = receiver.MakeFactoryMap(receivertest.NewNopFactory(), receivertest.NewNopFactoryForType(component.DataTypeLogs)); err != nil { + if factories.Receivers, err = receiver.MakeFactoryMap(receivertest.NewNopFactory(), receivertest.NewNopFactoryForTypeWithSignal(pipeline.SignalLogs)); err != nil { return Factories{}, err } factories.ReceiverModules = make(map[component.Type]string, len(factories.Receivers)) diff --git a/otelcol/go.mod b/otelcol/go.mod index 449265ef8e1..47c7af4f3a8 100644 --- a/otelcol/go.mod +++ b/otelcol/go.mod @@ -13,6 +13,7 @@ require ( go.opentelemetry.io/collector/exporter v0.109.0 go.opentelemetry.io/collector/extension v0.109.0 go.opentelemetry.io/collector/featuregate v1.15.0 + go.opentelemetry.io/collector/pipeline v0.109.0 go.opentelemetry.io/collector/processor v0.109.0 go.opentelemetry.io/collector/receiver v0.109.0 go.opentelemetry.io/collector/service v0.109.0 @@ -71,6 +72,7 @@ require ( go.opentelemetry.io/collector/exporter/exporterprofiles v0.109.0 // indirect go.opentelemetry.io/collector/extension/extensioncapabilities v0.109.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata v1.15.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.109.0 // indirect go.opentelemetry.io/collector/pdata/testdata v0.109.0 // indirect @@ -178,3 +180,7 @@ replace go.opentelemetry.io/collector/processor/processorprofiles => ../processo replace go.opentelemetry.io/collector/connector/connectorprofiles => ../connector/connectorprofiles replace go.opentelemetry.io/collector/exporter/exporterprofiles => ../exporter/exporterprofiles + +replace go.opentelemetry.io/collector/pipeline => ../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../internal/globalsignal diff --git a/otelcol/otelcoltest/config_test.go b/otelcol/otelcoltest/config_test.go index ba259ddc663..94d8c616e94 100644 --- a/otelcol/otelcoltest/config_test.go +++ b/otelcol/otelcoltest/config_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/service/pipelines" ) @@ -48,14 +49,14 @@ func TestLoadConfig(t *testing.T) { // Verify service. require.Len(t, cfg.Service.Extensions, 1) assert.Contains(t, cfg.Service.Extensions, component.MustNewID("nop")) - require.Len(t, cfg.Service.Pipelines, 1) + require.Len(t, cfg.Service.PipelinesWithPipelineID, 1) assert.Equal(t, &pipelines.PipelineConfig{ Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("nop")}, }, - cfg.Service.Pipelines[component.MustNewID("traces")], + cfg.Service.PipelinesWithPipelineID[pipeline.MustNewID("traces")], "Did not load pipeline config correctly") } diff --git a/otelcol/otelcoltest/go.mod b/otelcol/otelcoltest/go.mod index c971bd377bb..fb4e0aad766 100644 --- a/otelcol/otelcoltest/go.mod +++ b/otelcol/otelcoltest/go.mod @@ -14,6 +14,7 @@ require ( go.opentelemetry.io/collector/exporter v0.109.0 go.opentelemetry.io/collector/extension v0.109.0 go.opentelemetry.io/collector/otelcol v0.109.0 + go.opentelemetry.io/collector/pipeline v0.109.0 go.opentelemetry.io/collector/processor v0.109.0 go.opentelemetry.io/collector/receiver v0.109.0 go.opentelemetry.io/collector/service v0.109.0 @@ -70,6 +71,7 @@ require ( go.opentelemetry.io/collector/extension/extensioncapabilities v0.109.0 // indirect go.opentelemetry.io/collector/featuregate v1.15.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata v1.15.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.109.0 // indirect go.opentelemetry.io/collector/pdata/testdata v0.109.0 // indirect @@ -193,3 +195,7 @@ replace go.opentelemetry.io/collector/processor/processorprofiles => ../../proce replace go.opentelemetry.io/collector/connector/connectorprofiles => ../../connector/connectorprofiles replace go.opentelemetry.io/collector/exporter/exporterprofiles => ../../exporter/exporterprofiles + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal diff --git a/otelcol/unmarshaler_test.go b/otelcol/unmarshaler_test.go index 3885abc38dc..436d88c0c0f 100644 --- a/otelcol/unmarshaler_test.go +++ b/otelcol/unmarshaler_test.go @@ -134,7 +134,7 @@ func TestPipelineConfigUnmarshalError(t *testing.T) { for _, tt := range testCases { t.Run(tt.name, func(t *testing.T) { - pips := new(pipelines.Config) + pips := new(pipelines.ConfigWithPipelineID) err := tt.conf.Unmarshal(&pips) require.Error(t, err) assert.Contains(t, err.Error(), tt.expectError) diff --git a/pipeline/signal.go b/pipeline/signal.go index eaa2c75b331..69b3d527952 100644 --- a/pipeline/signal.go +++ b/pipeline/signal.go @@ -4,6 +4,8 @@ package pipeline // import "go.opentelemetry.io/collector/pipeline" import ( + "errors" + "go.opentelemetry.io/collector/internal/globalsignal" ) @@ -11,6 +13,8 @@ import ( // collecting metrics, traces and logs, this can expand in the future. type Signal = globalsignal.Signal +var ErrSignalNotSupported = errors.New("telemetry type is not supported") + var ( SignalTraces = globalsignal.MustNewSignal("traces") SignalMetrics = globalsignal.MustNewSignal("metrics") diff --git a/processor/batchprocessor/go.mod b/processor/batchprocessor/go.mod index 8cfa442b63b..5a294b50f10 100644 --- a/processor/batchprocessor/go.mod +++ b/processor/batchprocessor/go.mod @@ -39,7 +39,9 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/component/componentstatus v0.109.0 // indirect go.opentelemetry.io/collector/consumer/consumerprofiles v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.109.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/collector/processor/processorprofiles v0.109.0 // indirect go.opentelemetry.io/otel/sdk v1.30.0 // indirect go.uber.org/multierr v1.11.0 // indirect @@ -82,3 +84,7 @@ replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/co replace go.opentelemetry.io/collector/component/componentstatus => ../../component/componentstatus replace go.opentelemetry.io/collector/processor/processorprofiles => ../processorprofiles + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal diff --git a/processor/go.mod b/processor/go.mod index a079c19436b..eee359cebe9 100644 --- a/processor/go.mod +++ b/processor/go.mod @@ -14,6 +14,7 @@ require ( go.opentelemetry.io/collector/pdata v1.15.0 go.opentelemetry.io/collector/pdata/pprofile v0.109.0 go.opentelemetry.io/collector/pdata/testdata v0.109.0 + go.opentelemetry.io/collector/pipeline v0.109.0 go.opentelemetry.io/collector/processor/processorprofiles v0.109.0 go.opentelemetry.io/otel v1.30.0 go.opentelemetry.io/otel/metric v1.30.0 @@ -31,6 +32,7 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/otel/sdk v1.30.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect @@ -62,3 +64,7 @@ replace go.opentelemetry.io/collector/consumer/consumertest => ../consumer/consu replace go.opentelemetry.io/collector/component/componentstatus => ../component/componentstatus replace go.opentelemetry.io/collector/processor/processorprofiles => ./processorprofiles + +replace go.opentelemetry.io/collector/pipeline => ../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../internal/globalsignal diff --git a/processor/internal/factory.go b/processor/internal/factory.go index b08a9e97d24..2f6729ca2fe 100644 --- a/processor/internal/factory.go +++ b/processor/internal/factory.go @@ -9,6 +9,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumerprofiles" + "go.opentelemetry.io/collector/pipeline" ) // Factory is a Factory interface for processors. @@ -20,7 +21,7 @@ type Factory interface { // CreateTracesProcessor creates a TracesProcessor based on this config. // If the processor type does not support traces, - // this function returns the error [component.ErrDataTypeIsNotSupported]. + // this function returns the error [pipeline.ErrSignalNotSupported]. // Implementers can assume `nextConsumer` is never nil. CreateTracesProcessor(ctx context.Context, set Settings, cfg component.Config, nextConsumer consumer.Traces) (Traces, error) @@ -29,7 +30,7 @@ type Factory interface { // CreateMetricsProcessor creates a MetricsProcessor based on this config. // If the processor type does not support metrics, - // this function returns the error [component.ErrDataTypeIsNotSupported]. + // this function returns the error [pipeline.ErrSignalNotSupported]. // Implementers can assume `nextConsumer` is never nil. CreateMetricsProcessor(ctx context.Context, set Settings, cfg component.Config, nextConsumer consumer.Metrics) (Metrics, error) @@ -38,7 +39,7 @@ type Factory interface { // CreateLogsProcessor creates a LogsProcessor based on the config. // If the processor type does not support logs, - // this function returns the error [component.ErrDataTypeIsNotSupported]. + // this function returns the error [pipeline.ErrSignalNotSupported]. // Implementers can assume `nextConsumer` is never nil. CreateLogsProcessor(ctx context.Context, set Settings, cfg component.Config, nextConsumer consumer.Logs) (Logs, error) @@ -81,7 +82,7 @@ func (f CreateTracesFunc) CreateTracesProcessor( cfg component.Config, nextConsumer consumer.Traces) (Traces, error) { if f == nil { - return nil, component.ErrDataTypeIsNotSupported + return nil, pipeline.ErrSignalNotSupported } return f(ctx, set, cfg, nextConsumer) } @@ -97,7 +98,7 @@ func (f CreateMetricsFunc) CreateMetricsProcessor( nextConsumer consumer.Metrics, ) (Metrics, error) { if f == nil { - return nil, component.ErrDataTypeIsNotSupported + return nil, pipeline.ErrSignalNotSupported } return f(ctx, set, cfg, nextConsumer) } @@ -113,7 +114,7 @@ func (f CreateLogsFunc) CreateLogsProcessor( nextConsumer consumer.Logs, ) (Logs, error) { if f == nil { - return nil, component.ErrDataTypeIsNotSupported + return nil, pipeline.ErrSignalNotSupported } return f(ctx, set, cfg, nextConsumer) } @@ -128,7 +129,7 @@ func (f CreateProfilesFunc) CreateProfilesProcessor( cfg component.Config, nextConsumer consumerprofiles.Profiles) (Profiles, error) { if f == nil { - return nil, component.ErrDataTypeIsNotSupported + return nil, pipeline.ErrSignalNotSupported } return f(ctx, set, cfg, nextConsumer) } diff --git a/processor/memorylimiterprocessor/go.mod b/processor/memorylimiterprocessor/go.mod index 00c31eb5444..f4fc2a65295 100644 --- a/processor/memorylimiterprocessor/go.mod +++ b/processor/memorylimiterprocessor/go.mod @@ -40,8 +40,10 @@ require ( go.opentelemetry.io/collector/component/componentstatus v0.109.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect go.opentelemetry.io/collector/consumer/consumerprofiles v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.109.0 // indirect go.opentelemetry.io/collector/pdata/testdata v0.109.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/collector/processor/processorprofiles v0.109.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect go.opentelemetry.io/otel/metric v1.30.0 // indirect @@ -89,3 +91,7 @@ replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/co replace go.opentelemetry.io/collector/component/componentstatus => ../../component/componentstatus replace go.opentelemetry.io/collector/processor/processorprofiles => ../processorprofiles + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal diff --git a/processor/processorhelper/obsreport.go b/processor/processorhelper/obsreport.go index dfbc2971ec5..d1445a3ee05 100644 --- a/processor/processorhelper/obsreport.go +++ b/processor/processorhelper/obsreport.go @@ -11,6 +11,7 @@ import ( "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/processor" "go.opentelemetry.io/collector/processor/internal" "go.opentelemetry.io/collector/processor/processorhelper/internal/metadata" @@ -65,18 +66,18 @@ func (or *ObsReport) recordInOut(ctx context.Context, incoming, outgoing int) { or.telemetryBuilder.ProcessorOutgoingItems.Add(ctx, int64(outgoing), metric.WithAttributes(or.otelAttrs...)) } -func (or *ObsReport) recordData(ctx context.Context, dataType component.DataType, accepted, refused, dropped int64) { +func (or *ObsReport) recordData(ctx context.Context, signal pipeline.Signal, accepted, refused, dropped int64) { var acceptedCount, refusedCount, droppedCount metric.Int64Counter - switch dataType { - case component.DataTypeTraces: + switch signal { + case pipeline.SignalTraces: acceptedCount = or.telemetryBuilder.ProcessorAcceptedSpans refusedCount = or.telemetryBuilder.ProcessorRefusedSpans droppedCount = or.telemetryBuilder.ProcessorDroppedSpans - case component.DataTypeMetrics: + case pipeline.SignalMetrics: acceptedCount = or.telemetryBuilder.ProcessorAcceptedMetricPoints refusedCount = or.telemetryBuilder.ProcessorRefusedMetricPoints droppedCount = or.telemetryBuilder.ProcessorDroppedMetricPoints - case component.DataTypeLogs: + case pipeline.SignalLogs: acceptedCount = or.telemetryBuilder.ProcessorAcceptedLogRecords refusedCount = or.telemetryBuilder.ProcessorRefusedLogRecords droppedCount = or.telemetryBuilder.ProcessorDroppedLogRecords @@ -91,61 +92,61 @@ func (or *ObsReport) recordData(ctx context.Context, dataType component.DataType // // Deprecated: [v0.110.0] Processor helper automatically calculates incoming/outgoing metrics only. func (or *ObsReport) TracesAccepted(ctx context.Context, numSpans int) { - or.recordData(ctx, component.DataTypeTraces, int64(numSpans), int64(0), int64(0)) + or.recordData(ctx, pipeline.SignalTraces, int64(numSpans), int64(0), int64(0)) } // TracesRefused reports that the trace data was refused. // // Deprecated: [v0.110.0] Processor helper automatically calculates incoming/outgoing metrics only. func (or *ObsReport) TracesRefused(ctx context.Context, numSpans int) { - or.recordData(ctx, component.DataTypeTraces, int64(0), int64(numSpans), int64(0)) + or.recordData(ctx, pipeline.SignalTraces, int64(0), int64(numSpans), int64(0)) } // TracesDropped reports that the trace data was dropped. // // Deprecated: [v0.110.0] Processor helper automatically calculates incoming/outgoing metrics only. func (or *ObsReport) TracesDropped(ctx context.Context, numSpans int) { - or.recordData(ctx, component.DataTypeTraces, int64(0), int64(0), int64(numSpans)) + or.recordData(ctx, pipeline.SignalTraces, int64(0), int64(0), int64(numSpans)) } // MetricsAccepted reports that the metrics were accepted. // // Deprecated: [v0.110.0] Processor helper automatically calculates incoming/outgoing metrics only. func (or *ObsReport) MetricsAccepted(ctx context.Context, numPoints int) { - or.recordData(ctx, component.DataTypeMetrics, int64(numPoints), int64(0), int64(0)) + or.recordData(ctx, pipeline.SignalMetrics, int64(numPoints), int64(0), int64(0)) } // MetricsRefused reports that the metrics were refused. // // Deprecated: [v0.110.0] Processor helper automatically calculates incoming/outgoing metrics only. func (or *ObsReport) MetricsRefused(ctx context.Context, numPoints int) { - or.recordData(ctx, component.DataTypeMetrics, int64(0), int64(numPoints), int64(0)) + or.recordData(ctx, pipeline.SignalMetrics, int64(0), int64(numPoints), int64(0)) } // MetricsDropped reports that the metrics were dropped. // // Deprecated: [v0.110.0] Processor helper automatically calculates incoming/outgoing metrics only. func (or *ObsReport) MetricsDropped(ctx context.Context, numPoints int) { - or.recordData(ctx, component.DataTypeMetrics, int64(0), int64(0), int64(numPoints)) + or.recordData(ctx, pipeline.SignalMetrics, int64(0), int64(0), int64(numPoints)) } // LogsAccepted reports that the logs were accepted. // // Deprecated: [v0.110.0] Processor helper automatically calculates incoming/outgoing metrics only. func (or *ObsReport) LogsAccepted(ctx context.Context, numRecords int) { - or.recordData(ctx, component.DataTypeLogs, int64(numRecords), int64(0), int64(0)) + or.recordData(ctx, pipeline.SignalLogs, int64(numRecords), int64(0), int64(0)) } // LogsRefused reports that the logs were refused. // // Deprecated: [v0.110.0] Processor helper automatically calculates incoming/outgoing metrics only. func (or *ObsReport) LogsRefused(ctx context.Context, numRecords int) { - or.recordData(ctx, component.DataTypeLogs, int64(0), int64(numRecords), int64(0)) + or.recordData(ctx, pipeline.SignalLogs, int64(0), int64(numRecords), int64(0)) } // LogsDropped reports that the logs were dropped. // // Deprecated: [v0.110.0] Processor helper automatically calculates incoming/outgoing metrics only. func (or *ObsReport) LogsDropped(ctx context.Context, numRecords int) { - or.recordData(ctx, component.DataTypeLogs, int64(0), int64(0), int64(numRecords)) + or.recordData(ctx, pipeline.SignalLogs, int64(0), int64(0), int64(numRecords)) } diff --git a/processor/processorprofiles/go.mod b/processor/processorprofiles/go.mod index 89b1a2edc21..c81052be3ff 100644 --- a/processor/processorprofiles/go.mod +++ b/processor/processorprofiles/go.mod @@ -19,8 +19,10 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect go.opentelemetry.io/collector/consumer v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata v1.15.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.109.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect go.opentelemetry.io/otel/metric v1.30.0 // indirect go.opentelemetry.io/otel/trace v1.30.0 // indirect @@ -54,3 +56,7 @@ replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consume replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest replace go.opentelemetry.io/collector/component/componentstatus => ../../component/componentstatus + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal diff --git a/processor/processortest/shutdown_verifier.go b/processor/processortest/shutdown_verifier.go index d020f6e4f8a..5561991f576 100644 --- a/processor/processortest/shutdown_verifier.go +++ b/processor/processortest/shutdown_verifier.go @@ -15,6 +15,7 @@ import ( "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/pdata/testdata" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/processor" ) @@ -22,7 +23,7 @@ func verifyTracesDoesNotProduceAfterShutdown(t *testing.T, factory processor.Fac // Create a proc and output its produce to a sink. nextSink := new(consumertest.TracesSink) proc, err := factory.CreateTracesProcessor(context.Background(), NewNopSettings(), cfg, nextSink) - if errors.Is(err, component.ErrDataTypeIsNotSupported) { + if errors.Is(err, pipeline.ErrSignalNotSupported) { return } require.NoError(t, err) @@ -46,7 +47,7 @@ func verifyLogsDoesNotProduceAfterShutdown(t *testing.T, factory processor.Facto // Create a proc and output its produce to a sink. nextSink := new(consumertest.LogsSink) proc, err := factory.CreateLogsProcessor(context.Background(), NewNopSettings(), cfg, nextSink) - if errors.Is(err, component.ErrDataTypeIsNotSupported) { + if errors.Is(err, pipeline.ErrSignalNotSupported) { return } require.NoError(t, err) @@ -70,7 +71,7 @@ func verifyMetricsDoesNotProduceAfterShutdown(t *testing.T, factory processor.Fa // Create a proc and output its produce to a sink. nextSink := new(consumertest.MetricsSink) proc, err := factory.CreateMetricsProcessor(context.Background(), NewNopSettings(), cfg, nextSink) - if errors.Is(err, component.ErrDataTypeIsNotSupported) { + if errors.Is(err, pipeline.ErrSignalNotSupported) { return } require.NoError(t, err) diff --git a/receiver/go.mod b/receiver/go.mod index 15f9281da3d..9c64f4d71a4 100644 --- a/receiver/go.mod +++ b/receiver/go.mod @@ -6,11 +6,14 @@ require ( github.com/google/uuid v1.6.0 github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.109.0 + go.opentelemetry.io/collector/component/componentprofiles v0.109.0 go.opentelemetry.io/collector/config/configtelemetry v0.109.0 go.opentelemetry.io/collector/consumer v0.109.0 go.opentelemetry.io/collector/consumer/consumerprofiles v0.109.0 go.opentelemetry.io/collector/consumer/consumertest v0.109.0 + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 go.opentelemetry.io/collector/pdata v1.15.0 + go.opentelemetry.io/collector/pipeline v0.109.0 go.opentelemetry.io/collector/receiver/receiverprofiles v0.109.0 go.opentelemetry.io/otel v1.30.0 go.opentelemetry.io/otel/metric v1.30.0 @@ -60,3 +63,9 @@ replace go.opentelemetry.io/collector/consumer/consumertest => ../consumer/consu replace go.opentelemetry.io/collector/receiver/receiverprofiles => ./receiverprofiles retract v0.76.0 // Depends on retracted pdata v1.0.0-rc10 module + +replace go.opentelemetry.io/collector/pipeline => ../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../internal/globalsignal + +replace go.opentelemetry.io/collector/component/componentprofiles => ../component/componentprofiles diff --git a/receiver/internal/factory.go b/receiver/internal/factory.go index bd7f581e382..b62a0c6ff6f 100644 --- a/receiver/internal/factory.go +++ b/receiver/internal/factory.go @@ -9,6 +9,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumerprofiles" + "go.opentelemetry.io/collector/pipeline" ) // Factory is a factory interface for receivers. @@ -20,7 +21,7 @@ type Factory interface { // CreateTracesReceiver creates a TracesReceiver based on this config. // If the receiver type does not support traces, - // this function returns the error [component.ErrDataTypeIsNotSupported]. + // 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) @@ -29,7 +30,7 @@ type Factory interface { // CreateMetricsReceiver creates a MetricsReceiver based on this config. // If the receiver type does not support metrics, - // this function returns the error [component.ErrDataTypeIsNotSupported]. + // 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) @@ -38,7 +39,7 @@ type Factory interface { // CreateLogsReceiver creates a LogsReceiver based on this config. // If the receiver type does not support logs, - // this function returns the error [component.ErrDataTypeIsNotSupported]. + // 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) @@ -79,7 +80,7 @@ func (f CreateTracesFunc) CreateTracesReceiver( cfg component.Config, nextConsumer consumer.Traces) (Traces, error) { if f == nil { - return nil, component.ErrDataTypeIsNotSupported + return nil, pipeline.ErrSignalNotSupported } return f(ctx, set, cfg, nextConsumer) } @@ -95,7 +96,7 @@ func (f CreateMetricsFunc) CreateMetricsReceiver( nextConsumer consumer.Metrics, ) (Metrics, error) { if f == nil { - return nil, component.ErrDataTypeIsNotSupported + return nil, pipeline.ErrSignalNotSupported } return f(ctx, set, cfg, nextConsumer) } @@ -111,7 +112,7 @@ func (f CreateLogsFunc) CreateLogsReceiver( nextConsumer consumer.Logs, ) (Logs, error) { if f == nil { - return nil, component.ErrDataTypeIsNotSupported + return nil, pipeline.ErrSignalNotSupported } return f(ctx, set, cfg, nextConsumer) } @@ -126,7 +127,7 @@ func (f CreateProfilesFunc) CreateProfilesReceiver( cfg component.Config, nextConsumer consumerprofiles.Profiles) (Profiles, error) { if f == nil { - return nil, component.ErrDataTypeIsNotSupported + return nil, pipeline.ErrSignalNotSupported } return f(ctx, set, cfg, nextConsumer) } diff --git a/receiver/nopreceiver/go.mod b/receiver/nopreceiver/go.mod index 9261058011e..413a42d8eca 100644 --- a/receiver/nopreceiver/go.mod +++ b/receiver/nopreceiver/go.mod @@ -28,10 +28,13 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + go.opentelemetry.io/collector/component/componentprofiles v0.109.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect go.opentelemetry.io/collector/consumer/consumerprofiles v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata v1.15.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.109.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/collector/receiver/receiverprofiles v0.109.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect go.opentelemetry.io/otel/metric v1.30.0 // indirect @@ -70,3 +73,9 @@ replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consume replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest replace go.opentelemetry.io/collector/receiver/receiverprofiles => ../receiverprofiles + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal + +replace go.opentelemetry.io/collector/component/componentprofiles => ../../component/componentprofiles diff --git a/receiver/otlpreceiver/go.mod b/receiver/otlpreceiver/go.mod index 7e82c33b361..ee139fc2614 100644 --- a/receiver/otlpreceiver/go.mod +++ b/receiver/otlpreceiver/go.mod @@ -53,6 +53,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rs/cors v1.11.1 // indirect go.opentelemetry.io/collector/client v1.15.0 // indirect + go.opentelemetry.io/collector/component/componentprofiles v0.109.0 // indirect go.opentelemetry.io/collector/config/configcompression v1.15.0 // indirect go.opentelemetry.io/collector/config/configopaque v1.15.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect @@ -60,6 +61,8 @@ require ( go.opentelemetry.io/collector/extension v0.109.0 // indirect go.opentelemetry.io/collector/extension/auth v0.109.0 // indirect go.opentelemetry.io/collector/featuregate v1.15.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.55.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect @@ -130,3 +133,9 @@ retract ( v0.76.0 // Depends on retracted pdata v1.0.0-rc10 module, use v0.76.1 v0.69.0 // Release failed, use v0.69.1 ) + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal + +replace go.opentelemetry.io/collector/component/componentprofiles => ../../component/componentprofiles diff --git a/receiver/receiverhelper/obsreport.go b/receiver/receiverhelper/obsreport.go index 790adb60f4c..c92c464ff53 100644 --- a/receiver/receiverhelper/obsreport.go +++ b/receiver/receiverhelper/obsreport.go @@ -14,6 +14,7 @@ import ( "go.opentelemetry.io/otel/trace" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/receiver/internal" "go.opentelemetry.io/collector/receiver/receiverhelper/internal/metadata" @@ -82,7 +83,7 @@ func (rec *ObsReport) EndTracesOp( numReceivedSpans int, err error, ) { - rec.endOp(receiverCtx, format, numReceivedSpans, err, component.DataTypeTraces) + rec.endOp(receiverCtx, format, numReceivedSpans, err, pipeline.SignalTraces) } // StartLogsOp is called when a request is received from a client. @@ -100,7 +101,7 @@ func (rec *ObsReport) EndLogsOp( numReceivedLogRecords int, err error, ) { - rec.endOp(receiverCtx, format, numReceivedLogRecords, err, component.DataTypeLogs) + rec.endOp(receiverCtx, format, numReceivedLogRecords, err, pipeline.SignalLogs) } // StartMetricsOp is called when a request is received from a client. @@ -118,7 +119,7 @@ func (rec *ObsReport) EndMetricsOp( numReceivedPoints int, err error, ) { - rec.endOp(receiverCtx, format, numReceivedPoints, err, component.DataTypeMetrics) + rec.endOp(receiverCtx, format, numReceivedPoints, err, pipeline.SignalMetrics) } // startOp creates the span used to trace the operation. Returning @@ -152,7 +153,7 @@ func (rec *ObsReport) endOp( format string, numReceivedItems int, err error, - dataType component.DataType, + signal pipeline.Signal, ) { numAccepted := numReceivedItems numRefused := 0 @@ -163,19 +164,19 @@ func (rec *ObsReport) endOp( span := trace.SpanFromContext(receiverCtx) - rec.recordMetrics(receiverCtx, dataType, numAccepted, numRefused) + rec.recordMetrics(receiverCtx, signal, numAccepted, numRefused) // end span according to errors if span.IsRecording() { var acceptedItemsKey, refusedItemsKey string - switch dataType { - case component.DataTypeTraces: + switch signal { + case pipeline.SignalTraces: acceptedItemsKey = internal.AcceptedSpansKey refusedItemsKey = internal.RefusedSpansKey - case component.DataTypeMetrics: + case pipeline.SignalMetrics: acceptedItemsKey = internal.AcceptedMetricPointsKey refusedItemsKey = internal.RefusedMetricPointsKey - case component.DataTypeLogs: + case pipeline.SignalLogs: acceptedItemsKey = internal.AcceptedLogRecordsKey refusedItemsKey = internal.RefusedLogRecordsKey } @@ -192,16 +193,16 @@ func (rec *ObsReport) endOp( span.End() } -func (rec *ObsReport) recordMetrics(receiverCtx context.Context, dataType component.DataType, numAccepted, numRefused int) { +func (rec *ObsReport) recordMetrics(receiverCtx context.Context, signal pipeline.Signal, numAccepted, numRefused int) { var acceptedMeasure, refusedMeasure metric.Int64Counter - switch dataType { - case component.DataTypeTraces: + switch signal { + case pipeline.SignalTraces: acceptedMeasure = rec.telemetryBuilder.ReceiverAcceptedSpans refusedMeasure = rec.telemetryBuilder.ReceiverRefusedSpans - case component.DataTypeMetrics: + case pipeline.SignalMetrics: acceptedMeasure = rec.telemetryBuilder.ReceiverAcceptedMetricPoints refusedMeasure = rec.telemetryBuilder.ReceiverRefusedMetricPoints - case component.DataTypeLogs: + case pipeline.SignalLogs: acceptedMeasure = rec.telemetryBuilder.ReceiverAcceptedLogRecords refusedMeasure = rec.telemetryBuilder.ReceiverRefusedLogRecords } diff --git a/receiver/receiverprofiles/go.mod b/receiver/receiverprofiles/go.mod index 283d25e5208..d88454196d3 100644 --- a/receiver/receiverprofiles/go.mod +++ b/receiver/receiverprofiles/go.mod @@ -19,8 +19,10 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.109.0 // indirect go.opentelemetry.io/collector/consumer v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/collector/pdata v1.15.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.109.0 // indirect + go.opentelemetry.io/collector/pipeline v0.109.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect go.opentelemetry.io/otel/metric v1.30.0 // indirect go.opentelemetry.io/otel/trace v1.30.0 // indirect @@ -52,3 +54,9 @@ replace go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile replace go.opentelemetry.io/collector/pdata => ../../pdata replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest + +replace go.opentelemetry.io/collector/pipeline => ../../pipeline + +replace go.opentelemetry.io/collector/internal/globalsignal => ../../internal/globalsignal + +replace go.opentelemetry.io/collector/component/componentprofiles => ../../component/componentprofiles diff --git a/receiver/receivertest/contract_checker.go b/receiver/receivertest/contract_checker.go index a8b95e06b03..7e24b507f48 100644 --- a/receiver/receivertest/contract_checker.go +++ b/receiver/receivertest/contract_checker.go @@ -17,6 +17,7 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componentprofiles" "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumererror" @@ -24,6 +25,7 @@ import ( "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/pdata/pmetric" "go.opentelemetry.io/collector/pdata/ptrace" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/receiver" ) @@ -54,8 +56,13 @@ type CheckConsumeContractParams struct { T *testing.T // Factory that allows to create a receiver. Factory receiver.Factory + // DataType to test for. - DataType component.DataType + // + // Deprecated: [v0.110.0] Use Signal instead. + DataType component.DataType // nolint + + Signal pipeline.Signal // Config of the receiver to use. Config component.Config // Generator that can send data to the receiver. @@ -111,12 +118,26 @@ func checkConsumeContractScenario(params CheckConsumeContractParams, decisionFun // Create and start the receiver. var receiver component.Component var err error + + s := params.Signal + // nolint switch params.DataType { + case component.DataTypeTraces: + s = pipeline.SignalTraces + case component.DataTypeMetrics: + s = pipeline.SignalMetrics case component.DataTypeLogs: + s = pipeline.SignalLogs + case componentprofiles.DataTypeProfiles: + s = componentprofiles.SignalProfiles + } + + switch s { + case pipeline.SignalLogs: receiver, err = params.Factory.CreateLogsReceiver(ctx, NewNopSettings(), params.Config, consumer) - case component.DataTypeTraces: + case pipeline.SignalTraces: receiver, err = params.Factory.CreateTracesReceiver(ctx, NewNopSettings(), params.Config, consumer) - case component.DataTypeMetrics: + case pipeline.SignalMetrics: receiver, err = params.Factory.CreateMetricsReceiver(ctx, NewNopSettings(), params.Config, consumer) default: require.FailNow(params.T, "must specify a valid DataType to test for") diff --git a/receiver/receivertest/contract_checker_test.go b/receiver/receivertest/contract_checker_test.go index 9a646dde06f..da2fab0f675 100644 --- a/receiver/receivertest/contract_checker_test.go +++ b/receiver/receivertest/contract_checker_test.go @@ -18,6 +18,7 @@ import ( "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/pdata/pmetric" "go.opentelemetry.io/collector/pdata/ptrace" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/receiver" ) @@ -239,7 +240,7 @@ func TestConsumeContract(t *testing.T) { params := CheckConsumeContractParams{ T: t, Factory: newExampleFactory(), - DataType: component.DataTypeLogs, + Signal: pipeline.SignalLogs, Config: cfg, Generator: generator, GenerateCount: logsPerTest, @@ -262,7 +263,7 @@ func TestConsumeMetricsContract(t *testing.T) { params := CheckConsumeContractParams{ T: t, Factory: newExampleFactory(), - DataType: component.DataTypeMetrics, + Signal: pipeline.SignalMetrics, Config: cfg, Generator: generator, GenerateCount: metricsPerTest, @@ -285,7 +286,7 @@ func TestConsumeTracesContract(t *testing.T) { params := CheckConsumeContractParams{ T: t, Factory: newExampleFactory(), - DataType: component.DataTypeTraces, + Signal: pipeline.SignalTraces, Config: cfg, Generator: generator, GenerateCount: spansPerTest, diff --git a/receiver/receivertest/nop_receiver.go b/receiver/receivertest/nop_receiver.go index 2e7e8e7210b..e9a265377d0 100644 --- a/receiver/receivertest/nop_receiver.go +++ b/receiver/receivertest/nop_receiver.go @@ -12,6 +12,8 @@ import ( "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumerprofiles" + "go.opentelemetry.io/collector/internal/globalsignal" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/receiver/receiverprofiles" ) @@ -41,20 +43,28 @@ func NewNopFactory() receiver.Factory { // NewNopFactoryForType returns a receiver.Factory that constructs nop receivers supporting only the // given data type. +// +// Deprecated: [v0.110.0] Use NewNopFactoryForTypeWithSignal instead func NewNopFactoryForType(dataType component.DataType) receiver.Factory { + return NewNopFactoryForTypeWithSignal(globalsignal.MustNewSignal(dataType.String())) +} + +// NewNopFactoryForTypeWithSignal returns a receiver.Factory that constructs nop receivers supporting only the +// given signal. +func NewNopFactoryForTypeWithSignal(signal pipeline.Signal) receiver.Factory { var factoryOpt receiver.FactoryOption - switch dataType { - case component.DataTypeTraces: + switch signal { + case pipeline.SignalTraces: factoryOpt = receiver.WithTraces(createTraces, component.StabilityLevelStable) - case component.DataTypeMetrics: + case pipeline.SignalMetrics: factoryOpt = receiver.WithMetrics(createMetrics, component.StabilityLevelStable) - case component.DataTypeLogs: + case pipeline.SignalLogs: factoryOpt = receiver.WithLogs(createLogs, component.StabilityLevelStable) default: - panic("unsupported data type for creating nop receiver factory: " + dataType.String()) + panic("unsupported data type for creating nop receiver factory: " + signal.String()) } - componentType := component.MustNewType(defaultComponentType.String() + "_" + dataType.String()) + componentType := component.MustNewType(defaultComponentType.String() + "_" + signal.String()) return receiver.NewFactory(componentType, func() component.Config { return &nopConfig{} }, factoryOpt) } diff --git a/receiver/scraperhelper/obsreport.go b/receiver/scraperhelper/obsreport.go index 6c950a21711..cce7f49478e 100644 --- a/receiver/scraperhelper/obsreport.go +++ b/receiver/scraperhelper/obsreport.go @@ -13,6 +13,7 @@ import ( "go.opentelemetry.io/otel/trace" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/receiver/internal" "go.opentelemetry.io/collector/receiver/scrapererror" @@ -88,7 +89,7 @@ func (s *obsReport) EndMetricsOp( // end span according to errors if span.IsRecording() { span.SetAttributes( - attribute.String(internal.FormatKey, component.DataTypeMetrics.String()), + attribute.String(internal.FormatKey, pipeline.SignalMetrics.String()), attribute.Int64(internal.ScrapedMetricPointsKey, int64(numScrapedMetrics)), attribute.Int64(internal.ErroredMetricPointsKey, int64(numErroredMetrics)), ) diff --git a/service/config.go b/service/config.go index 9c3eb4d7d74..766edad9418 100644 --- a/service/config.go +++ b/service/config.go @@ -20,12 +20,28 @@ type Config struct { Extensions extensions.Config `mapstructure:"extensions"` // Pipelines are the set of data pipelines configured for the service. - Pipelines pipelines.Config `mapstructure:"pipelines"` + // + // Deprecated: [v0.110.0] Use PipelinesWithPipelineID instead + // nolint + Pipelines pipelines.Config `mapstructure:"-"` + + // Pipelines are the set of data pipelines configured for the service. + PipelinesWithPipelineID pipelines.ConfigWithPipelineID `mapstructure:"pipelines"` } func (cfg *Config) Validate() error { - if err := cfg.Pipelines.Validate(); err != nil { - return fmt.Errorf("service::pipelines config validation failed: %w", err) + if len(cfg.Pipelines) > 0 && len(cfg.PipelinesWithPipelineID) > 0 { + return fmt.Errorf("service::pipelines config validation failed: cannot configure both Pipelines and PipelinesWithPipelineID") + } + + if len(cfg.Pipelines) > 0 { + if err := cfg.Pipelines.Validate(); err != nil { + return fmt.Errorf("service::pipelines config validation failed: %w", err) + } + } else { + if err := cfg.PipelinesWithPipelineID.Validate(); err != nil { + return fmt.Errorf("service::pipelines config validation failed: %w", err) + } } if err := cfg.Telemetry.Validate(); err != nil { diff --git a/service/config_test.go b/service/config_test.go index efe4db66d1d..2dd0246e734 100644 --- a/service/config_test.go +++ b/service/config_test.go @@ -13,6 +13,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config/configtelemetry" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/service/extensions" "go.opentelemetry.io/collector/service/pipelines" "go.opentelemetry.io/collector/service/telemetry" @@ -42,7 +43,7 @@ func TestConfigValidate(t *testing.T) { name: "duplicate-processor-reference", cfgFn: func() *Config { cfg := generateConfig() - pipe := cfg.Pipelines[component.MustNewID("traces")] + pipe := cfg.PipelinesWithPipelineID[pipeline.MustNewID("traces")] pipe.Processors = append(pipe.Processors, pipe.Processors...) return cfg }, @@ -52,14 +53,14 @@ func TestConfigValidate(t *testing.T) { name: "invalid-service-pipeline-type", cfgFn: func() *Config { cfg := generateConfig() - cfg.Pipelines[component.MustNewID("wrongtype")] = &pipelines.PipelineConfig{ + cfg.PipelinesWithPipelineID[pipeline.MustNewID("wrongtype")] = &pipelines.PipelineConfig{ Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("nop")}, } return cfg }, - expected: fmt.Errorf(`service::pipelines config validation failed: %w`, errors.New(`pipeline "wrongtype": unknown datatype "wrongtype"`)), + expected: fmt.Errorf(`service::pipelines config validation failed: %w`, errors.New(`pipeline "wrongtype": unknown signal "wrongtype"`)), }, { name: "invalid-telemetry-metric-config", @@ -100,8 +101,8 @@ func generateConfig() *Config { }, }, Extensions: extensions.Config{component.MustNewID("nop")}, - Pipelines: pipelines.Config{ - component.MustNewID("traces"): { + PipelinesWithPipelineID: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("nop")}, diff --git a/service/extensions/extensions.go b/service/extensions/extensions.go index fcefcb33f20..140d8b3b6ab 100644 --- a/service/extensions/extensions.go +++ b/service/extensions/extensions.go @@ -209,7 +209,7 @@ func New(ctx context.Context, set Settings, cfg Config, options ...Option) (*Ext } for _, extID := range cfg { - instanceID := componentstatus.NewInstanceID(extID, component.KindExtension) + instanceID := componentstatus.NewInstanceIDWithPipelineIDs(extID, component.KindExtension) extSet := extension.Settings{ ID: extID, TelemetrySettings: set.Telemetry, diff --git a/service/go.mod b/service/go.mod index 855e96c189a..6b653558f80 100644 --- a/service/go.mod +++ b/service/go.mod @@ -31,6 +31,7 @@ require ( go.opentelemetry.io/collector/pdata v1.15.0 go.opentelemetry.io/collector/pdata/pprofile v0.109.0 go.opentelemetry.io/collector/pdata/testdata v0.109.0 + go.opentelemetry.io/collector/pipeline v0.109.0 go.opentelemetry.io/collector/processor v0.109.0 go.opentelemetry.io/collector/processor/processorprofiles v0.109.0 go.opentelemetry.io/collector/receiver v0.109.0 @@ -94,6 +95,7 @@ require ( go.opentelemetry.io/collector/config/configtls v1.15.0 // indirect go.opentelemetry.io/collector/config/internal v0.109.1-0.20240916143658-74729e731d3b // indirect go.opentelemetry.io/collector/extension/auth v0.109.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0 // indirect go.opentelemetry.io/contrib/zpages v0.55.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.6.0 // indirect @@ -137,6 +139,8 @@ replace go.opentelemetry.io/collector/confmap => ../confmap replace go.opentelemetry.io/collector/config/configtelemetry => ../config/configtelemetry +replace go.opentelemetry.io/collector/pipeline => ../pipeline + replace go.opentelemetry.io/collector/processor => ../processor replace go.opentelemetry.io/collector/consumer => ../consumer @@ -186,3 +190,5 @@ replace go.opentelemetry.io/collector/processor/processorprofiles => ../processo replace go.opentelemetry.io/collector/connector/connectorprofiles => ../connector/connectorprofiles replace go.opentelemetry.io/collector/exporter/exporterprofiles => ../exporter/exporterprofiles + +replace go.opentelemetry.io/collector/internal/globalsignal => ../internal/globalsignal diff --git a/service/internal/builders/connector_test.go b/service/internal/builders/connector_test.go index 9f2fe018ba8..be756e4ae15 100644 --- a/service/internal/builders/connector_test.go +++ b/service/internal/builders/connector_test.go @@ -20,6 +20,7 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumerprofiles" "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/pipeline" ) func TestConnectorBuilder(t *testing.T) { @@ -52,7 +53,7 @@ func TestConnectorBuilder(t *testing.T) { testCases := []struct { name string id component.ID - err func(component.DataType, component.DataType) string + err func(pipeline.Signal, pipeline.Signal) string nextTraces consumer.Traces nextLogs consumer.Logs nextMetrics consumer.Metrics @@ -61,7 +62,7 @@ func TestConnectorBuilder(t *testing.T) { { name: "unknown", id: component.MustNewID("unknown"), - err: func(component.DataType, component.DataType) string { + err: func(pipeline.Signal, pipeline.Signal) string { return "connector factory not available for: \"unknown\"" }, nextTraces: consumertest.NewNop(), @@ -72,7 +73,7 @@ func TestConnectorBuilder(t *testing.T) { { name: "err", id: component.MustNewID("err"), - err: func(expType, rcvType component.DataType) string { + err: func(expType, rcvType pipeline.Signal) string { return fmt.Sprintf("connector \"err\" cannot connect from %s to %s: telemetry type is not supported", expType, rcvType) }, nextTraces: consumertest.NewNop(), @@ -83,7 +84,7 @@ func TestConnectorBuilder(t *testing.T) { { name: "all", id: component.MustNewID("all"), - err: func(component.DataType, component.DataType) string { + err: func(pipeline.Signal, pipeline.Signal) string { return "" }, nextTraces: consumertest.NewNop(), @@ -94,7 +95,7 @@ func TestConnectorBuilder(t *testing.T) { { name: "all/named", id: component.MustNewIDWithName("all", "named"), - err: func(component.DataType, component.DataType) string { + err: func(pipeline.Signal, pipeline.Signal) string { return "" }, nextTraces: consumertest.NewNop(), @@ -105,7 +106,7 @@ func TestConnectorBuilder(t *testing.T) { { name: "no next consumer", id: component.MustNewID("unknown"), - err: func(_, _ component.DataType) string { + err: func(_, _ pipeline.Signal) string { return "nil next Consumer" }, nextTraces: nil, @@ -121,7 +122,7 @@ func TestConnectorBuilder(t *testing.T) { b := NewConnector(cfgs, factories) t2t, err := b.CreateTracesToTraces(context.Background(), createConnectorSettings(tt.id), tt.nextTraces) - if expectedErr := tt.err(component.DataTypeTraces, component.DataTypeTraces); expectedErr != "" { + if expectedErr := tt.err(pipeline.SignalTraces, pipeline.SignalTraces); expectedErr != "" { assert.EqualError(t, err, expectedErr) assert.Nil(t, t2t) } else { @@ -129,7 +130,7 @@ func TestConnectorBuilder(t *testing.T) { assert.Equal(t, nopConnectorInstance, t2t) } t2m, err := b.CreateTracesToMetrics(context.Background(), createConnectorSettings(tt.id), tt.nextMetrics) - if expectedErr := tt.err(component.DataTypeTraces, component.DataTypeMetrics); expectedErr != "" { + if expectedErr := tt.err(pipeline.SignalTraces, pipeline.SignalMetrics); expectedErr != "" { assert.EqualError(t, err, expectedErr) assert.Nil(t, t2m) } else { @@ -137,7 +138,7 @@ func TestConnectorBuilder(t *testing.T) { assert.Equal(t, nopConnectorInstance, t2m) } t2l, err := b.CreateTracesToLogs(context.Background(), createConnectorSettings(tt.id), tt.nextLogs) - if expectedErr := tt.err(component.DataTypeTraces, component.DataTypeLogs); expectedErr != "" { + if expectedErr := tt.err(pipeline.SignalTraces, pipeline.SignalLogs); expectedErr != "" { assert.EqualError(t, err, expectedErr) assert.Nil(t, t2l) } else { @@ -145,7 +146,7 @@ func TestConnectorBuilder(t *testing.T) { assert.Equal(t, nopConnectorInstance, t2l) } t2p, err := b.CreateTracesToProfiles(context.Background(), createConnectorSettings(tt.id), tt.nextProfiles) - if expectedErr := tt.err(component.DataTypeTraces, componentprofiles.DataTypeProfiles); expectedErr != "" { + if expectedErr := tt.err(pipeline.SignalTraces, componentprofiles.SignalProfiles); expectedErr != "" { assert.EqualError(t, err, expectedErr) assert.Nil(t, t2p) } else { @@ -154,7 +155,7 @@ func TestConnectorBuilder(t *testing.T) { } m2t, err := b.CreateMetricsToTraces(context.Background(), createConnectorSettings(tt.id), tt.nextTraces) - if expectedErr := tt.err(component.DataTypeMetrics, component.DataTypeTraces); expectedErr != "" { + if expectedErr := tt.err(pipeline.SignalMetrics, pipeline.SignalTraces); expectedErr != "" { assert.EqualError(t, err, expectedErr) assert.Nil(t, m2t) } else { @@ -163,7 +164,7 @@ func TestConnectorBuilder(t *testing.T) { } m2m, err := b.CreateMetricsToMetrics(context.Background(), createConnectorSettings(tt.id), tt.nextMetrics) - if expectedErr := tt.err(component.DataTypeMetrics, component.DataTypeMetrics); expectedErr != "" { + if expectedErr := tt.err(pipeline.SignalMetrics, pipeline.SignalMetrics); expectedErr != "" { assert.EqualError(t, err, expectedErr) assert.Nil(t, m2m) } else { @@ -172,7 +173,7 @@ func TestConnectorBuilder(t *testing.T) { } m2l, err := b.CreateMetricsToLogs(context.Background(), createConnectorSettings(tt.id), tt.nextLogs) - if expectedErr := tt.err(component.DataTypeMetrics, component.DataTypeLogs); expectedErr != "" { + if expectedErr := tt.err(pipeline.SignalMetrics, pipeline.SignalLogs); expectedErr != "" { assert.EqualError(t, err, expectedErr) assert.Nil(t, m2l) } else { @@ -180,7 +181,7 @@ func TestConnectorBuilder(t *testing.T) { assert.Equal(t, nopConnectorInstance, m2l) } m2p, err := b.CreateMetricsToProfiles(context.Background(), createConnectorSettings(tt.id), tt.nextProfiles) - if expectedErr := tt.err(component.DataTypeMetrics, componentprofiles.DataTypeProfiles); expectedErr != "" { + if expectedErr := tt.err(pipeline.SignalMetrics, componentprofiles.SignalProfiles); expectedErr != "" { assert.EqualError(t, err, expectedErr) assert.Nil(t, m2p) } else { @@ -189,7 +190,7 @@ func TestConnectorBuilder(t *testing.T) { } l2t, err := b.CreateLogsToTraces(context.Background(), createConnectorSettings(tt.id), tt.nextTraces) - if expectedErr := tt.err(component.DataTypeLogs, component.DataTypeTraces); expectedErr != "" { + if expectedErr := tt.err(pipeline.SignalLogs, pipeline.SignalTraces); expectedErr != "" { assert.EqualError(t, err, expectedErr) assert.Nil(t, l2t) } else { @@ -198,7 +199,7 @@ func TestConnectorBuilder(t *testing.T) { } l2m, err := b.CreateLogsToMetrics(context.Background(), createConnectorSettings(tt.id), tt.nextMetrics) - if expectedErr := tt.err(component.DataTypeLogs, component.DataTypeMetrics); expectedErr != "" { + if expectedErr := tt.err(pipeline.SignalLogs, pipeline.SignalMetrics); expectedErr != "" { assert.EqualError(t, err, expectedErr) assert.Nil(t, l2m) } else { @@ -207,7 +208,7 @@ func TestConnectorBuilder(t *testing.T) { } l2l, err := b.CreateLogsToLogs(context.Background(), createConnectorSettings(tt.id), tt.nextLogs) - if expectedErr := tt.err(component.DataTypeLogs, component.DataTypeLogs); expectedErr != "" { + if expectedErr := tt.err(pipeline.SignalLogs, pipeline.SignalLogs); expectedErr != "" { assert.EqualError(t, err, expectedErr) assert.Nil(t, l2l) } else { @@ -215,7 +216,7 @@ func TestConnectorBuilder(t *testing.T) { assert.Equal(t, nopConnectorInstance, l2l) } l2p, err := b.CreateLogsToProfiles(context.Background(), createConnectorSettings(tt.id), tt.nextProfiles) - if expectedErr := tt.err(component.DataTypeLogs, componentprofiles.DataTypeProfiles); expectedErr != "" { + if expectedErr := tt.err(pipeline.SignalLogs, componentprofiles.SignalProfiles); expectedErr != "" { assert.EqualError(t, err, expectedErr) assert.Nil(t, l2p) } else { @@ -224,7 +225,7 @@ func TestConnectorBuilder(t *testing.T) { } p2t, err := b.CreateProfilesToTraces(context.Background(), createConnectorSettings(tt.id), tt.nextTraces) - if expectedErr := tt.err(componentprofiles.DataTypeProfiles, component.DataTypeTraces); expectedErr != "" { + if expectedErr := tt.err(componentprofiles.SignalProfiles, pipeline.SignalTraces); expectedErr != "" { assert.EqualError(t, err, expectedErr) assert.Nil(t, p2t) } else { @@ -232,7 +233,7 @@ func TestConnectorBuilder(t *testing.T) { assert.Equal(t, nopConnectorInstance, p2t) } p2m, err := b.CreateProfilesToMetrics(context.Background(), createConnectorSettings(tt.id), tt.nextMetrics) - if expectedErr := tt.err(componentprofiles.DataTypeProfiles, component.DataTypeMetrics); expectedErr != "" { + if expectedErr := tt.err(componentprofiles.SignalProfiles, pipeline.SignalMetrics); expectedErr != "" { assert.EqualError(t, err, expectedErr) assert.Nil(t, p2m) } else { @@ -240,7 +241,7 @@ func TestConnectorBuilder(t *testing.T) { assert.Equal(t, nopConnectorInstance, p2m) } p2l, err := b.CreateProfilesToLogs(context.Background(), createConnectorSettings(tt.id), tt.nextLogs) - if expectedErr := tt.err(componentprofiles.DataTypeProfiles, component.DataTypeLogs); expectedErr != "" { + if expectedErr := tt.err(componentprofiles.SignalProfiles, pipeline.SignalLogs); expectedErr != "" { assert.EqualError(t, err, expectedErr) assert.Nil(t, p2l) } else { @@ -248,7 +249,7 @@ func TestConnectorBuilder(t *testing.T) { assert.Equal(t, nopConnectorInstance, p2l) } p2p, err := b.CreateProfilesToProfiles(context.Background(), createConnectorSettings(tt.id), tt.nextProfiles) - if expectedErr := tt.err(componentprofiles.DataTypeProfiles, componentprofiles.DataTypeProfiles); expectedErr != "" { + if expectedErr := tt.err(componentprofiles.SignalProfiles, componentprofiles.SignalProfiles); expectedErr != "" { assert.EqualError(t, err, expectedErr) assert.Nil(t, p2p) } else { diff --git a/service/internal/components/loggers.go b/service/internal/components/loggers.go index f4178977b2d..f02d19fb082 100644 --- a/service/internal/components/loggers.go +++ b/service/internal/components/loggers.go @@ -9,6 +9,7 @@ import ( "go.uber.org/zap" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/pipeline" ) const ( @@ -21,21 +22,21 @@ const ( zapReceiverInPipeline = "receiver_in_pipeline" ) -func ReceiverLogger(logger *zap.Logger, id component.ID, dt component.DataType) *zap.Logger { +func ReceiverLogger(logger *zap.Logger, id component.ID, dt pipeline.Signal) *zap.Logger { return logger.With( zap.String(zapKindKey, strings.ToLower(component.KindReceiver.String())), zap.String(zapNameKey, id.String()), zap.String(zapDataTypeKey, dt.String())) } -func ProcessorLogger(logger *zap.Logger, id component.ID, pipelineID component.ID) *zap.Logger { +func ProcessorLogger(logger *zap.Logger, id component.ID, pipelineID pipeline.ID) *zap.Logger { return logger.With( zap.String(zapKindKey, strings.ToLower(component.KindProcessor.String())), zap.String(zapNameKey, id.String()), zap.String(zapPipelineKey, pipelineID.String())) } -func ExporterLogger(logger *zap.Logger, id component.ID, dt component.DataType) *zap.Logger { +func ExporterLogger(logger *zap.Logger, id component.ID, dt pipeline.Signal) *zap.Logger { return logger.With( zap.String(zapKindKey, strings.ToLower(component.KindExporter.String())), zap.String(zapDataTypeKey, dt.String()), @@ -48,7 +49,7 @@ func ExtensionLogger(logger *zap.Logger, id component.ID) *zap.Logger { zap.String(zapNameKey, id.String())) } -func ConnectorLogger(logger *zap.Logger, id component.ID, expDT, rcvDT component.DataType) *zap.Logger { +func ConnectorLogger(logger *zap.Logger, id component.ID, expDT, rcvDT pipeline.Signal) *zap.Logger { return logger.With( zap.String(zapKindKey, strings.ToLower(component.KindConnector.String())), zap.String(zapNameKey, id.String()), diff --git a/service/internal/graph/graph.go b/service/internal/graph/graph.go index 3adc1c568a2..4702e5832e8 100644 --- a/service/internal/graph/graph.go +++ b/service/internal/graph/graph.go @@ -31,6 +31,7 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/consumerprofiles" "go.opentelemetry.io/collector/internal/fanoutconsumer" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/service/internal/builders" "go.opentelemetry.io/collector/service/internal/capabilityconsumer" "go.opentelemetry.io/collector/service/internal/status" @@ -48,7 +49,7 @@ type Settings struct { ConnectorBuilder *builders.ConnectorBuilder // PipelineConfigs is a map of component.ID to PipelineConfig. - PipelineConfigs pipelines.Config + PipelineConfigs pipelines.ConfigWithPipelineID ReportStatus status.ServiceStatusFunc } @@ -58,7 +59,7 @@ type Graph struct { componentGraph *simple.DirectedGraph // Keep track of how nodes relate to pipelines, so we can declare edges in the graph. - pipelines map[component.ID]*pipelineNodes + pipelines map[pipeline.ID]*pipelineNodes // Keep track of status source per node instanceIDs map[int64]*componentstatus.InstanceID @@ -71,7 +72,7 @@ type Graph struct { func Build(ctx context.Context, set Settings) (*Graph, error) { pipelines := &Graph{ componentGraph: simple.NewDirectedGraph(), - pipelines: make(map[component.ID]*pipelineNodes, len(set.PipelineConfigs)), + pipelines: make(map[pipeline.ID]*pipelineNodes, len(set.PipelineConfigs)), instanceIDs: make(map[int64]*componentstatus.InstanceID), telemetry: set.Telemetry, } @@ -95,8 +96,8 @@ func (g *Graph) createNodes(set Settings) error { connectors := make(map[component.ID]struct{}) // Keep track of connectors and where they are used. (map[connectorID][]pipelineID). - connectorsAsExporter := make(map[component.ID][]component.ID) - connectorsAsReceiver := make(map[component.ID][]component.ID) + connectorsAsExporter := make(map[component.ID][]pipeline.ID) + connectorsAsReceiver := make(map[component.ID][]pipeline.ID) // Build each pipelineNodes struct for each pipeline by parsing the pipelineCfg. // Also populates the connectors, connectorsAsExporter and connectorsAsReceiver maps. @@ -140,19 +141,19 @@ func (g *Graph) createNodes(set Settings) error { } connFactory := factory.(connector.Factory) - expTypes := make(map[component.DataType]bool) + expTypes := make(map[pipeline.Signal]bool) for _, pipelineID := range connectorsAsExporter[connID] { // The presence of each key indicates how the connector is used as an exporter. // The value is initially set to false. Later we will set the value to true *if* we // confirm that there is a supported corresponding use as a receiver. - expTypes[pipelineID.Type()] = false + expTypes[pipelineID.Signal()] = false } - recTypes := make(map[component.DataType]bool) + recTypes := make(map[pipeline.Signal]bool) for _, pipelineID := range connectorsAsReceiver[connID] { // The presence of each key indicates how the connector is used as a receiver. // The value is initially set to false. Later we will set the value to true *if* we // confirm that there is a supported corresponding use as an exporter. - recTypes[pipelineID.Type()] = false + recTypes[pipelineID.Signal()] = false } for expType := range expTypes { @@ -180,7 +181,7 @@ func (g *Graph) createNodes(set Settings) error { for _, eID := range connectorsAsExporter[connID] { for _, rID := range connectorsAsReceiver[connID] { - if connectorStability(connFactory, eID.Type(), rID.Type()) == component.StabilityLevelUndefined { + if connectorStability(connFactory, eID.Signal(), rID.Signal()) == component.StabilityLevelUndefined { // Connector is not supported for this combination, but we know it is used correctly elsewhere continue } @@ -194,52 +195,52 @@ func (g *Graph) createNodes(set Settings) error { return nil } -func (g *Graph) createReceiver(pipelineID, recvID component.ID) *receiverNode { - rcvrNode := newReceiverNode(pipelineID.Type(), recvID) +func (g *Graph) createReceiver(pipelineID pipeline.ID, recvID component.ID) *receiverNode { + rcvrNode := newReceiverNode(pipelineID.Signal(), recvID) if node := g.componentGraph.Node(rcvrNode.ID()); node != nil { instanceID := g.instanceIDs[node.ID()] - g.instanceIDs[node.ID()] = instanceID.WithPipelines(pipelineID) + g.instanceIDs[node.ID()] = instanceID.WithPipelineIDs(pipelineID) return node.(*receiverNode) } g.componentGraph.AddNode(rcvrNode) - g.instanceIDs[rcvrNode.ID()] = componentstatus.NewInstanceID( + g.instanceIDs[rcvrNode.ID()] = componentstatus.NewInstanceIDWithPipelineIDs( recvID, component.KindReceiver, pipelineID, ) return rcvrNode } -func (g *Graph) createProcessor(pipelineID, procID component.ID) *processorNode { +func (g *Graph) createProcessor(pipelineID pipeline.ID, procID component.ID) *processorNode { procNode := newProcessorNode(pipelineID, procID) g.componentGraph.AddNode(procNode) - g.instanceIDs[procNode.ID()] = componentstatus.NewInstanceID( + g.instanceIDs[procNode.ID()] = componentstatus.NewInstanceIDWithPipelineIDs( procID, component.KindProcessor, pipelineID, ) return procNode } -func (g *Graph) createExporter(pipelineID, exprID component.ID) *exporterNode { - expNode := newExporterNode(pipelineID.Type(), exprID) +func (g *Graph) createExporter(pipelineID pipeline.ID, exprID component.ID) *exporterNode { + expNode := newExporterNode(pipelineID.Signal(), exprID) if node := g.componentGraph.Node(expNode.ID()); node != nil { instanceID := g.instanceIDs[expNode.ID()] - g.instanceIDs[expNode.ID()] = instanceID.WithPipelines(pipelineID) + g.instanceIDs[expNode.ID()] = instanceID.WithPipelineIDs(pipelineID) return node.(*exporterNode) } g.componentGraph.AddNode(expNode) - g.instanceIDs[expNode.ID()] = componentstatus.NewInstanceID( + g.instanceIDs[expNode.ID()] = componentstatus.NewInstanceIDWithPipelineIDs( expNode.componentID, component.KindExporter, pipelineID, ) return expNode } -func (g *Graph) createConnector(exprPipelineID, rcvrPipelineID, connID component.ID) *connectorNode { - connNode := newConnectorNode(exprPipelineID.Type(), rcvrPipelineID.Type(), connID) +func (g *Graph) createConnector(exprPipelineID, rcvrPipelineID pipeline.ID, connID component.ID) *connectorNode { + connNode := newConnectorNode(exprPipelineID.Signal(), rcvrPipelineID.Signal(), connID) if node := g.componentGraph.Node(connNode.ID()); node != nil { instanceID := g.instanceIDs[connNode.ID()] - g.instanceIDs[connNode.ID()] = instanceID.WithPipelines(exprPipelineID, rcvrPipelineID) + g.instanceIDs[connNode.ID()] = instanceID.WithPipelineIDs(exprPipelineID, rcvrPipelineID) return node.(*connectorNode) } g.componentGraph.AddNode(connNode) - g.instanceIDs[connNode.ID()] = componentstatus.NewInstanceID( + g.instanceIDs[connNode.ID()] = componentstatus.NewInstanceIDWithPipelineIDs( connNode.componentID, component.KindConnector, exprPipelineID, rcvrPipelineID, ) return connNode @@ -303,46 +304,46 @@ func (g *Graph) buildComponents(ctx context.Context, set Settings) error { capability.MutatesData = capability.MutatesData || proc.getConsumer().Capabilities().MutatesData } next := g.nextConsumers(n.ID())[0] - switch n.pipelineID.Type() { - case component.DataTypeTraces: + switch n.pipelineID.Signal() { + case pipeline.SignalTraces: cc := capabilityconsumer.NewTraces(next.(consumer.Traces), capability) n.baseConsumer = cc n.ConsumeTracesFunc = cc.ConsumeTraces - case component.DataTypeMetrics: + case pipeline.SignalMetrics: cc := capabilityconsumer.NewMetrics(next.(consumer.Metrics), capability) n.baseConsumer = cc n.ConsumeMetricsFunc = cc.ConsumeMetrics - case component.DataTypeLogs: + case pipeline.SignalLogs: cc := capabilityconsumer.NewLogs(next.(consumer.Logs), capability) n.baseConsumer = cc n.ConsumeLogsFunc = cc.ConsumeLogs - case componentprofiles.DataTypeProfiles: + case componentprofiles.SignalProfiles: cc := capabilityconsumer.NewProfiles(next.(consumerprofiles.Profiles), capability) n.baseConsumer = cc n.ConsumeProfilesFunc = cc.ConsumeProfiles } case *fanOutNode: nexts := g.nextConsumers(n.ID()) - switch n.pipelineID.Type() { - case component.DataTypeTraces: + switch n.pipelineID.Signal() { + case pipeline.SignalTraces: consumers := make([]consumer.Traces, 0, len(nexts)) for _, next := range nexts { consumers = append(consumers, next.(consumer.Traces)) } n.baseConsumer = fanoutconsumer.NewTraces(consumers) - case component.DataTypeMetrics: + case pipeline.SignalMetrics: consumers := make([]consumer.Metrics, 0, len(nexts)) for _, next := range nexts { consumers = append(consumers, next.(consumer.Metrics)) } n.baseConsumer = fanoutconsumer.NewMetrics(consumers) - case component.DataTypeLogs: + case pipeline.SignalLogs: consumers := make([]consumer.Logs, 0, len(nexts)) for _, next := range nexts { consumers = append(consumers, next.(consumer.Logs)) } n.baseConsumer = fanoutconsumer.NewLogs(consumers) - case componentprofiles.DataTypeProfiles: + case componentprofiles.SignalProfiles: consumers := make([]consumerprofiles.Profiles, 0, len(nexts)) for _, next := range nexts { consumers = append(consumers, next.(consumerprofiles.Profiles)) @@ -477,18 +478,12 @@ func (g *Graph) ShutdownAll(ctx context.Context, reporter status.Reporter) error return errs } -// Deprecated: [0.79.0] This function will be removed in the future. -// Several components in the contrib repository use this function so it cannot be removed -// before those cases are removed. In most cases, use of this function can be replaced by a -// connector. See https://github.com/open-telemetry/opentelemetry-collector/issues/7370 and -// https://github.com/open-telemetry/opentelemetry-collector/pull/7390#issuecomment-1483710184 -// for additional information. -func (g *Graph) GetExporters() map[component.DataType]map[component.ID]component.Component { - exportersMap := make(map[component.DataType]map[component.ID]component.Component) - exportersMap[component.DataTypeTraces] = make(map[component.ID]component.Component) - exportersMap[component.DataTypeMetrics] = make(map[component.ID]component.Component) - exportersMap[component.DataTypeLogs] = make(map[component.ID]component.Component) - exportersMap[componentprofiles.DataTypeProfiles] = make(map[component.ID]component.Component) +func (g *Graph) GetExporters() map[pipeline.Signal]map[component.ID]component.Component { + exportersMap := make(map[pipeline.Signal]map[component.ID]component.Component) + exportersMap[pipeline.SignalTraces] = make(map[component.ID]component.Component) + exportersMap[pipeline.SignalMetrics] = make(map[component.ID]component.Component) + exportersMap[pipeline.SignalLogs] = make(map[component.ID]component.Component) + exportersMap[componentprofiles.SignalProfiles] = make(map[component.ID]component.Component) for _, pg := range g.pipelines { for _, expNode := range pg.exporters { @@ -531,7 +526,7 @@ func cycleErr(err error, cycles [][]graph.Node) error { for _, node := range cycle { switch n := node.(type) { case *processorNode: - componentDetails = append(componentDetails, fmt.Sprintf("processor %q in pipeline %q", n.componentID, n.pipelineID)) + componentDetails = append(componentDetails, fmt.Sprintf("processor %q in pipeline %q", n.componentID, n.pipelineID.String())) case *connectorNode: componentDetails = append(componentDetails, fmt.Sprintf("connector %q (%s to %s)", n.componentID, n.exprPipelineType, n.rcvrPipelineType)) default: @@ -541,50 +536,50 @@ func cycleErr(err error, cycles [][]graph.Node) error { return fmt.Errorf("cycle detected: %s", strings.Join(componentDetails, " -> ")) } -func connectorStability(f connector.Factory, expType, recType component.Type) component.StabilityLevel { +func connectorStability(f connector.Factory, expType, recType pipeline.Signal) component.StabilityLevel { switch expType { - case component.DataTypeTraces: + case pipeline.SignalTraces: switch recType { - case component.DataTypeTraces: + case pipeline.SignalTraces: return f.TracesToTracesStability() - case component.DataTypeMetrics: + case pipeline.SignalMetrics: return f.TracesToMetricsStability() - case component.DataTypeLogs: + case pipeline.SignalLogs: return f.TracesToLogsStability() - case componentprofiles.DataTypeProfiles: + case componentprofiles.SignalProfiles: return f.TracesToProfilesStability() } - case component.DataTypeMetrics: + case pipeline.SignalMetrics: switch recType { - case component.DataTypeTraces: + case pipeline.SignalTraces: return f.MetricsToTracesStability() - case component.DataTypeMetrics: + case pipeline.SignalMetrics: return f.MetricsToMetricsStability() - case component.DataTypeLogs: + case pipeline.SignalLogs: return f.MetricsToLogsStability() - case componentprofiles.DataTypeProfiles: + case componentprofiles.SignalProfiles: return f.MetricsToProfilesStability() } - case component.DataTypeLogs: + case pipeline.SignalLogs: switch recType { - case component.DataTypeTraces: + case pipeline.SignalTraces: return f.LogsToTracesStability() - case component.DataTypeMetrics: + case pipeline.SignalMetrics: return f.LogsToMetricsStability() - case component.DataTypeLogs: + case pipeline.SignalLogs: return f.LogsToLogsStability() - case componentprofiles.DataTypeProfiles: + case componentprofiles.SignalProfiles: return f.LogsToProfilesStability() } - case componentprofiles.DataTypeProfiles: + case componentprofiles.SignalProfiles: switch recType { - case component.DataTypeTraces: + case pipeline.SignalTraces: return f.ProfilesToTracesStability() - case component.DataTypeMetrics: + case pipeline.SignalMetrics: return f.ProfilesToMetricsStability() - case component.DataTypeLogs: + case pipeline.SignalLogs: return f.ProfilesToLogsStability() - case componentprofiles.DataTypeProfiles: + case componentprofiles.SignalProfiles: return f.ProfilesToProfilesStability() } } diff --git a/service/internal/graph/graph_test.go b/service/internal/graph/graph_test.go index a6e636229fe..58cab24f25a 100644 --- a/service/internal/graph/graph_test.go +++ b/service/internal/graph/graph_test.go @@ -29,6 +29,7 @@ import ( "go.opentelemetry.io/collector/exporter/exporterprofiles" "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/pdata/testdata" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/processor" "go.opentelemetry.io/collector/processor/processorprofiles" "go.opentelemetry.io/collector/processor/processortest" @@ -231,28 +232,28 @@ func TestGraphStartStopComponentError(t *testing.T) { func TestConnectorPipelinesGraph(t *testing.T) { tests := []struct { name string - pipelineConfigs pipelines.Config + pipelineConfigs pipelines.ConfigWithPipelineID expectedPerExporter int // requires symmetry in Pipelines }{ { name: "pipelines_simple.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewID("traces"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("metrics"): { + pipeline.MustNewID("metrics"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("logs"): { + pipeline.MustNewID("logs"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("profiles"): { + pipeline.MustNewID("profiles"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -262,23 +263,23 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_simple_mutate.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewID("traces"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("metrics"): { + pipeline.MustNewID("metrics"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("logs"): { + pipeline.MustNewID("logs"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("profiles"): { + pipeline.MustNewID("profiles"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -288,23 +289,23 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_simple_multi_proc.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewID("traces"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor"), component.MustNewIDWithName("exampleprocessor", "mutate")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("metrics"): { + pipeline.MustNewID("metrics"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor"), component.MustNewIDWithName("exampleprocessor", "mutate")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("logs"): { + pipeline.MustNewID("logs"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor"), component.MustNewIDWithName("exampleprocessor", "mutate")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("profiles"): { + pipeline.MustNewID("profiles"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor"), component.MustNewIDWithName("exampleprocessor", "mutate")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -314,20 +315,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_simple_no_proc.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewID("traces"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("metrics"): { + pipeline.MustNewID("metrics"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("logs"): { + pipeline.MustNewID("logs"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("profiles"): { + pipeline.MustNewID("profiles"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, @@ -336,23 +337,23 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_multi.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewID("traces"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate"), component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")}, }, - component.MustNewID("metrics"): { + pipeline.MustNewID("metrics"): { Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate"), component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")}, }, - component.MustNewID("logs"): { + pipeline.MustNewID("logs"): { Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate"), component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")}, }, - component.MustNewID("profiles"): { + pipeline.MustNewID("profiles"): { Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate"), component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")}, @@ -362,20 +363,20 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_multi_no_proc.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewID("traces"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")}, Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")}, }, - component.MustNewID("metrics"): { + pipeline.MustNewID("metrics"): { Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")}, Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")}, }, - component.MustNewID("logs"): { + pipeline.MustNewID("logs"): { Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")}, Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")}, }, - component.MustNewID("profiles"): { + pipeline.MustNewID("profiles"): { Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")}, Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")}, }, @@ -384,40 +385,40 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "multi_pipeline_receivers_and_exporters.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewID("traces"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewIDWithName("traces", "1"): { + pipeline.MustNewIDWithName("traces", "1"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("metrics"): { + pipeline.MustNewID("metrics"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewIDWithName("metrics", "1"): { + pipeline.MustNewIDWithName("metrics", "1"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("logs"): { + pipeline.MustNewID("logs"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewIDWithName("logs", "1"): { + pipeline.MustNewIDWithName("logs", "1"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("profiles"): { + pipeline.MustNewID("profiles"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewIDWithName("profiles", "1"): { + pipeline.MustNewIDWithName("profiles", "1"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, @@ -426,13 +427,13 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_conn_simple_traces.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewIDWithName("traces", "in"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("traces", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.MustNewIDWithName("traces", "out"): { + pipeline.MustNewIDWithName("traces", "out"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -442,13 +443,13 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_conn_simple_metrics.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewIDWithName("metrics", "in"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("metrics", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.MustNewIDWithName("metrics", "out"): { + pipeline.MustNewIDWithName("metrics", "out"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -458,13 +459,13 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_conn_simple_logs.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewIDWithName("logs", "in"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("logs", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.MustNewIDWithName("logs", "out"): { + pipeline.MustNewIDWithName("logs", "out"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -474,13 +475,13 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_conn_simple_profiles.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewIDWithName("profiles", "in"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("profiles", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.MustNewIDWithName("profiles", "out"): { + pipeline.MustNewIDWithName("profiles", "out"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -490,23 +491,23 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_conn_fork_merge_traces.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewIDWithName("traces", "in"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("traces", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.MustNewIDWithName("traces", "type0"): { + pipeline.MustNewIDWithName("traces", "type0"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, }, - component.MustNewIDWithName("traces", "type1"): { + pipeline.MustNewIDWithName("traces", "type1"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, }, - component.MustNewIDWithName("traces", "out"): { + pipeline.MustNewIDWithName("traces", "out"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -516,23 +517,23 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_conn_fork_merge_metrics.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewIDWithName("metrics", "in"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("metrics", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.MustNewIDWithName("metrics", "type0"): { + pipeline.MustNewIDWithName("metrics", "type0"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, }, - component.MustNewIDWithName("metrics", "type1"): { + pipeline.MustNewIDWithName("metrics", "type1"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, }, - component.MustNewIDWithName("metrics", "out"): { + pipeline.MustNewIDWithName("metrics", "out"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -542,23 +543,23 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_conn_fork_merge_logs.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewIDWithName("logs", "in"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("logs", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.MustNewIDWithName("logs", "type0"): { + pipeline.MustNewIDWithName("logs", "type0"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, }, - component.MustNewIDWithName("logs", "type1"): { + pipeline.MustNewIDWithName("logs", "type1"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, }, - component.MustNewIDWithName("logs", "out"): { + pipeline.MustNewIDWithName("logs", "out"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -568,23 +569,23 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_conn_fork_merge_profiles.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewIDWithName("profiles", "in"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("profiles", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.MustNewIDWithName("profiles", "type0"): { + pipeline.MustNewIDWithName("profiles", "type0"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, }, - component.MustNewIDWithName("profiles", "type1"): { + pipeline.MustNewIDWithName("profiles", "type1"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, }, - component.MustNewIDWithName("profiles", "out"): { + pipeline.MustNewIDWithName("profiles", "out"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -594,23 +595,23 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_conn_translate_from_traces.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewID("traces"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleconnector")}, }, - component.MustNewID("metrics"): { + pipeline.MustNewID("metrics"): { Receivers: []component.ID{component.MustNewID("exampleconnector")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("logs"): { + pipeline.MustNewID("logs"): { Receivers: []component.ID{component.MustNewID("exampleconnector")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("profiles"): { + pipeline.MustNewID("profiles"): { Receivers: []component.ID{component.MustNewID("exampleconnector")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -620,23 +621,23 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_conn_translate_from_metrics.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewID("metrics"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("metrics"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleconnector")}, }, - component.MustNewID("traces"): { + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewID("exampleconnector")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("logs"): { + pipeline.MustNewID("logs"): { Receivers: []component.ID{component.MustNewID("exampleconnector")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("profiles"): { + pipeline.MustNewID("profiles"): { Receivers: []component.ID{component.MustNewID("exampleconnector")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -646,23 +647,23 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_conn_translate_from_logs.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewID("logs"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("logs"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleconnector")}, }, - component.MustNewID("traces"): { + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewID("exampleconnector")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("metrics"): { + pipeline.MustNewID("metrics"): { Receivers: []component.ID{component.MustNewID("exampleconnector")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("profiles"): { + pipeline.MustNewID("profiles"): { Receivers: []component.ID{component.MustNewID("exampleconnector")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -672,23 +673,23 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_conn_translate_from_profiles.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewID("traces"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleconnector")}, }, - component.MustNewID("metrics"): { + pipeline.MustNewID("metrics"): { Receivers: []component.ID{component.MustNewID("exampleconnector")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("logs"): { + pipeline.MustNewID("logs"): { Receivers: []component.ID{component.MustNewID("exampleconnector")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewID("profiles"): { + pipeline.MustNewID("profiles"): { Receivers: []component.ID{component.MustNewID("exampleconnector")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -698,43 +699,43 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_conn_matrix_immutable.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewIDWithName("traces", "in"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("traces", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleconnector")}, }, - component.MustNewIDWithName("metrics", "in"): { + pipeline.MustNewIDWithName("metrics", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleconnector")}, }, - component.MustNewIDWithName("logs", "in"): { + pipeline.MustNewIDWithName("logs", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleconnector")}, }, - component.MustNewIDWithName("profiles", "in"): { + pipeline.MustNewIDWithName("profiles", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleconnector")}, }, - component.MustNewIDWithName("traces", "out"): { + pipeline.MustNewIDWithName("traces", "out"): { Receivers: []component.ID{component.MustNewID("exampleconnector")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewIDWithName("metrics", "out"): { + pipeline.MustNewIDWithName("metrics", "out"): { Receivers: []component.ID{component.MustNewID("exampleconnector")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewIDWithName("logs", "out"): { + pipeline.MustNewIDWithName("logs", "out"): { Receivers: []component.ID{component.MustNewID("exampleconnector")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewIDWithName("profiles", "out"): { + pipeline.MustNewIDWithName("profiles", "out"): { Receivers: []component.ID{component.MustNewID("exampleconnector")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -744,43 +745,43 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_conn_matrix_mutable.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewIDWithName("traces", "in"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("traces", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.MustNewIDWithName("metrics", "in"): { + pipeline.MustNewIDWithName("metrics", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.MustNewIDWithName("logs", "in"): { + pipeline.MustNewIDWithName("logs", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.MustNewIDWithName("profiles", "in"): { + pipeline.MustNewIDWithName("profiles", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.MustNewIDWithName("traces", "out"): { + pipeline.MustNewIDWithName("traces", "out"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewIDWithName("metrics", "out"): { + pipeline.MustNewIDWithName("metrics", "out"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewIDWithName("logs", "out"): { + pipeline.MustNewIDWithName("logs", "out"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewIDWithName("profiles", "out"): { + pipeline.MustNewIDWithName("profiles", "out"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -790,36 +791,36 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_conn_lanes.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewIDWithName("traces", "in"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("traces", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Exporters: []component.ID{component.MustNewID("mockforward")}, }, - component.MustNewIDWithName("traces", "out"): { + pipeline.MustNewIDWithName("traces", "out"): { Receivers: []component.ID{component.MustNewID("mockforward")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewIDWithName("metrics", "in"): { + pipeline.MustNewIDWithName("metrics", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Exporters: []component.ID{component.MustNewID("mockforward")}, }, - component.MustNewIDWithName("metrics", "out"): { + pipeline.MustNewIDWithName("metrics", "out"): { Receivers: []component.ID{component.MustNewID("mockforward")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewIDWithName("logs", "in"): { + pipeline.MustNewIDWithName("logs", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Exporters: []component.ID{component.MustNewID("mockforward")}, }, - component.MustNewIDWithName("logs", "out"): { + pipeline.MustNewIDWithName("logs", "out"): { Receivers: []component.ID{component.MustNewID("mockforward")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewIDWithName("profiles", "in"): { + pipeline.MustNewIDWithName("profiles", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Exporters: []component.ID{component.MustNewID("mockforward")}, }, - component.MustNewIDWithName("profiles", "out"): { + pipeline.MustNewIDWithName("profiles", "out"): { Receivers: []component.ID{component.MustNewID("mockforward")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, @@ -828,23 +829,23 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_conn_mutate_traces.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewIDWithName("traces", "in"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("traces", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.MustNewIDWithName("traces", "out0"): { + pipeline.MustNewIDWithName("traces", "out0"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewIDWithName("traces", "middle"): { + pipeline.MustNewIDWithName("traces", "middle"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")}, }, - component.MustNewIDWithName("traces", "out1"): { + pipeline.MustNewIDWithName("traces", "out1"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -854,23 +855,23 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_conn_mutate_metrics.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewIDWithName("metrics", "in"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("metrics", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.MustNewIDWithName("metrics", "out0"): { + pipeline.MustNewIDWithName("metrics", "out0"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewIDWithName("metrics", "middle"): { + pipeline.MustNewIDWithName("metrics", "middle"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")}, }, - component.MustNewIDWithName("metrics", "out1"): { + pipeline.MustNewIDWithName("metrics", "out1"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -880,23 +881,23 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_conn_mutate_logs.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewIDWithName("logs", "in"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("logs", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.MustNewIDWithName("logs", "out0"): { + pipeline.MustNewIDWithName("logs", "out0"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewIDWithName("logs", "middle"): { + pipeline.MustNewIDWithName("logs", "middle"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")}, }, - component.MustNewIDWithName("logs", "out1"): { + pipeline.MustNewIDWithName("logs", "out1"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -906,23 +907,23 @@ func TestConnectorPipelinesGraph(t *testing.T) { }, { name: "pipelines_conn_mutate_profiles.yaml", - pipelineConfigs: pipelines.Config{ - component.MustNewIDWithName("profiles", "in"): { + pipelineConfigs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("profiles", "in"): { Receivers: []component.ID{component.MustNewID("examplereceiver")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, }, - component.MustNewIDWithName("profiles", "out0"): { + pipeline.MustNewIDWithName("profiles", "out0"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, }, - component.MustNewIDWithName("profiles", "middle"): { + pipeline.MustNewIDWithName("profiles", "middle"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")}, }, - component.MustNewIDWithName("profiles", "out1"): { + pipeline.MustNewIDWithName("profiles", "out1"): { Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")}, Processors: []component.ID{component.MustNewID("exampleprocessor")}, Exporters: []component.ID{component.MustNewID("exampleexporter")}, @@ -988,7 +989,7 @@ func TestConnectorPipelinesGraph(t *testing.T) { require.NoError(t, pg.StartAll(context.Background(), &Host{Reporter: status.NewReporter(func(*componentstatus.InstanceID, *componentstatus.Event) {}, func(error) {})})) - mutatingPipelines := make(map[component.ID]bool, len(tt.pipelineConfigs)) + mutatingPipelines := make(map[pipeline.ID]bool, len(tt.pipelineConfigs)) // Check each pipeline individually, ensuring that all components are started // and that they have observed no signals yet. @@ -1081,7 +1082,7 @@ func TestConnectorPipelinesGraph(t *testing.T) { // find all the Pipelines of the same type where this connector is a receiver var inheritMutatesData bool for recPipelineID, recPipeline := range pg.pipelines { - if recPipelineID == expPipelineID || recPipelineID.Type() != expPipelineID.Type() { + if recPipelineID == expPipelineID || recPipelineID.Signal() != expPipelineID.Signal() { continue } for _, rec := range recPipeline.receivers { @@ -1101,19 +1102,19 @@ func TestConnectorPipelinesGraph(t *testing.T) { // shared between Pipelines. The `allReceivers` function also excludes Connectors, which we do // not want to directly inject with signals. allReceivers := pg.getReceivers() - for _, c := range allReceivers[component.DataTypeTraces] { + for _, c := range allReceivers[pipeline.SignalTraces] { tracesReceiver := c.(*testcomponents.ExampleReceiver) require.NoError(t, tracesReceiver.ConsumeTraces(context.Background(), testdata.GenerateTraces(1))) } - for _, c := range allReceivers[component.DataTypeMetrics] { + for _, c := range allReceivers[pipeline.SignalMetrics] { metricsReceiver := c.(*testcomponents.ExampleReceiver) require.NoError(t, metricsReceiver.ConsumeMetrics(context.Background(), testdata.GenerateMetrics(1))) } - for _, c := range allReceivers[component.DataTypeLogs] { + for _, c := range allReceivers[pipeline.SignalLogs] { logsReceiver := c.(*testcomponents.ExampleReceiver) require.NoError(t, logsReceiver.ConsumeLogs(context.Background(), testdata.GenerateLogs(1))) } - for _, c := range allReceivers[componentprofiles.DataTypeProfiles] { + for _, c := range allReceivers[componentprofiles.SignalProfiles] { profilesReceiver := c.(*testcomponents.ExampleReceiver) require.NoError(t, profilesReceiver.ConsumeProfiles(context.Background(), testdata.GenerateProfiles(1))) } @@ -1177,7 +1178,7 @@ func TestConnectorPipelinesGraph(t *testing.T) { // Get the list of Exporters directly from the overall component graph. Like Receivers, // exclude Connectors and validate each exporter once regardless of sharing between Pipelines. allExporters := pg.GetExporters() - for _, e := range allExporters[component.DataTypeTraces] { + for _, e := range allExporters[pipeline.SignalTraces] { tracesExporter := e.(*testcomponents.ExampleExporter) assert.Len(t, tracesExporter.Traces, tt.expectedPerExporter) expectedMutable := testdata.GenerateTraces(1) @@ -1191,7 +1192,7 @@ func TestConnectorPipelinesGraph(t *testing.T) { } } } - for _, e := range allExporters[component.DataTypeMetrics] { + for _, e := range allExporters[pipeline.SignalMetrics] { metricsExporter := e.(*testcomponents.ExampleExporter) assert.Len(t, metricsExporter.Metrics, tt.expectedPerExporter) expectedMutable := testdata.GenerateMetrics(1) @@ -1205,7 +1206,7 @@ func TestConnectorPipelinesGraph(t *testing.T) { } } } - for _, e := range allExporters[component.DataTypeLogs] { + for _, e := range allExporters[pipeline.SignalLogs] { logsExporter := e.(*testcomponents.ExampleExporter) assert.Len(t, logsExporter.Logs, tt.expectedPerExporter) expectedMutable := testdata.GenerateLogs(1) @@ -1219,7 +1220,7 @@ func TestConnectorPipelinesGraph(t *testing.T) { } } } - for _, e := range allExporters[componentprofiles.DataTypeProfiles] { + for _, e := range allExporters[componentprofiles.SignalProfiles] { profilesExporter := e.(*testcomponents.ExampleExporter) assert.Len(t, profilesExporter.Profiles, tt.expectedPerExporter) expectedMutable := testdata.GenerateProfiles(1) @@ -1246,21 +1247,21 @@ func TestConnectorRouter(t *testing.T) { expRightID := component.MustNewIDWithName("exampleexporter", "right") expLeftID := component.MustNewIDWithName("exampleexporter", "left") - tracesInID := component.MustNewIDWithName("traces", "in") - tracesRightID := component.MustNewIDWithName("traces", "right") - tracesLeftID := component.MustNewIDWithName("traces", "left") + tracesInID := pipeline.MustNewIDWithName("traces", "in") + tracesRightID := pipeline.MustNewIDWithName("traces", "right") + tracesLeftID := pipeline.MustNewIDWithName("traces", "left") - metricsInID := component.MustNewIDWithName("metrics", "in") - metricsRightID := component.MustNewIDWithName("metrics", "right") - metricsLeftID := component.MustNewIDWithName("metrics", "left") + metricsInID := pipeline.MustNewIDWithName("metrics", "in") + metricsRightID := pipeline.MustNewIDWithName("metrics", "right") + metricsLeftID := pipeline.MustNewIDWithName("metrics", "left") - logsInID := component.MustNewIDWithName("logs", "in") - logsRightID := component.MustNewIDWithName("logs", "right") - logsLeftID := component.MustNewIDWithName("logs", "left") + logsInID := pipeline.MustNewIDWithName("logs", "in") + logsRightID := pipeline.MustNewIDWithName("logs", "right") + logsLeftID := pipeline.MustNewIDWithName("logs", "left") - profilesInID := component.MustNewIDWithName("profiles", "in") - profilesRightID := component.MustNewIDWithName("profiles", "right") - profilesLeftID := component.MustNewIDWithName("profiles", "left") + profilesInID := pipeline.MustNewIDWithName("profiles", "in") + profilesRightID := pipeline.MustNewIDWithName("profiles", "right") + profilesLeftID := pipeline.MustNewIDWithName("profiles", "left") ctx := context.Background() set := Settings{ @@ -1314,7 +1315,7 @@ func TestConnectorRouter(t *testing.T) { testcomponents.ExampleRouterFactory.Type(): testcomponents.ExampleRouterFactory, }, ), - PipelineConfigs: pipelines.Config{ + PipelineConfigs: pipelines.ConfigWithPipelineID{ tracesInID: { Receivers: []component.ID{rcvrID}, Exporters: []component.ID{routeTracesID}, @@ -1375,9 +1376,9 @@ func TestConnectorRouter(t *testing.T) { assert.Equal(t, len(set.PipelineConfigs), len(pg.pipelines)) // Get a handle for the traces receiver and both Exporters - tracesReceiver := allReceivers[component.DataTypeTraces][rcvrID].(*testcomponents.ExampleReceiver) - tracesRight := allExporters[component.DataTypeTraces][expRightID].(*testcomponents.ExampleExporter) - tracesLeft := allExporters[component.DataTypeTraces][expLeftID].(*testcomponents.ExampleExporter) + tracesReceiver := allReceivers[pipeline.SignalTraces][rcvrID].(*testcomponents.ExampleReceiver) + tracesRight := allExporters[pipeline.SignalTraces][expRightID].(*testcomponents.ExampleExporter) + tracesLeft := allExporters[pipeline.SignalTraces][expLeftID].(*testcomponents.ExampleExporter) // Consume 1, validate it went right require.NoError(t, tracesReceiver.ConsumeTraces(ctx, testdata.GenerateTraces(1))) @@ -1397,9 +1398,9 @@ func TestConnectorRouter(t *testing.T) { assert.Len(t, tracesLeft.Traces, 2) // Get a handle for the metrics receiver and both Exporters - metricsReceiver := allReceivers[component.DataTypeMetrics][rcvrID].(*testcomponents.ExampleReceiver) - metricsRight := allExporters[component.DataTypeMetrics][expRightID].(*testcomponents.ExampleExporter) - metricsLeft := allExporters[component.DataTypeMetrics][expLeftID].(*testcomponents.ExampleExporter) + metricsReceiver := allReceivers[pipeline.SignalMetrics][rcvrID].(*testcomponents.ExampleReceiver) + metricsRight := allExporters[pipeline.SignalMetrics][expRightID].(*testcomponents.ExampleExporter) + metricsLeft := allExporters[pipeline.SignalMetrics][expLeftID].(*testcomponents.ExampleExporter) // Consume 1, validate it went right require.NoError(t, metricsReceiver.ConsumeMetrics(ctx, testdata.GenerateMetrics(1))) @@ -1419,9 +1420,9 @@ func TestConnectorRouter(t *testing.T) { assert.Len(t, metricsLeft.Metrics, 2) // Get a handle for the logs receiver and both Exporters - logsReceiver := allReceivers[component.DataTypeLogs][rcvrID].(*testcomponents.ExampleReceiver) - logsRight := allExporters[component.DataTypeLogs][expRightID].(*testcomponents.ExampleExporter) - logsLeft := allExporters[component.DataTypeLogs][expLeftID].(*testcomponents.ExampleExporter) + logsReceiver := allReceivers[pipeline.SignalLogs][rcvrID].(*testcomponents.ExampleReceiver) + logsRight := allExporters[pipeline.SignalLogs][expRightID].(*testcomponents.ExampleExporter) + logsLeft := allExporters[pipeline.SignalLogs][expLeftID].(*testcomponents.ExampleExporter) // Consume 1, validate it went right require.NoError(t, logsReceiver.ConsumeLogs(ctx, testdata.GenerateLogs(1))) @@ -1441,9 +1442,9 @@ func TestConnectorRouter(t *testing.T) { assert.Len(t, logsLeft.Logs, 2) // Get a handle for the profiles receiver and both Exporters - profilesReceiver := allReceivers[componentprofiles.DataTypeProfiles][rcvrID].(*testcomponents.ExampleReceiver) - profilesRight := allExporters[componentprofiles.DataTypeProfiles][expRightID].(*testcomponents.ExampleExporter) - profilesLeft := allExporters[componentprofiles.DataTypeProfiles][expLeftID].(*testcomponents.ExampleExporter) + profilesReceiver := allReceivers[componentprofiles.SignalProfiles][rcvrID].(*testcomponents.ExampleReceiver) + profilesRight := allExporters[componentprofiles.SignalProfiles][expRightID].(*testcomponents.ExampleExporter) + profilesLeft := allExporters[componentprofiles.SignalProfiles][expLeftID].(*testcomponents.ExampleExporter) // Consume 1, validate it went right require.NoError(t, profilesReceiver.ConsumeProfiles(ctx, testdata.GenerateProfiles(1))) @@ -1481,7 +1482,7 @@ func TestGraphBuildErrors(t *testing.T) { processorCfgs map[component.ID]component.Config exporterCfgs map[component.ID]component.Config connectorCfgs map[component.ID]component.Config - pipelineCfgs pipelines.Config + pipelineCfgs pipelines.ConfigWithPipelineID expected string }{ { @@ -1492,8 +1493,8 @@ func TestGraphBuildErrors(t *testing.T) { exporterCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): badExporterFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("logs"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("logs"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, @@ -1508,8 +1509,8 @@ func TestGraphBuildErrors(t *testing.T) { exporterCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): badExporterFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("metrics"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("metrics"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, @@ -1524,8 +1525,8 @@ func TestGraphBuildErrors(t *testing.T) { exporterCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): badExporterFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("traces"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, @@ -1540,8 +1541,8 @@ func TestGraphBuildErrors(t *testing.T) { exporterCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): badExporterFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("profiles"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("profiles"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, @@ -1559,8 +1560,8 @@ func TestGraphBuildErrors(t *testing.T) { exporterCfgs: map[component.ID]component.Config{ component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("logs"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("logs"): { Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, @@ -1579,8 +1580,8 @@ func TestGraphBuildErrors(t *testing.T) { exporterCfgs: map[component.ID]component.Config{ component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("metrics"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("metrics"): { Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, @@ -1599,8 +1600,8 @@ func TestGraphBuildErrors(t *testing.T) { exporterCfgs: map[component.ID]component.Config{ component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("traces"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, @@ -1619,8 +1620,8 @@ func TestGraphBuildErrors(t *testing.T) { exporterCfgs: map[component.ID]component.Config{ component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("profiles"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("profiles"): { Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, @@ -1636,8 +1637,8 @@ func TestGraphBuildErrors(t *testing.T) { exporterCfgs: map[component.ID]component.Config{ component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("logs"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("logs"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -1652,8 +1653,8 @@ func TestGraphBuildErrors(t *testing.T) { exporterCfgs: map[component.ID]component.Config{ component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("metrics"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("metrics"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -1668,8 +1669,8 @@ func TestGraphBuildErrors(t *testing.T) { exporterCfgs: map[component.ID]component.Config{ component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("traces"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -1684,8 +1685,8 @@ func TestGraphBuildErrors(t *testing.T) { exporterCfgs: map[component.ID]component.Config{ component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("profiles"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("profiles"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -1703,12 +1704,12 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("traces", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("traces", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, - component.MustNewIDWithName("traces", "out"): { + pipeline.MustNewIDWithName("traces", "out"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -1726,12 +1727,12 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("traces", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("traces", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, - component.MustNewIDWithName("metrics", "out"): { + pipeline.MustNewIDWithName("metrics", "out"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -1749,12 +1750,12 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("traces", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("traces", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, - component.MustNewIDWithName("logs", "out"): { + pipeline.MustNewIDWithName("logs", "out"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -1772,12 +1773,12 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("traces", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("traces", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, - component.MustNewIDWithName("profiles", "out"): { + pipeline.MustNewIDWithName("profiles", "out"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -1795,12 +1796,12 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("metrics", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("metrics", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, - component.MustNewIDWithName("traces", "out"): { + pipeline.MustNewIDWithName("traces", "out"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -1818,12 +1819,12 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("metrics", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("metrics", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, - component.MustNewIDWithName("metrics", "out"): { + pipeline.MustNewIDWithName("metrics", "out"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -1841,12 +1842,12 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("metrics", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("metrics", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, - component.MustNewIDWithName("logs", "out"): { + pipeline.MustNewIDWithName("logs", "out"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -1864,12 +1865,12 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("metrics", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("metrics", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, - component.MustNewIDWithName("profiles", "out"): { + pipeline.MustNewIDWithName("profiles", "out"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -1887,12 +1888,12 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("logs", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("logs", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, - component.MustNewIDWithName("traces", "out"): { + pipeline.MustNewIDWithName("traces", "out"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -1910,12 +1911,12 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("logs", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("logs", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, - component.MustNewIDWithName("metrics", "out"): { + pipeline.MustNewIDWithName("metrics", "out"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -1933,12 +1934,12 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("logs", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("logs", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, - component.MustNewIDWithName("logs", "out"): { + pipeline.MustNewIDWithName("logs", "out"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -1956,12 +1957,12 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("logs", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("logs", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, - component.MustNewIDWithName("profiles", "out"): { + pipeline.MustNewIDWithName("profiles", "out"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -1979,12 +1980,12 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("profiles", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("profiles", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, - component.MustNewIDWithName("traces", "out"): { + pipeline.MustNewIDWithName("traces", "out"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -2002,12 +2003,12 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("profiles", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("profiles", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, - component.MustNewIDWithName("metrics", "out"): { + pipeline.MustNewIDWithName("metrics", "out"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -2025,12 +2026,12 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("profiles", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("profiles", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, - component.MustNewIDWithName("logs", "out"): { + pipeline.MustNewIDWithName("logs", "out"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -2048,12 +2049,12 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("profiles", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("profiles", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("bf")}, }, - component.MustNewIDWithName("profiles", "out"): { + pipeline.MustNewIDWithName("profiles", "out"): { Receivers: []component.ID{component.MustNewID("bf")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -2071,8 +2072,8 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("metrics", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("metrics", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")}, }, @@ -2090,8 +2091,8 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("traces", "out"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("traces", "out"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -2109,16 +2110,16 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewID("mockforward"): mfConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("traces", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("traces", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("mockforward")}, }, - component.MustNewIDWithName("traces", "out"): { + pipeline.MustNewIDWithName("traces", "out"): { Receivers: []component.ID{component.MustNewID("mockforward")}, Exporters: []component.ID{component.MustNewID("nop")}, }, - component.MustNewIDWithName("metrics", "in"): { + pipeline.MustNewIDWithName("metrics", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("mockforward")}, }, @@ -2136,16 +2137,16 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewID("mockforward"): mfConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("metrics", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("metrics", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("mockforward")}, }, - component.MustNewIDWithName("metrics", "out"): { + pipeline.MustNewIDWithName("metrics", "out"): { Receivers: []component.ID{component.MustNewID("mockforward")}, Exporters: []component.ID{component.MustNewID("nop")}, }, - component.MustNewIDWithName("traces", "out"): { + pipeline.MustNewIDWithName("traces", "out"): { Receivers: []component.ID{component.MustNewID("mockforward")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -2166,8 +2167,8 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("traces"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")}, @@ -2192,8 +2193,8 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("metrics"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("metrics"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")}, @@ -2218,8 +2219,8 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("logs"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("logs"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")}, @@ -2244,8 +2245,8 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("profiles"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("profiles"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")}, @@ -2272,23 +2273,23 @@ func TestGraphBuildErrors(t *testing.T) { component.MustNewIDWithName("nop", "conn1"): nopConnectorFactory.CreateDefaultConfig(), component.MustNewIDWithName("nop", "conn2"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("traces", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("traces", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")}, }, - component.MustNewIDWithName("traces", "1"): { + pipeline.MustNewIDWithName("traces", "1"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "conn1")}, }, - component.MustNewIDWithName("traces", "2"): { + pipeline.MustNewIDWithName("traces", "2"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "conn1")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "conn2"), component.MustNewIDWithName("nop", "conn")}, }, - component.MustNewIDWithName("traces", "out"): { + pipeline.MustNewIDWithName("traces", "out"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "conn2")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("nop")}, @@ -2317,23 +2318,23 @@ func TestGraphBuildErrors(t *testing.T) { component.MustNewIDWithName("nop", "conn1"): nopConnectorFactory.CreateDefaultConfig(), component.MustNewIDWithName("nop", "conn2"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("metrics", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("metrics", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")}, }, - component.MustNewIDWithName("metrics", "1"): { + pipeline.MustNewIDWithName("metrics", "1"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "conn1")}, }, - component.MustNewIDWithName("metrics", "2"): { + pipeline.MustNewIDWithName("metrics", "2"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "conn1")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "conn2"), component.MustNewIDWithName("nop", "conn")}, }, - component.MustNewIDWithName("metrics", "out"): { + pipeline.MustNewIDWithName("metrics", "out"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "conn2")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("nop")}, @@ -2362,23 +2363,23 @@ func TestGraphBuildErrors(t *testing.T) { component.MustNewIDWithName("nop", "conn1"): nopConnectorFactory.CreateDefaultConfig(), component.MustNewIDWithName("nop", "conn2"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("logs", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("logs", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")}, }, - component.MustNewIDWithName("logs", "1"): { + pipeline.MustNewIDWithName("logs", "1"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "conn1")}, }, - component.MustNewIDWithName("logs", "2"): { + pipeline.MustNewIDWithName("logs", "2"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "conn1")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "conn2"), component.MustNewIDWithName("nop", "conn")}, }, - component.MustNewIDWithName("logs", "out"): { + pipeline.MustNewIDWithName("logs", "out"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "conn2")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("nop")}, @@ -2407,23 +2408,23 @@ func TestGraphBuildErrors(t *testing.T) { component.MustNewIDWithName("nop", "conn1"): nopConnectorFactory.CreateDefaultConfig(), component.MustNewIDWithName("nop", "conn2"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("profiles", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("profiles", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")}, }, - component.MustNewIDWithName("profiles", "1"): { + pipeline.MustNewIDWithName("profiles", "1"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "conn1")}, }, - component.MustNewIDWithName("profiles", "2"): { + pipeline.MustNewIDWithName("profiles", "2"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "conn1")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "conn2"), component.MustNewIDWithName("nop", "conn")}, }, - component.MustNewIDWithName("profiles", "out"): { + pipeline.MustNewIDWithName("profiles", "out"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "conn2")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("nop")}, @@ -2453,38 +2454,38 @@ func TestGraphBuildErrors(t *testing.T) { component.MustNewIDWithName("nop", "forkagain"): nopConnectorFactory.CreateDefaultConfig(), component.MustNewIDWithName("nop", "rawlog"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("traces", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("traces", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "fork")}, }, - component.MustNewIDWithName("traces", "copy1"): { + pipeline.MustNewIDWithName("traces", "copy1"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "fork")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "count")}, }, - component.MustNewIDWithName("traces", "copy2"): { + pipeline.MustNewIDWithName("traces", "copy2"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "fork")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "forkagain")}, }, - component.MustNewIDWithName("traces", "copy2a"): { + pipeline.MustNewIDWithName("traces", "copy2a"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "forkagain")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "count")}, }, - component.MustNewIDWithName("traces", "copy2b"): { + pipeline.MustNewIDWithName("traces", "copy2b"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "forkagain")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "rawlog")}, }, - component.MustNewIDWithName("metrics", "count"): { + pipeline.MustNewIDWithName("metrics", "count"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "count")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("nop")}, }, - component.MustNewIDWithName("logs", "raw"): { + pipeline.MustNewIDWithName("logs", "raw"): { Receivers: []component.ID{component.MustNewIDWithName("nop", "rawlog")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewIDWithName("nop", "fork")}, // cannot loop back to "nop/fork" @@ -2507,8 +2508,8 @@ func TestGraphBuildErrors(t *testing.T) { exporterCfgs: map[component.ID]component.Config{ component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("traces"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("nop"), component.MustNewIDWithName("nop", "1")}, }, @@ -2523,8 +2524,8 @@ func TestGraphBuildErrors(t *testing.T) { exporterCfgs: map[component.ID]component.Config{ component.MustNewID("unknown"): nopReceiverFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("traces"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("unknown")}, }, @@ -2542,8 +2543,8 @@ func TestGraphBuildErrors(t *testing.T) { exporterCfgs: map[component.ID]component.Config{ component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("metrics"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("metrics"): { Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("nop"), component.MustNewIDWithName("nop", "1")}, Exporters: []component.ID{component.MustNewID("nop")}, @@ -2562,8 +2563,8 @@ func TestGraphBuildErrors(t *testing.T) { exporterCfgs: map[component.ID]component.Config{ component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("metrics"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("metrics"): { Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("unknown")}, Exporters: []component.ID{component.MustNewID("nop")}, @@ -2579,8 +2580,8 @@ func TestGraphBuildErrors(t *testing.T) { exporterCfgs: map[component.ID]component.Config{ component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("logs"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("logs"): { Receivers: []component.ID{component.MustNewID("nop"), component.MustNewIDWithName("nop", "1")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -2595,8 +2596,8 @@ func TestGraphBuildErrors(t *testing.T) { exporterCfgs: map[component.ID]component.Config{ component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewID("logs"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("logs"): { Receivers: []component.ID{component.MustNewID("unknown")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -2614,12 +2615,12 @@ func TestGraphBuildErrors(t *testing.T) { connectorCfgs: map[component.ID]component.Config{ component.MustNewID("unknown"): nopConnectorFactory.CreateDefaultConfig(), }, - pipelineCfgs: pipelines.Config{ - component.MustNewIDWithName("traces", "in"): { + pipelineCfgs: pipelines.ConfigWithPipelineID{ + pipeline.MustNewIDWithName("traces", "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("unknown")}, }, - component.MustNewIDWithName("traces", "out"): { + pipeline.MustNewIDWithName("traces", "out"): { Receivers: []component.ID{component.MustNewID("unknown")}, Exporters: []component.ID{component.MustNewID("nop")}, }, @@ -2719,11 +2720,11 @@ func TestGraphFailToStartAndShutdown(t *testing.T) { }), } - dataTypes := []component.DataType{component.DataTypeTraces, component.DataTypeMetrics, component.DataTypeLogs} + dataTypes := []pipeline.Signal{pipeline.SignalTraces, pipeline.SignalMetrics, pipeline.SignalLogs} for _, dt := range dataTypes { t.Run(dt.String()+"/receiver", func(t *testing.T) { - set.PipelineConfigs = pipelines.Config{ - component.NewID(dt): { + set.PipelineConfigs = pipelines.ConfigWithPipelineID{ + pipeline.NewID(dt): { Receivers: []component.ID{component.MustNewID("nop"), component.MustNewID("err")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("nop")}, @@ -2736,8 +2737,8 @@ func TestGraphFailToStartAndShutdown(t *testing.T) { }) t.Run(dt.String()+"/processor", func(t *testing.T) { - set.PipelineConfigs = pipelines.Config{ - component.NewID(dt): { + set.PipelineConfigs = pipelines.ConfigWithPipelineID{ + pipeline.NewID(dt): { Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("nop"), component.MustNewID("err")}, Exporters: []component.ID{component.MustNewID("nop")}, @@ -2750,8 +2751,8 @@ func TestGraphFailToStartAndShutdown(t *testing.T) { }) t.Run(dt.String()+"/exporter", func(t *testing.T) { - set.PipelineConfigs = pipelines.Config{ - component.NewID(dt): { + set.PipelineConfigs = pipelines.ConfigWithPipelineID{ + pipeline.NewID(dt): { Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("nop"), component.MustNewID("err")}, @@ -2765,13 +2766,13 @@ func TestGraphFailToStartAndShutdown(t *testing.T) { for _, dt2 := range dataTypes { t.Run(dt.String()+"/"+dt2.String()+"/connector", func(t *testing.T) { - set.PipelineConfigs = pipelines.Config{ - component.NewIDWithName(dt, "in"): { + set.PipelineConfigs = pipelines.ConfigWithPipelineID{ + pipeline.NewIDWithName(dt, "in"): { Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("nop"), component.MustNewIDWithName("err", "conn")}, }, - component.NewIDWithName(dt2, "out"): { + pipeline.NewIDWithName(dt2, "out"): { Receivers: []component.ID{component.MustNewID("nop"), component.MustNewIDWithName("err", "conn")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("nop")}, @@ -2797,12 +2798,12 @@ func TestStatusReportedOnStartupShutdown(t *testing.T) { eSdErr := &testNode{id: component.MustNewIDWithName("e_sd_err", "1"), shutdownErr: assert.AnError} instanceIDs := map[*testNode]*componentstatus.InstanceID{ - rNoErr: componentstatus.NewInstanceID(rNoErr.id, component.KindReceiver), - rStErr: componentstatus.NewInstanceID(rStErr.id, component.KindReceiver), - rSdErr: componentstatus.NewInstanceID(rSdErr.id, component.KindReceiver), - eNoErr: componentstatus.NewInstanceID(eNoErr.id, component.KindExporter), - eStErr: componentstatus.NewInstanceID(eStErr.id, component.KindExporter), - eSdErr: componentstatus.NewInstanceID(eSdErr.id, component.KindExporter), + rNoErr: componentstatus.NewInstanceIDWithPipelineIDs(rNoErr.id, component.KindReceiver), + rStErr: componentstatus.NewInstanceIDWithPipelineIDs(rStErr.id, component.KindReceiver), + rSdErr: componentstatus.NewInstanceIDWithPipelineIDs(rSdErr.id, component.KindReceiver), + eNoErr: componentstatus.NewInstanceIDWithPipelineIDs(eNoErr.id, component.KindExporter), + eStErr: componentstatus.NewInstanceIDWithPipelineIDs(eStErr.id, component.KindExporter), + eSdErr: componentstatus.NewInstanceIDWithPipelineIDs(eSdErr.id, component.KindExporter), } // compare two maps of status events ignoring timestamp @@ -2939,12 +2940,12 @@ func TestStatusReportedOnStartupShutdown(t *testing.T) { } } -func (g *Graph) getReceivers() map[component.DataType]map[component.ID]component.Component { - receiversMap := make(map[component.DataType]map[component.ID]component.Component) - receiversMap[component.DataTypeTraces] = make(map[component.ID]component.Component) - receiversMap[component.DataTypeMetrics] = make(map[component.ID]component.Component) - receiversMap[component.DataTypeLogs] = make(map[component.ID]component.Component) - receiversMap[componentprofiles.DataTypeProfiles] = make(map[component.ID]component.Component) +func (g *Graph) getReceivers() map[pipeline.Signal]map[component.ID]component.Component { + receiversMap := make(map[pipeline.Signal]map[component.ID]component.Component) + receiversMap[pipeline.SignalTraces] = make(map[component.ID]component.Component) + receiversMap[pipeline.SignalMetrics] = make(map[component.ID]component.Component) + receiversMap[pipeline.SignalLogs] = make(map[component.ID]component.Component) + receiversMap[componentprofiles.SignalProfiles] = make(map[component.ID]component.Component) for _, pg := range g.pipelines { for _, rcvrNode := range pg.receivers { @@ -2972,7 +2973,7 @@ func (g *Graph) getReceivers() map[component.DataType]map[component.ID]component // However, within an individual pipeline, we expect: // - E instances of the connector as a receiver. // - R instances of the connector as an exporter. -func expectedInstances(m pipelines.Config, pID component.ID) (int, int) { +func expectedInstances(m pipelines.ConfigWithPipelineID, pID pipeline.ID) (int, int) { exConnectorType := component.MustNewType("exampleconnector") var r, e int for _, rID := range m[pID].Receivers { @@ -2982,11 +2983,11 @@ func expectedInstances(m pipelines.Config, pID component.ID) (int, int) { } // This is a connector. Count the pipeline types where it is an exporter. - typeMap := map[component.DataType]bool{} + typeMap := map[pipeline.Signal]bool{} for pID, pCfg := range m { for _, eID := range pCfg.Exporters { if eID == rID { - typeMap[pID.Type()] = true + typeMap[pID.Signal()] = true } } } @@ -2999,11 +3000,11 @@ func expectedInstances(m pipelines.Config, pID component.ID) (int, int) { } // This is a connector. Count the pipeline types where it is a receiver. - typeMap := map[component.DataType]bool{} + typeMap := map[pipeline.Signal]bool{} for pID, pCfg := range m { for _, rID := range pCfg.Receivers { if rID == eID { - typeMap[pID.Type()] = true + typeMap[pID.Signal()] = true } } } diff --git a/service/internal/graph/host.go b/service/internal/graph/host.go index abadca4b4af..e35beda18a7 100644 --- a/service/internal/graph/host.go +++ b/service/internal/graph/host.go @@ -10,9 +10,11 @@ import ( "time" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componentprofiles" "go.opentelemetry.io/collector/component/componentstatus" "go.opentelemetry.io/collector/extension" "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/service/extensions" "go.opentelemetry.io/collector/service/internal/builders" "go.opentelemetry.io/collector/service/internal/status" @@ -20,6 +22,8 @@ import ( ) // TODO: remove as part of https://github.com/open-telemetry/opentelemetry-collector/issues/7370 for service 1.0 +// +// nolint type getExporters interface { GetExporters() map[component.DataType]map[component.ID]component.Component } @@ -70,8 +74,30 @@ func (host *Host) GetExtensions() map[component.ID]component.Component { // connector. See https://github.com/open-telemetry/opentelemetry-collector/issues/7370 and // https://github.com/open-telemetry/opentelemetry-collector/pull/7390#issuecomment-1483710184 // for additional information. +// nolint func (host *Host) GetExporters() map[component.DataType]map[component.ID]component.Component { - return host.Pipelines.GetExporters() + exporters := host.Pipelines.GetExporters() + exportersMap := make(map[component.DataType]map[component.ID]component.Component) + for k, v := range exporters { + exportersMap[convertSignalToDataType(k)] = v + } + return exportersMap +} + +// nolint +func convertSignalToDataType(signal pipeline.Signal) component.DataType { + switch signal { + case pipeline.SignalTraces: + return component.DataTypeTraces + case pipeline.SignalMetrics: + return component.DataTypeMetrics + case pipeline.SignalLogs: + return component.DataTypeLogs + case componentprofiles.SignalProfiles: + return componentprofiles.DataTypeProfiles + default: + return component.MustNewType(signal.String()) + } } func (host *Host) NotifyComponentStatusChange(source *componentstatus.InstanceID, event *componentstatus.Event) { diff --git a/service/internal/graph/nodes.go b/service/internal/graph/nodes.go index f9cc3e6fa7a..89580dab487 100644 --- a/service/internal/graph/nodes.go +++ b/service/internal/graph/nodes.go @@ -17,6 +17,7 @@ import ( "go.opentelemetry.io/collector/consumer/consumerprofiles" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/internal/fanoutconsumer" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/processor" "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/service/internal/builders" @@ -59,11 +60,11 @@ type consumerNode interface { type receiverNode struct { nodeID componentID component.ID - pipelineType component.DataType + pipelineType pipeline.Signal component.Component } -func newReceiverNode(pipelineType component.DataType, recvID component.ID) *receiverNode { +func newReceiverNode(pipelineType pipeline.Signal, recvID component.ID) *receiverNode { return &receiverNode{ nodeID: newNodeID(receiverSeed, pipelineType.String(), recvID.String()), componentID: recvID, @@ -81,25 +82,25 @@ func (n *receiverNode) buildComponent(ctx context.Context, set := receiver.Settings{ID: n.componentID, TelemetrySettings: tel, BuildInfo: info} var err error switch n.pipelineType { - case component.DataTypeTraces: + case pipeline.SignalTraces: var consumers []consumer.Traces for _, next := range nexts { consumers = append(consumers, next.(consumer.Traces)) } n.Component, err = builder.CreateTraces(ctx, set, fanoutconsumer.NewTraces(consumers)) - case component.DataTypeMetrics: + case pipeline.SignalMetrics: var consumers []consumer.Metrics for _, next := range nexts { consumers = append(consumers, next.(consumer.Metrics)) } n.Component, err = builder.CreateMetrics(ctx, set, fanoutconsumer.NewMetrics(consumers)) - case component.DataTypeLogs: + case pipeline.SignalLogs: var consumers []consumer.Logs for _, next := range nexts { consumers = append(consumers, next.(consumer.Logs)) } n.Component, err = builder.CreateLogs(ctx, set, fanoutconsumer.NewLogs(consumers)) - case componentprofiles.DataTypeProfiles: + case componentprofiles.SignalProfiles: var consumers []consumerprofiles.Profiles for _, next := range nexts { consumers = append(consumers, next.(consumerprofiles.Profiles)) @@ -121,11 +122,11 @@ var _ consumerNode = (*processorNode)(nil) type processorNode struct { nodeID componentID component.ID - pipelineID component.ID + pipelineID pipeline.ID component.Component } -func newProcessorNode(pipelineID, procID component.ID) *processorNode { +func newProcessorNode(pipelineID pipeline.ID, procID component.ID) *processorNode { return &processorNode{ nodeID: newNodeID(processorSeed, pipelineID.String(), procID.String()), componentID: procID, @@ -146,20 +147,20 @@ func (n *processorNode) buildComponent(ctx context.Context, tel.Logger = components.ProcessorLogger(tel.Logger, n.componentID, n.pipelineID) set := processor.Settings{ID: n.componentID, TelemetrySettings: tel, BuildInfo: info} var err error - switch n.pipelineID.Type() { - case component.DataTypeTraces: + switch n.pipelineID.Signal() { + case pipeline.SignalTraces: n.Component, err = builder.CreateTraces(ctx, set, next.(consumer.Traces)) - case component.DataTypeMetrics: + case pipeline.SignalMetrics: n.Component, err = builder.CreateMetrics(ctx, set, next.(consumer.Metrics)) - case component.DataTypeLogs: + case pipeline.SignalLogs: n.Component, err = builder.CreateLogs(ctx, set, next.(consumer.Logs)) - case componentprofiles.DataTypeProfiles: + case componentprofiles.SignalProfiles: n.Component, err = builder.CreateProfiles(ctx, set, next.(consumerprofiles.Profiles)) default: - return fmt.Errorf("error creating processor %q in pipeline %q, data type %q is not supported", set.ID, n.pipelineID, n.pipelineID.Type()) + return fmt.Errorf("error creating processor %q in pipeline %q, data type %q is not supported", set.ID, n.pipelineID.String(), n.pipelineID.Signal()) } if err != nil { - return fmt.Errorf("failed to create %q processor, in pipeline %q: %w", set.ID, n.pipelineID, err) + return fmt.Errorf("failed to create %q processor, in pipeline %q: %w", set.ID, n.pipelineID.String(), err) } return nil } @@ -171,11 +172,11 @@ var _ consumerNode = (*exporterNode)(nil) type exporterNode struct { nodeID componentID component.ID - pipelineType component.DataType + pipelineType pipeline.Signal component.Component } -func newExporterNode(pipelineType component.DataType, exprID component.ID) *exporterNode { +func newExporterNode(pipelineType pipeline.Signal, exprID component.ID) *exporterNode { return &exporterNode{ nodeID: newNodeID(exporterSeed, pipelineType.String(), exprID.String()), componentID: exprID, @@ -197,13 +198,13 @@ func (n *exporterNode) buildComponent( set := exporter.Settings{ID: n.componentID, TelemetrySettings: tel, BuildInfo: info} var err error switch n.pipelineType { - case component.DataTypeTraces: + case pipeline.SignalTraces: n.Component, err = builder.CreateTraces(ctx, set) - case component.DataTypeMetrics: + case pipeline.SignalMetrics: n.Component, err = builder.CreateMetrics(ctx, set) - case component.DataTypeLogs: + case pipeline.SignalLogs: n.Component, err = builder.CreateLogs(ctx, set) - case componentprofiles.DataTypeProfiles: + case componentprofiles.SignalProfiles: n.Component, err = builder.CreateProfiles(ctx, set) default: return fmt.Errorf("error creating exporter %q for data type %q is not supported", set.ID, n.pipelineType) @@ -221,13 +222,13 @@ var _ consumerNode = (*connectorNode)(nil) type connectorNode struct { nodeID componentID component.ID - exprPipelineType component.DataType - rcvrPipelineType component.DataType + exprPipelineType pipeline.Signal + rcvrPipelineType pipeline.Signal component.Component baseConsumer } -func newConnectorNode(exprPipelineType, rcvrPipelineType component.DataType, connID component.ID) *connectorNode { +func newConnectorNode(exprPipelineType, rcvrPipelineType pipeline.Signal, connID component.ID) *connectorNode { return &connectorNode{ nodeID: newNodeID(connectorSeed, connID.String(), exprPipelineType.String(), rcvrPipelineType.String()), componentID: connID, @@ -251,9 +252,9 @@ func (n *connectorNode) buildComponent( set := connector.Settings{ID: n.componentID, TelemetrySettings: tel, BuildInfo: info} switch n.rcvrPipelineType { - case component.DataTypeTraces: + case pipeline.SignalTraces: capability := consumer.Capabilities{MutatesData: false} - consumers := make(map[component.ID]consumer.Traces, len(nexts)) + consumers := make(map[pipeline.ID]consumer.Traces, len(nexts)) for _, next := range nexts { consumers[next.(*capabilitiesNode).pipelineID] = next.(consumer.Traces) capability.MutatesData = capability.MutatesData || next.Capabilities().MutatesData @@ -261,7 +262,7 @@ func (n *connectorNode) buildComponent( next := connector.NewTracesRouter(consumers) switch n.exprPipelineType { - case component.DataTypeTraces: + case pipeline.SignalTraces: conn, err := builder.CreateTracesToTraces(ctx, set, next) if err != nil { return err @@ -273,19 +274,19 @@ func (n *connectorNode) buildComponent( // that the connector itself may MutatesData. capability.MutatesData = capability.MutatesData || conn.Capabilities().MutatesData n.baseConsumer = capabilityconsumer.NewTraces(conn, capability) - case component.DataTypeMetrics: + case pipeline.SignalMetrics: conn, err := builder.CreateMetricsToTraces(ctx, set, next) if err != nil { return err } n.Component, n.baseConsumer = conn, conn - case component.DataTypeLogs: + case pipeline.SignalLogs: conn, err := builder.CreateLogsToTraces(ctx, set, next) if err != nil { return err } n.Component, n.baseConsumer = conn, conn - case componentprofiles.DataTypeProfiles: + case componentprofiles.SignalProfiles: conn, err := builder.CreateProfilesToTraces(ctx, set, next) if err != nil { return err @@ -293,9 +294,9 @@ func (n *connectorNode) buildComponent( n.Component, n.baseConsumer = conn, conn } - case component.DataTypeMetrics: + case pipeline.SignalMetrics: capability := consumer.Capabilities{MutatesData: false} - consumers := make(map[component.ID]consumer.Metrics, len(nexts)) + consumers := make(map[pipeline.ID]consumer.Metrics, len(nexts)) for _, next := range nexts { consumers[next.(*capabilitiesNode).pipelineID] = next.(consumer.Metrics) capability.MutatesData = capability.MutatesData || next.Capabilities().MutatesData @@ -303,13 +304,13 @@ func (n *connectorNode) buildComponent( next := connector.NewMetricsRouter(consumers) switch n.exprPipelineType { - case component.DataTypeTraces: + case pipeline.SignalTraces: conn, err := builder.CreateTracesToMetrics(ctx, set, next) if err != nil { return err } n.Component, n.baseConsumer = conn, conn - case component.DataTypeMetrics: + case pipeline.SignalMetrics: conn, err := builder.CreateMetricsToMetrics(ctx, set, next) if err != nil { return err @@ -321,22 +322,22 @@ func (n *connectorNode) buildComponent( // that the connector itself may MutatesData. capability.MutatesData = capability.MutatesData || conn.Capabilities().MutatesData n.baseConsumer = capabilityconsumer.NewMetrics(conn, capability) - case component.DataTypeLogs: + case pipeline.SignalLogs: conn, err := builder.CreateLogsToMetrics(ctx, set, next) if err != nil { return err } n.Component, n.baseConsumer = conn, conn - case componentprofiles.DataTypeProfiles: + case componentprofiles.SignalProfiles: conn, err := builder.CreateProfilesToMetrics(ctx, set, next) if err != nil { return err } n.Component, n.baseConsumer = conn, conn } - case component.DataTypeLogs: + case pipeline.SignalLogs: capability := consumer.Capabilities{MutatesData: false} - consumers := make(map[component.ID]consumer.Logs, len(nexts)) + consumers := make(map[pipeline.ID]consumer.Logs, len(nexts)) for _, next := range nexts { consumers[next.(*capabilitiesNode).pipelineID] = next.(consumer.Logs) capability.MutatesData = capability.MutatesData || next.Capabilities().MutatesData @@ -344,19 +345,19 @@ func (n *connectorNode) buildComponent( next := connector.NewLogsRouter(consumers) switch n.exprPipelineType { - case component.DataTypeTraces: + case pipeline.SignalTraces: conn, err := builder.CreateTracesToLogs(ctx, set, next) if err != nil { return err } n.Component, n.baseConsumer = conn, conn - case component.DataTypeMetrics: + case pipeline.SignalMetrics: conn, err := builder.CreateMetricsToLogs(ctx, set, next) if err != nil { return err } n.Component, n.baseConsumer = conn, conn - case component.DataTypeLogs: + case pipeline.SignalLogs: conn, err := builder.CreateLogsToLogs(ctx, set, next) if err != nil { return err @@ -368,16 +369,16 @@ func (n *connectorNode) buildComponent( // that the connector itself may MutatesData. capability.MutatesData = capability.MutatesData || conn.Capabilities().MutatesData n.baseConsumer = capabilityconsumer.NewLogs(conn, capability) - case componentprofiles.DataTypeProfiles: + case componentprofiles.SignalProfiles: conn, err := builder.CreateProfilesToLogs(ctx, set, next) if err != nil { return err } n.Component, n.baseConsumer = conn, conn } - case componentprofiles.DataTypeProfiles: + case componentprofiles.SignalProfiles: capability := consumer.Capabilities{MutatesData: false} - consumers := make(map[component.ID]consumerprofiles.Profiles, len(nexts)) + consumers := make(map[pipeline.ID]consumerprofiles.Profiles, len(nexts)) for _, next := range nexts { consumers[next.(*capabilitiesNode).pipelineID] = next.(consumerprofiles.Profiles) capability.MutatesData = capability.MutatesData || next.Capabilities().MutatesData @@ -385,25 +386,25 @@ func (n *connectorNode) buildComponent( next := connectorprofiles.NewProfilesRouter(consumers) switch n.exprPipelineType { - case component.DataTypeTraces: + case pipeline.SignalTraces: conn, err := builder.CreateTracesToProfiles(ctx, set, next) if err != nil { return err } n.Component, n.baseConsumer = conn, conn - case component.DataTypeMetrics: + case pipeline.SignalMetrics: conn, err := builder.CreateMetricsToProfiles(ctx, set, next) if err != nil { return err } n.Component, n.baseConsumer = conn, conn - case component.DataTypeLogs: + case pipeline.SignalLogs: conn, err := builder.CreateLogsToProfiles(ctx, set, next) if err != nil { return err } n.Component, n.baseConsumer = conn, conn - case componentprofiles.DataTypeProfiles: + case componentprofiles.SignalProfiles: conn, err := builder.CreateProfilesToProfiles(ctx, set, next) if err != nil { return err @@ -429,7 +430,7 @@ var _ consumerNode = (*capabilitiesNode)(nil) // The nodeID is derived from "pipeline ID". type capabilitiesNode struct { nodeID - pipelineID component.ID + pipelineID pipeline.ID baseConsumer consumer.ConsumeTracesFunc consumer.ConsumeMetricsFunc @@ -437,7 +438,7 @@ type capabilitiesNode struct { consumerprofiles.ConsumeProfilesFunc } -func newCapabilitiesNode(pipelineID component.ID) *capabilitiesNode { +func newCapabilitiesNode(pipelineID pipeline.ID) *capabilitiesNode { return &capabilitiesNode{ nodeID: newNodeID(capabilitiesSeed, pipelineID.String()), pipelineID: pipelineID, @@ -454,11 +455,11 @@ var _ consumerNode = (*fanOutNode)(nil) // Therefore, nodeID is derived from "pipeline ID". type fanOutNode struct { nodeID - pipelineID component.ID + pipelineID pipeline.ID baseConsumer } -func newFanOutNode(pipelineID component.ID) *fanOutNode { +func newFanOutNode(pipelineID pipeline.ID) *fanOutNode { return &fanOutNode{ nodeID: newNodeID(fanOutToExporters, pipelineID.String()), pipelineID: pipelineID, diff --git a/service/internal/graph/zpages.go b/service/internal/graph/zpages.go index 0f2793974e9..4b7f2c5ae6d 100644 --- a/service/internal/graph/zpages.go +++ b/service/internal/graph/zpages.go @@ -55,7 +55,7 @@ func (g *Graph) HandleZPages(w http.ResponseWriter, r *http.Request) { sumData.Rows = append(sumData.Rows, zpages.SummaryPipelinesTableRowData{ FullName: c.String(), - InputType: c.Type().String(), + InputType: c.Signal().String(), MutatesData: p.capabilitiesNode.getConsumer().Capabilities().MutatesData, Receivers: recvIDs, Processors: procIDs, diff --git a/service/internal/testcomponents/example_router.go b/service/internal/testcomponents/example_router.go index c8fd28f48e1..b3302580821 100644 --- a/service/internal/testcomponents/example_router.go +++ b/service/internal/testcomponents/example_router.go @@ -15,6 +15,7 @@ import ( "go.opentelemetry.io/collector/pdata/pmetric" "go.opentelemetry.io/collector/pdata/pprofile" "go.opentelemetry.io/collector/pdata/ptrace" + "go.opentelemetry.io/collector/pipeline" ) var routerType = component.MustNewType("examplerouter") @@ -30,8 +31,8 @@ var ExampleRouterFactory = connector.NewFactory( ) type LeftRightConfig struct { - Left component.ID `mapstructure:"left"` - Right component.ID `mapstructure:"right"` + Left pipeline.ID `mapstructure:"left"` + Right pipeline.ID `mapstructure:"right"` } type ExampleRouterConfig struct { diff --git a/service/internal/testcomponents/example_router_test.go b/service/internal/testcomponents/example_router_test.go index 123799e9213..f8c69e40f8a 100644 --- a/service/internal/testcomponents/example_router_test.go +++ b/service/internal/testcomponents/example_router_test.go @@ -10,7 +10,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/connector" "go.opentelemetry.io/collector/connector/connectorprofiles" @@ -19,6 +18,7 @@ import ( "go.opentelemetry.io/collector/consumer/consumerprofiles" "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/pdata/testdata" + "go.opentelemetry.io/collector/pipeline" ) func TestExampleRouter(t *testing.T) { @@ -34,8 +34,8 @@ func TestExampleRouter(t *testing.T) { } func TestTracesRouter(t *testing.T) { - leftID := component.MustNewIDWithName("sink", "left") - rightID := component.MustNewIDWithName("sink", "right") + leftID := pipeline.MustNewIDWithName("sink", "left") + rightID := pipeline.MustNewIDWithName("sink", "right") sinkLeft := new(consumertest.TracesSink) sinkRight := new(consumertest.TracesSink) @@ -44,7 +44,7 @@ func TestTracesRouter(t *testing.T) { // Many connectors will just call router.ConsumeTraces, // but some implementation will call RouteTraces instead. router := connector.NewTracesRouter( - map[component.ID]consumer.Traces{ + map[pipeline.ID]consumer.Traces{ leftID: sinkLeft, rightID: sinkRight, }) @@ -73,8 +73,8 @@ func TestTracesRouter(t *testing.T) { } func TestMetricsRouter(t *testing.T) { - leftID := component.MustNewIDWithName("sink", "left") - rightID := component.MustNewIDWithName("sink", "right") + leftID := pipeline.MustNewIDWithName("sink", "left") + rightID := pipeline.MustNewIDWithName("sink", "right") sinkLeft := new(consumertest.MetricsSink) sinkRight := new(consumertest.MetricsSink) @@ -83,7 +83,7 @@ func TestMetricsRouter(t *testing.T) { // Many connectors will just call router.ConsumeMetrics, // but some implementation will call RouteMetrics instead. router := connector.NewMetricsRouter( - map[component.ID]consumer.Metrics{ + map[pipeline.ID]consumer.Metrics{ leftID: sinkLeft, rightID: sinkRight, }) @@ -112,8 +112,8 @@ func TestMetricsRouter(t *testing.T) { } func TestLogsRouter(t *testing.T) { - leftID := component.MustNewIDWithName("sink", "left") - rightID := component.MustNewIDWithName("sink", "right") + leftID := pipeline.MustNewIDWithName("sink", "left") + rightID := pipeline.MustNewIDWithName("sink", "right") sinkLeft := new(consumertest.LogsSink) sinkRight := new(consumertest.LogsSink) @@ -122,7 +122,7 @@ func TestLogsRouter(t *testing.T) { // Many connectors will just call router.ConsumeLogs, // but some implementation will call RouteLogs instead. router := connector.NewLogsRouter( - map[component.ID]consumer.Logs{ + map[pipeline.ID]consumer.Logs{ leftID: sinkLeft, rightID: sinkRight, }) @@ -151,8 +151,8 @@ func TestLogsRouter(t *testing.T) { } func TestProfilesRouter(t *testing.T) { - leftID := component.MustNewIDWithName("sink", "left") - rightID := component.MustNewIDWithName("sink", "right") + leftID := pipeline.MustNewIDWithName("sink", "left") + rightID := pipeline.MustNewIDWithName("sink", "right") sinkLeft := new(consumertest.ProfilesSink) sinkRight := new(consumertest.ProfilesSink) @@ -161,7 +161,7 @@ func TestProfilesRouter(t *testing.T) { // Many connectors will just call router.ConsumeProfiles, // but some implementation will call RouteProfiles instead. router := connectorprofiles.NewProfilesRouter( - map[component.ID]consumerprofiles.Profiles{ + map[pipeline.ID]consumerprofiles.Profiles{ leftID: sinkLeft, rightID: sinkRight, }) diff --git a/service/pipelines/config.go b/service/pipelines/config.go index 66698539d5b..dd37e696039 100644 --- a/service/pipelines/config.go +++ b/service/pipelines/config.go @@ -9,6 +9,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componentprofiles" + "go.opentelemetry.io/collector/pipeline" ) var ( @@ -18,6 +19,8 @@ var ( ) // Config defines the configurable settings for service telemetry. +// +// Deprecated: [v0.110.0] Use ConfigWithPipelineID instead type Config map[component.ID]*PipelineConfig func (cfg Config) Validate() error { @@ -28,8 +31,9 @@ func (cfg Config) Validate() error { // Check that all pipelines have at least one receiver and one exporter, and they reference // only configured components. - for pipelineID, pipeline := range cfg { + for pipelineID, p := range cfg { switch pipelineID.Type() { + // nolint case component.DataTypeTraces, component.DataTypeMetrics, component.DataTypeLogs, componentprofiles.DataTypeProfiles: // Continue default: @@ -37,7 +41,7 @@ func (cfg Config) Validate() error { } // Validate pipeline has at least one receiver. - if err := pipeline.Validate(); err != nil { + if err := p.Validate(); err != nil { return fmt.Errorf("pipeline %q: %w", pipelineID, err) } } @@ -45,6 +49,33 @@ func (cfg Config) Validate() error { return nil } +type ConfigWithPipelineID map[pipeline.ID]*PipelineConfig + +func (cfg ConfigWithPipelineID) Validate() error { + // Must have at least one pipeline. + if len(cfg) == 0 { + return errMissingServicePipelines + } + + // Check that all pipelines have at least one receiver and one exporter, and they reference + // only configured components. + for pipelineID, p := range cfg { + switch pipelineID.Signal() { + case pipeline.SignalTraces, pipeline.SignalMetrics, pipeline.SignalLogs, componentprofiles.SignalProfiles: + // Continue + default: + return fmt.Errorf("pipeline %q: unknown signal %q", pipelineID.String(), pipelineID.Signal()) + } + + // Validate pipeline has at least one receiver. + if err := p.Validate(); err != nil { + return fmt.Errorf("pipeline %q: %w", pipelineID.String(), err) + } + } + + return nil +} + // PipelineConfig defines the configuration of a Pipeline. type PipelineConfig struct { Receivers []component.ID `mapstructure:"receivers"` diff --git a/service/pipelines/config_test.go b/service/pipelines/config_test.go index d4b5503e3a9..2ec239ac54b 100644 --- a/service/pipelines/config_test.go +++ b/service/pipelines/config_test.go @@ -11,12 +11,13 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/pipeline" ) func TestConfigValidate(t *testing.T) { var testCases = []struct { name string // test case name (also file name containing config yaml) - cfgFn func() Config + cfgFn func() ConfigWithPipelineID expected error }{ { @@ -26,9 +27,9 @@ func TestConfigValidate(t *testing.T) { }, { name: "duplicate-processor-reference", - cfgFn: func() Config { + cfgFn: func() ConfigWithPipelineID { cfg := generateConfig() - pipe := cfg[component.MustNewID("traces")] + pipe := cfg[pipeline.MustNewID("traces")] pipe.Processors = append(pipe.Processors, pipe.Processors...) return cfg }, @@ -36,41 +37,41 @@ func TestConfigValidate(t *testing.T) { }, { name: "missing-pipeline-receivers", - cfgFn: func() Config { + cfgFn: func() ConfigWithPipelineID { cfg := generateConfig() - cfg[component.MustNewID("traces")].Receivers = nil + cfg[pipeline.MustNewID("traces")].Receivers = nil return cfg }, expected: fmt.Errorf(`pipeline "traces": %w`, errMissingServicePipelineReceivers), }, { name: "missing-pipeline-exporters", - cfgFn: func() Config { + cfgFn: func() ConfigWithPipelineID { cfg := generateConfig() - cfg[component.MustNewID("traces")].Exporters = nil + cfg[pipeline.MustNewID("traces")].Exporters = nil return cfg }, expected: fmt.Errorf(`pipeline "traces": %w`, errMissingServicePipelineExporters), }, { name: "missing-pipelines", - cfgFn: func() Config { + cfgFn: func() ConfigWithPipelineID { return nil }, expected: errMissingServicePipelines, }, { name: "invalid-service-pipeline-type", - cfgFn: func() Config { + cfgFn: func() ConfigWithPipelineID { cfg := generateConfig() - cfg[component.MustNewID("wrongtype")] = &PipelineConfig{ + cfg[pipeline.MustNewID("wrongtype")] = &PipelineConfig{ Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("nop")}, } return cfg }, - expected: errors.New(`pipeline "wrongtype": unknown datatype "wrongtype"`), + expected: errors.New(`pipeline "wrongtype": unknown signal "wrongtype"`), }, } @@ -82,9 +83,9 @@ func TestConfigValidate(t *testing.T) { } } -func generateConfig() Config { - return map[component.ID]*PipelineConfig{ - component.MustNewID("traces"): { +func generateConfig() ConfigWithPipelineID { + return map[pipeline.ID]*PipelineConfig{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.MustNewID("nop")}, Processors: []component.ID{component.MustNewID("nop")}, Exporters: []component.ID{component.MustNewID("nop")}, diff --git a/service/service.go b/service/service.go index 5874b72f8d1..bf17b418398 100644 --- a/service/service.go +++ b/service/service.go @@ -26,6 +26,7 @@ import ( "go.opentelemetry.io/collector/featuregate" "go.opentelemetry.io/collector/internal/globalgates" "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/processor" "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/service/extensions" @@ -34,6 +35,7 @@ import ( "go.opentelemetry.io/collector/service/internal/proctelemetry" "go.opentelemetry.io/collector/service/internal/resource" "go.opentelemetry.io/collector/service/internal/status" + "go.opentelemetry.io/collector/service/pipelines" "go.opentelemetry.io/collector/service/telemetry" ) @@ -303,8 +305,19 @@ func (srv *Service) initExtensions(ctx context.Context, cfg extensions.Config) e return nil } +func convertFromComponentIDToPipelineID(id component.ID) pipeline.ID { + return pipeline.MustNewIDWithName(id.Type().String(), id.Name()) +} + // Creates the pipeline graph. func (srv *Service) initGraph(ctx context.Context, cfg Config) error { + if len(cfg.Pipelines) > 0 { + cfg.PipelinesWithPipelineID = make(pipelines.ConfigWithPipelineID, len(cfg.Pipelines)) + for k, v := range cfg.Pipelines { + cfg.PipelinesWithPipelineID[convertFromComponentIDToPipelineID(k)] = v + } + } + var err error if srv.host.Pipelines, err = graph.Build(ctx, graph.Settings{ Telemetry: srv.telemetrySettings, @@ -313,7 +326,7 @@ func (srv *Service) initGraph(ctx context.Context, cfg Config) error { ProcessorBuilder: srv.host.Processors, ExporterBuilder: srv.host.Exporters, ConnectorBuilder: srv.host.Connectors, - PipelineConfigs: cfg.Pipelines, + PipelineConfigs: cfg.PipelinesWithPipelineID, ReportStatus: srv.host.Reporter.ReportStatus, }); err != nil { return fmt.Errorf("failed to build pipelines: %w", err) diff --git a/service/service_test.go b/service/service_test.go index 41e5e046b61..07e8e52cadb 100644 --- a/service/service_test.go +++ b/service/service_test.go @@ -31,6 +31,7 @@ import ( "go.opentelemetry.io/collector/extension/zpagesextension" "go.opentelemetry.io/collector/internal/testutil" "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pipeline" "go.opentelemetry.io/collector/service/extensions" "go.opentelemetry.io/collector/service/internal/builders" "go.opentelemetry.io/collector/service/internal/promtest" @@ -218,6 +219,7 @@ func TestServiceGetExtensions(t *testing.T) { assert.Contains(t, extMap, component.NewID(nopType)) } +// nolint func TestServiceGetExporters(t *testing.T) { srv, err := New(context.Background(), newNopSettings(), newNopConfig()) require.NoError(t, err) @@ -227,8 +229,12 @@ func TestServiceGetExporters(t *testing.T) { assert.NoError(t, srv.Shutdown(context.Background())) }) - // nolint expMap := srv.host.GetExporters() + + v, ok := expMap[component.DataTypeTraces] + assert.True(t, ok) + assert.NotNil(t, v) + assert.Len(t, expMap, 4) assert.Len(t, expMap[component.DataTypeTraces], 1) assert.Contains(t, expMap[component.DataTypeTraces], component.NewID(nopType)) @@ -244,7 +250,7 @@ func TestServiceGetExporters(t *testing.T) { // and another service with a valid config can be started right after. func TestServiceTelemetryCleanupOnError(t *testing.T) { invalidCfg := newNopConfig() - invalidCfg.Pipelines[component.MustNewID("traces")].Processors[0] = component.MustNewID("invalid") + invalidCfg.PipelinesWithPipelineID[pipeline.MustNewID("traces")].Processors[0] = component.MustNewID("invalid") // Create a service with an invalid config and expect an error _, err := New(context.Background(), newNopSettings(), invalidCfg) require.Error(t, err) @@ -663,23 +669,23 @@ func newNopSettings() Settings { } func newNopConfig() Config { - return newNopConfigPipelineConfigs(pipelines.Config{ - component.MustNewID("traces"): { + return newNopConfigPipelineConfigs(pipelines.ConfigWithPipelineID{ + pipeline.MustNewID("traces"): { Receivers: []component.ID{component.NewID(nopType)}, Processors: []component.ID{component.NewID(nopType)}, Exporters: []component.ID{component.NewID(nopType)}, }, - component.MustNewID("metrics"): { + pipeline.MustNewID("metrics"): { Receivers: []component.ID{component.NewID(nopType)}, Processors: []component.ID{component.NewID(nopType)}, Exporters: []component.ID{component.NewID(nopType)}, }, - component.MustNewID("logs"): { + pipeline.MustNewID("logs"): { Receivers: []component.ID{component.NewID(nopType)}, Processors: []component.ID{component.NewID(nopType)}, Exporters: []component.ID{component.NewID(nopType)}, }, - component.MustNewID("profiles"): { + pipeline.MustNewID("profiles"): { Receivers: []component.ID{component.NewID(nopType)}, Processors: []component.ID{component.NewID(nopType)}, Exporters: []component.ID{component.NewID(nopType)}, @@ -687,10 +693,10 @@ func newNopConfig() Config { }) } -func newNopConfigPipelineConfigs(pipelineCfgs pipelines.Config) Config { +func newNopConfigPipelineConfigs(pipelineCfgs pipelines.ConfigWithPipelineID) Config { return Config{ - Extensions: extensions.Config{component.NewID(nopType)}, - Pipelines: pipelineCfgs, + Extensions: extensions.Config{component.NewID(nopType)}, + PipelinesWithPipelineID: pipelineCfgs, Telemetry: telemetry.Config{ Logs: telemetry.LogsConfig{ Level: zapcore.InfoLevel,