Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stability levels to components output #8289

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .chloggen/components-command-with-stability-levels.yaml
Original file line number Diff line number Diff line change
@@ -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: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: components command

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: The "components" command now lists the component's stability levels.

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

# (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: Note that the format of this output is NOT stable and can change between versions.

# 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: []
67 changes: 57 additions & 10 deletions otelcol/command_components.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,85 @@ import (
"go.opentelemetry.io/collector/component"
)

type componentWithStability struct {
Name component.Type
Stability map[string]string
}

type componentsOutput struct {
BuildInfo component.BuildInfo
Receivers []component.Type
Processors []component.Type
Exporters []component.Type
Connectors []component.Type
Extensions []component.Type
Receivers []componentWithStability
Processors []componentWithStability
Exporters []componentWithStability
Connectors []componentWithStability
Extensions []componentWithStability
}

// newComponentsCommand constructs a new components command using the given CollectorSettings.
func newComponentsCommand(set CollectorSettings) *cobra.Command {
return &cobra.Command{
Use: "components",
Short: "Outputs available components in this collector distribution",
Long: "Outputs available components in this collector distribution including their stability levels. The output format is not stable and can change between releases.",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {

components := componentsOutput{}
for con := range set.Factories.Connectors {
components.Connectors = append(components.Connectors, con)
components.Connectors = append(components.Connectors, componentWithStability{
Name: con,
Stability: map[string]string{
"logs-to-logs": set.Factories.Connectors[con].LogsToLogsStability().String(),
"logs-to-metrics": set.Factories.Connectors[con].LogsToMetricsStability().String(),
"logs-to-traces": set.Factories.Connectors[con].LogsToTracesStability().String(),

"metrics-to-logs": set.Factories.Connectors[con].MetricsToLogsStability().String(),
"metrics-to-metrics": set.Factories.Connectors[con].MetricsToMetricsStability().String(),
"metrics-to-traces": set.Factories.Connectors[con].MetricsToTracesStability().String(),

"traces-to-logs": set.Factories.Connectors[con].TracesToLogsStability().String(),
"traces-to-metrics": set.Factories.Connectors[con].TracesToMetricsStability().String(),
"traces-to-traces": set.Factories.Connectors[con].TracesToTracesStability().String(),
},
})
}
for ext := range set.Factories.Extensions {
components.Extensions = append(components.Extensions, ext)
components.Extensions = append(components.Extensions, componentWithStability{
Name: ext,
Stability: map[string]string{
"extension": set.Factories.Extensions[ext].ExtensionStability().String(),
},
})
}
for prs := range set.Factories.Processors {
components.Processors = append(components.Processors, prs)
components.Processors = append(components.Processors, componentWithStability{
Name: prs,
Stability: map[string]string{
"logs": set.Factories.Processors[prs].LogsProcessorStability().String(),
"metrics": set.Factories.Processors[prs].MetricsProcessorStability().String(),
"traces": set.Factories.Processors[prs].TracesProcessorStability().String(),
},
})
}
for rcv := range set.Factories.Receivers {
components.Receivers = append(components.Receivers, rcv)
components.Receivers = append(components.Receivers, componentWithStability{
Name: rcv,
Stability: map[string]string{
"logs": set.Factories.Receivers[rcv].LogsReceiverStability().String(),
"metrics": set.Factories.Receivers[rcv].MetricsReceiverStability().String(),
"traces": set.Factories.Receivers[rcv].TracesReceiverStability().String(),
},
})
}
for exp := range set.Factories.Exporters {
components.Exporters = append(components.Exporters, exp)
components.Exporters = append(components.Exporters, componentWithStability{
Name: exp,
Stability: map[string]string{
"logs": set.Factories.Exporters[exp].LogsExporterStability().String(),
"metrics": set.Factories.Exporters[exp].MetricsExporterStability().String(),
"traces": set.Factories.Exporters[exp].TracesExporterStability().String(),
},
})
}
components.BuildInfo = set.BuildInfo
yamlData, err := yaml.Marshal(components)
Expand Down
53 changes: 47 additions & 6 deletions otelcol/command_components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,53 @@ func TestNewBuildSubCommand(t *testing.T) {
cmd.SetArgs([]string{"components"})

ExpectedYamlStruct := componentsOutput{
BuildInfo: component.NewDefaultBuildInfo(),
Receivers: []component.Type{"nop"},
Processors: []component.Type{"nop"},
Exporters: []component.Type{"nop"},
Connectors: []component.Type{"nop"},
Extensions: []component.Type{"nop"},
BuildInfo: component.NewDefaultBuildInfo(),
Receivers: []componentWithStability{{
Name: component.Type("nop"),
Stability: map[string]string{
"logs": "Stable",
"metrics": "Stable",
"traces": "Stable",
},
}},
Processors: []componentWithStability{{
Name: component.Type("nop"),
Stability: map[string]string{
"logs": "Stable",
"metrics": "Stable",
"traces": "Stable",
},
}},
Exporters: []componentWithStability{{
Name: component.Type("nop"),
Stability: map[string]string{
"logs": "Stable",
"metrics": "Stable",
"traces": "Stable",
},
}},
Connectors: []componentWithStability{{
Name: component.Type("nop"),
Stability: map[string]string{
"logs-to-logs": "Development",
"logs-to-metrics": "Development",
"logs-to-traces": "Development",

"metrics-to-logs": "Development",
"metrics-to-metrics": "Development",
"metrics-to-traces": "Development",

"traces-to-logs": "Development",
"traces-to-metrics": "Development",
"traces-to-traces": "Development",
},
}},
Extensions: []componentWithStability{{
Name: component.Type("nop"),
Stability: map[string]string{
"extension": "Stable",
},
}},
}
ExpectedOutput, err := yaml.Marshal(ExpectedYamlStruct)
require.NoError(t, err)
Expand Down
Loading