File tree 2 files changed +47
-0
lines changed
2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,11 @@ func NewCommand(set CollectorSettings) *cobra.Command {
42
42
return rootCmd
43
43
}
44
44
45
+ // Helper function for "make features" commmand for Jaeger
46
+ func FeatureCommand (set CollectorSettings ) {
47
+ featureflags (featuregate .GlobalRegistry ())
48
+ }
49
+
45
50
// Puts command line flags from flags into the CollectorSettings, to be used during config resolution.
46
51
func updateSettingsUsingFlags (set * CollectorSettings , flags * flag.FlagSet ) error {
47
52
resolverSet := & set .ConfigProviderSettings .ResolverSettings
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ package otelcol // import "go.opentelemetry.io/collector/otelcol"
6
6
import (
7
7
"errors"
8
8
"flag"
9
+ "fmt"
9
10
"strings"
10
11
11
12
"go.opentelemetry.io/collector/featuregate"
@@ -15,6 +16,10 @@ const (
15
16
configFlag = "config"
16
17
)
17
18
19
+ type flagValue struct {
20
+ reg * featuregate.Registry
21
+ }
22
+
18
23
type configFlagValue struct {
19
24
values []string
20
25
sets []string
@@ -53,6 +58,43 @@ func flags(reg *featuregate.Registry) *flag.FlagSet {
53
58
return flagSet
54
59
}
55
60
61
+ // Function to beautify and print the feature flags.
62
+ func featureflags (reg * featuregate.Registry ) {
63
+ f := & flagValue {reg : reg }
64
+ if f .reg == nil {
65
+ return
66
+ }
67
+ c := 1
68
+
69
+ f .reg .VisitAll (func (g * featuregate.Gate ) {
70
+ str := ""
71
+ id := g .ID ()
72
+ desc := g .Description ()
73
+ if ! g .IsEnabled () {
74
+ id = "-" + id
75
+ }
76
+ str += fmt .Sprint (c ) + "." + id + "\n "
77
+ str += "Description: " + desc + "\n "
78
+ ref := g .ReferenceURL ()
79
+ from := g .FromVersion ()
80
+ to := g .ToVersion ()
81
+ if (ref != "" ){
82
+ str += "ReferenceURL: " + ref + "\n "
83
+ }
84
+ if (from != "v<nil>" ){
85
+ str += "From version: " + from + "\n "
86
+
87
+ }
88
+ if (to != "v<nil>" ){
89
+ str += "From version: " + to + "\n "
90
+
91
+ }
92
+ // str += "\n"
93
+ c += 1
94
+ fmt .Println (str )
95
+ })
96
+ }
97
+
56
98
func getConfigFlag (flagSet * flag.FlagSet ) []string {
57
99
cfv := flagSet .Lookup (configFlag ).Value .(* configFlagValue )
58
100
return append (cfv .values , cfv .sets ... )
You can’t perform that action at this time.
0 commit comments