Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: danish9039 <[email protected]>
  • Loading branch information
danish9039 committed Jan 6, 2025
1 parent dde94a2 commit 3afa8e3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 59 deletions.
56 changes: 43 additions & 13 deletions otelcol/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ package otelcol // import "go.opentelemetry.io/collector/otelcol"
import (
"errors"
"flag"

"fmt"
"text/tabwriter"
"os"
"github.com/spf13/cobra"

"go.opentelemetry.io/collector/featuregate"
"go.opentelemetry.io/collector/service"
//"go.opentelemetry.io/collector/service"
)

// NewCommand constructs a new cobra.Command using the given CollectorSettings.
Expand Down Expand Up @@ -67,15 +69,43 @@ func updateSettingsUsingFlags(set *CollectorSettings, flags *flag.FlagSet) error
}

func newFeaturesCommand() *cobra.Command {
return &cobra.Command{
Use: "features [feature-id]",
Short: "Display feature gates information",
Long: "Display information about available feature gates and their status",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
return service.DisplayFeature(args[0])
}
return service.DisplayFeatures()
},
}
return &cobra.Command{
Use: "features [feature-id]",
Short: "Display feature gates information",
Long: "Display information about available feature gates and their status",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
found := false
featuregate.GlobalRegistry().VisitAll(func(g *featuregate.Gate) {
if g.ID() == args[0] {
found = true
fmt.Printf("Feature: %s\n", g.ID())
fmt.Printf("Enabled: %v\n", g.IsEnabled())
fmt.Printf("Stage: %s\n", g.Stage())
fmt.Printf("Description: %s\n", g.Description())
fmt.Printf("From Version: %s\n", g.FromVersion())
if g.ToVersion() != "" {
fmt.Printf("To Version: %s\n", g.ToVersion())
}
}
})
if !found {
return fmt.Errorf("feature %q not found", args[0])
}
return nil
}

w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintf(w, "ID\tEnabled\tStage\tDescription\n")
featuregate.GlobalRegistry().VisitAll(func(g *featuregate.Gate) {
fmt.Fprintf(w, "%s\t%v\t%s\t%s\n",
g.ID(),
g.IsEnabled(),
g.Stage(),
g.Description())
})
return w.Flush()
},
}
}

44 changes: 0 additions & 44 deletions service/display_feature.go

This file was deleted.

4 changes: 2 additions & 2 deletions service/internal/graph/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ func (host *Host) zPagesRequest(w http.ResponseWriter, _ *http.Request) {
func handleFeaturezRequest(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
zpages.WriteHTMLPageHeader(w, zpages.HeaderData{Title: "Feature Gates"})
zpages.WriteHTMLFeaturesTable(w, GetFeaturesTableData())
zpages.WriteHTMLFeaturesTable(w, getFeaturesTableData())
zpages.WriteHTMLPageFooter(w)
}

func GetFeaturesTableData() zpages.FeatureGateTableData {
func getFeaturesTableData() zpages.FeatureGateTableData {
data := zpages.FeatureGateTableData{}
featuregate.GlobalRegistry().VisitAll(func(gate *featuregate.Gate) {
data.Rows = append(data.Rows, zpages.FeatureGateTableRowData{
Expand Down

0 comments on commit 3afa8e3

Please sign in to comment.