forked from jaegertracing/jaeger
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'features' command to print available feature gates (jaegertracin…
…g#6542) ## Which problem is this PR solving? - Resolves jaegertracing#6442 ## Description of the changes - ## How was this change tested? - make features ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [x] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `npm run lint` and `npm run test` --------- Signed-off-by: cs-308-2023 <[email protected]>
- Loading branch information
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) 2025 The Jaeger Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package features | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
|
||
"go.opentelemetry.io/collector/featuregate" | ||
) | ||
|
||
func DisplayFeatures() string { | ||
f := featuregate.GlobalRegistry() | ||
var buffer bytes.Buffer | ||
|
||
f.VisitAll(func(g *featuregate.Gate) { | ||
fmt.Fprintf(&buffer, "Feature:\t%s\n", g.ID()) | ||
if g.IsEnabled() { | ||
fmt.Fprintf(&buffer, "Default state:\t%s\n", "On") | ||
} else { | ||
fmt.Fprintf(&buffer, "Default state:\t%s\n", "Off") | ||
} | ||
fmt.Fprintf(&buffer, "Description:\t%s\n", g.Description()) | ||
if ref := g.ReferenceURL(); ref != "" { | ||
fmt.Fprintf(&buffer, "ReferenceURL:\t%s\n", ref) | ||
} | ||
fmt.Fprintln(&buffer) | ||
}) | ||
|
||
return buffer.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2025 The Jaeger Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package features | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"go.opentelemetry.io/collector/featuregate" | ||
|
||
"github.com/jaegertracing/jaeger/pkg/testutils" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
testutils.VerifyGoLeaks(m) | ||
} | ||
|
||
func TestDisplayStageAlpha(t *testing.T) { | ||
featuregate.GlobalRegistry().MustRegister( | ||
"jaeger.featuresdisplay.testgate1", | ||
featuregate.StageAlpha, | ||
featuregate.WithRegisterDescription("testdescription"), | ||
featuregate.WithRegisterReferenceURL("https://testurl.com"), | ||
) | ||
out := DisplayFeatures() | ||
require.Contains(t, out, "jaeger.featuresdisplay.testgate") | ||
require.Contains(t, out, "Off") | ||
} | ||
|
||
func TestDisplayStageBeta(t *testing.T) { | ||
featuregate.GlobalRegistry().MustRegister( | ||
"jaeger.featuresdisplay.testgate2", | ||
featuregate.StageBeta, | ||
featuregate.WithRegisterDescription("testdescription"), | ||
featuregate.WithRegisterReferenceURL("https://testurl.com"), | ||
) | ||
out := DisplayFeatures() | ||
require.Contains(t, out, "jaeger.featuresdisplay.testgate") | ||
require.Contains(t, out, "On") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters