forked from open-telemetry/opentelemetry-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
command_components.go
109 lines (98 loc) · 3.96 KB
/
command_components.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package otelcol // import "go.opentelemetry.io/collector/otelcol"
import (
"fmt"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
"go.opentelemetry.io/collector/component"
)
type componentWithStability struct {
Name component.Type
Stability map[string]string
}
type componentsOutput struct {
BuildInfo component.BuildInfo
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 {
factories, err := set.Factories()
if err != nil {
return fmt.Errorf("failed to initialize factories: %w", err)
}
components := componentsOutput{}
for con := range factories.Connectors {
components.Connectors = append(components.Connectors, componentWithStability{
Name: con,
Stability: map[string]string{
"logs-to-logs": factories.Connectors[con].LogsToLogsStability().String(),
"logs-to-metrics": factories.Connectors[con].LogsToMetricsStability().String(),
"logs-to-traces": factories.Connectors[con].LogsToTracesStability().String(),
"metrics-to-logs": factories.Connectors[con].MetricsToLogsStability().String(),
"metrics-to-metrics": factories.Connectors[con].MetricsToMetricsStability().String(),
"metrics-to-traces": factories.Connectors[con].MetricsToTracesStability().String(),
"traces-to-logs": factories.Connectors[con].TracesToLogsStability().String(),
"traces-to-metrics": factories.Connectors[con].TracesToMetricsStability().String(),
"traces-to-traces": factories.Connectors[con].TracesToTracesStability().String(),
},
})
}
for ext := range factories.Extensions {
components.Extensions = append(components.Extensions, componentWithStability{
Name: ext,
Stability: map[string]string{
"extension": factories.Extensions[ext].ExtensionStability().String(),
},
})
}
for prs := range factories.Processors {
components.Processors = append(components.Processors, componentWithStability{
Name: prs,
Stability: map[string]string{
"logs": factories.Processors[prs].LogsProcessorStability().String(),
"metrics": factories.Processors[prs].MetricsProcessorStability().String(),
"traces": factories.Processors[prs].TracesProcessorStability().String(),
},
})
}
for rcv := range factories.Receivers {
components.Receivers = append(components.Receivers, componentWithStability{
Name: rcv,
Stability: map[string]string{
"logs": factories.Receivers[rcv].LogsReceiverStability().String(),
"metrics": factories.Receivers[rcv].MetricsReceiverStability().String(),
"traces": factories.Receivers[rcv].TracesReceiverStability().String(),
},
})
}
for exp := range factories.Exporters {
components.Exporters = append(components.Exporters, componentWithStability{
Name: exp,
Stability: map[string]string{
"logs": factories.Exporters[exp].LogsExporterStability().String(),
"metrics": factories.Exporters[exp].MetricsExporterStability().String(),
"traces": factories.Exporters[exp].TracesExporterStability().String(),
},
})
}
components.BuildInfo = set.BuildInfo
yamlData, err := yaml.Marshal(components)
if err != nil {
return err
}
fmt.Fprint(cmd.OutOrStdout(), string(yamlData))
return nil
},
}
}