From e3e50d371a80007b90b595963013060ed042dcfc Mon Sep 17 00:00:00 2001 From: Dan Jaglowski Date: Fri, 18 Nov 2022 09:29:03 -0500 Subject: [PATCH] Define new component type "connector" This establishes the new component type without including anything specific about the design of connectors. --- .chloggen/connector-component.yaml | 16 +++++++++++ component/component.go | 1 + config/connector.go | 46 ++++++++++++++++++++++++++++++ connector/connector.go | 37 ++++++++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100755 .chloggen/connector-component.yaml create mode 100644 config/connector.go create mode 100644 connector/connector.go diff --git a/.chloggen/connector-component.yaml b/.chloggen/connector-component.yaml new file mode 100755 index 00000000000..ab99af78308 --- /dev/null +++ b/.chloggen/connector-component.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# 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: Define new component type 'connectors' + +# One or more tracking issues or pull requests related to the change +issues: [6577] + +# (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: diff --git a/component/component.go b/component/component.go index e651f56595f..e393f1cf775 100644 --- a/component/component.go +++ b/component/component.go @@ -104,6 +104,7 @@ const ( KindProcessor KindExporter KindExtension + KindConnector ) // StabilityLevel represents the stability level of the component created by the factory. diff --git a/config/connector.go b/config/connector.go new file mode 100644 index 00000000000..ded0394b777 --- /dev/null +++ b/config/connector.go @@ -0,0 +1,46 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package config // import "go.opentelemetry.io/collector/config" + +import ( + "go.opentelemetry.io/collector/component" +) + +// ConnectorSettings defines common settings for a component.Connector configuration. +// Specific connectors can embed this struct and extend it with more fields if needed. +// +// It is highly recommended to "override" the Validate() function. +// +// When embedded in the exporter config, it must be with `mapstructure:",squash"` tag. +type ConnectorSettings struct { + settings +} + +// NewConnectorSettings return a new ConnectorSettings with the given ComponentID. +func NewConnectorSettings(id component.ID) ConnectorSettings { + return ConnectorSettings{settings: newSettings(id)} +} + +var _ component.Config = (*ConnectorSettings)(nil) + +// ID returns the connector ComponentID. +func (cs *ConnectorSettings) ID() component.ID { + return cs.id +} + +// SetIDName sets the connector name. +func (cs *ConnectorSettings) SetIDName(idName string) { + cs.id = component.NewIDWithName(cs.id.Type(), idName) +} diff --git a/connector/connector.go b/connector/connector.go new file mode 100644 index 00000000000..9c172e47bd2 --- /dev/null +++ b/connector/connector.go @@ -0,0 +1,37 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package connector // import "go.opentelemetry.io/collector/connector" + +import ( + "go.opentelemetry.io/collector/component" +) + +// Connector sends telemetry data from one pipeline to another. A connector +// is both an exporter and receiver, working together to connect pipelines. +// The purpose is to allow for differentiated processing of telemetry data. +// +// Connectors can be used to replicate or route data, merge data streams, +// derive signals from other signals, etc. +type Connector interface { + component.Component +} + +// CreateSettings configures Connector creators. +type CreateSettings struct { + TelemetrySettings component.TelemetrySettings + + // BuildInfo can be used by components for informational purposes + BuildInfo component.BuildInfo +}