Skip to content

Commit

Permalink
Add stability levels to components output
Browse files Browse the repository at this point in the history
Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
  • Loading branch information
jpkrohling committed Aug 28, 2023
1 parent 92f5fe6 commit e25788e
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 16 deletions.
66 changes: 56 additions & 10 deletions otelcol/command_components.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ import (
"go.opentelemetry.io/collector/component"
)

type componentWithStability struct {
Name component.Type
StabilityLevels 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.
Expand All @@ -31,19 +36,60 @@ func newComponentsCommand(set CollectorSettings) *cobra.Command {

components := componentsOutput{}
for con := range set.Factories.Connectors {
components.Connectors = append(components.Connectors, con)
components.Connectors = append(components.Connectors, componentWithStability{
Name: con,
StabilityLevels: map[string]string{
"logstologs": set.Factories.Connectors[con].LogsToLogsStability().String(),
"logstometrics": set.Factories.Connectors[con].LogsToMetricsStability().String(),
"logstotraces": set.Factories.Connectors[con].LogsToTracesStability().String(),

"metricstologs": set.Factories.Connectors[con].MetricsToLogsStability().String(),
"metricstometrics": set.Factories.Connectors[con].MetricsToMetricsStability().String(),
"metricstotraces": set.Factories.Connectors[con].MetricsToTracesStability().String(),

"tracestologs": set.Factories.Connectors[con].TracesToLogsStability().String(),
"tracestometrics": set.Factories.Connectors[con].TracesToMetricsStability().String(),
"tracestotraces": 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,
StabilityLevels: 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,
StabilityLevels: 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,
StabilityLevels: 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,
StabilityLevels: 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"),
StabilityLevels: map[string]string{
"logs": "Stable",
"metrics": "Stable",
"traces": "Stable",
},
}},
Processors: []componentWithStability{{
Name: component.Type("nop"),
StabilityLevels: map[string]string{
"logs": "Stable",
"metrics": "Stable",
"traces": "Stable",
},
}},
Exporters: []componentWithStability{{
Name: component.Type("nop"),
StabilityLevels: map[string]string{
"logs": "Stable",
"metrics": "Stable",
"traces": "Stable",
},
}},
Connectors: []componentWithStability{{
Name: component.Type("nop"),
StabilityLevels: map[string]string{
"logstologs": "Development",
"logstometrics": "Development",
"logstotraces": "Development",

"metricstologs": "Development",
"metricstometrics": "Development",
"metricstotraces": "Development",

"tracestologs": "Development",
"tracestometrics": "Development",
"tracestotraces": "Development",
},
}},
Extensions: []componentWithStability{{
Name: component.Type("nop"),
StabilityLevels: map[string]string{
"extension": "Stable",
},
}},
}
ExpectedOutput, err := yaml.Marshal(ExpectedYamlStruct)
require.NoError(t, err)
Expand Down

0 comments on commit e25788e

Please sign in to comment.