Skip to content

Commit

Permalink
Add connectors to the components command
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-bradley committed Jun 1, 2023
1 parent 9104611 commit e7ccf85
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 4 deletions.
16 changes: 16 additions & 0 deletions .chloggen/add-connectors-to-components-command.yaml
Original file line number Diff line number Diff line change
@@ -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: otelcol

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add connectors to output of the `components` command

# One or more tracking issues or pull requests related to the change
issues: [7809]

# (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:
4 changes: 4 additions & 0 deletions otelcol/command_components.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type componentsOutput struct {
Receivers []component.Type
Processors []component.Type
Exporters []component.Type
Connectors []component.Type
Extensions []component.Type
}

Expand All @@ -29,6 +30,9 @@ func newBuildSubCommand(set CollectorSettings) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {

components := componentsOutput{}
for con := range set.Factories.Connectors {
components.Connectors = append(components.Connectors, con)
}
for ext := range set.Factories.Extensions {
components.Extensions = append(components.Extensions, ext)
}
Expand Down
1 change: 1 addition & 0 deletions otelcol/command_components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func TestNewBuildSubCommand(t *testing.T) {
Receivers: []component.Type{"nop"},
Processors: []component.Type{"nop"},
Exporters: []component.Type{"nop"},
Connectors: []component.Type{"nop"},
Extensions: []component.Type{"nop"},
}
ExpectedOutput, err := yaml.Marshal(ExpectedYamlStruct)
Expand Down
6 changes: 4 additions & 2 deletions otelcol/configprovider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/confmap/provider/fileprovider"
"go.opentelemetry.io/collector/confmap/provider/yamlprovider"
"go.opentelemetry.io/collector/connector/connectortest"
"go.opentelemetry.io/collector/exporter/exportertest"
"go.opentelemetry.io/collector/extension/extensiontest"
"go.opentelemetry.io/collector/processor/processortest"
Expand All @@ -30,22 +31,23 @@ var configNop = &Config{
Receivers: map[component.ID]component.Config{component.NewID("nop"): receivertest.NewNopFactory().CreateDefaultConfig()},
Processors: map[component.ID]component.Config{component.NewID("nop"): processortest.NewNopFactory().CreateDefaultConfig()},
Exporters: map[component.ID]component.Config{component.NewID("nop"): exportertest.NewNopFactory().CreateDefaultConfig()},
Connectors: map[component.ID]component.Config{component.NewIDWithName("nop", "con"): connectortest.NewNopFactory().CreateDefaultConfig()},
Extensions: map[component.ID]component.Config{component.NewID("nop"): extensiontest.NewNopFactory().CreateDefaultConfig()},
Service: service.Config{
Extensions: []component.ID{component.NewID("nop")},
Pipelines: map[component.ID]*service.PipelineConfig{
component.NewID("traces"): {
Receivers: []component.ID{component.NewID("nop")},
Processors: []component.ID{component.NewID("nop")},
Exporters: []component.ID{component.NewID("nop")},
Exporters: []component.ID{component.NewID("nop"), component.NewIDWithName("nop", "con")},
},
component.NewID("metrics"): {
Receivers: []component.ID{component.NewID("nop")},
Processors: []component.ID{component.NewID("nop")},
Exporters: []component.ID{component.NewID("nop")},
},
component.NewID("logs"): {
Receivers: []component.ID{component.NewID("nop")},
Receivers: []component.ID{component.NewID("nop"), component.NewIDWithName("nop", "con")},
Processors: []component.ID{component.NewID("nop")},
Exporters: []component.ID{component.NewID("nop")},
},
Expand Down
6 changes: 6 additions & 0 deletions otelcol/factories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
package otelcol

import (
"go.opentelemetry.io/collector/connector"
"go.opentelemetry.io/collector/connector/connectortest"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exportertest"
"go.opentelemetry.io/collector/extension"
Expand All @@ -18,6 +20,10 @@ func nopFactories() (Factories, error) {
var factories Factories
var err error

if factories.Connectors, err = connector.MakeFactoryMap(connectortest.NewNopFactory()); err != nil {
return Factories{}, err
}

if factories.Extensions, err = extension.MakeFactoryMap(extensiontest.NewNopFactory()); err != nil {
return Factories{}, err
}
Expand Down
7 changes: 5 additions & 2 deletions otelcol/testdata/otelcol-nop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ exporters:
extensions:
nop:

connectors:
nop/con:

service:
telemetry:
metrics:
Expand All @@ -19,12 +22,12 @@ service:
traces:
receivers: [nop]
processors: [nop]
exporters: [nop]
exporters: [nop, nop/con]
metrics:
receivers: [nop]
processors: [nop]
exporters: [nop]
logs:
receivers: [nop]
receivers: [nop, nop/con]
processors: [nop]
exporters: [nop]

0 comments on commit e7ccf85

Please sign in to comment.