Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'features' command to beautify and print feature gates #6542

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

ADI-ROXX
Copy link
Contributor

@ADI-ROXX ADI-ROXX commented Jan 14, 2025

Which problem is this PR solving?

Description of the changes

How was this change tested?

  • make features

Checklist

@ADI-ROXX ADI-ROXX requested a review from a team as a code owner January 14, 2025 04:30
@ADI-ROXX ADI-ROXX requested a review from pavolloffay January 14, 2025 04:30
@dosubot dosubot bot added the enhancement label Jan 14, 2025
Copy link

codecov bot commented Jan 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 50.27%. Comparing base (89c4ee4) to head (cc1a73e).
Report is 30 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6542      +/-   ##
==========================================
+ Coverage   50.21%   50.27%   +0.05%     
==========================================
  Files         188      189       +1     
  Lines       11405    11424      +19     
==========================================
+ Hits         5727     5743      +16     
- Misses       5220     5226       +6     
+ Partials      458      455       -3     
Flag Coverage Δ
badger_v1 10.64% <ø> (-0.04%) ⬇️
badger_v2 2.77% <ø> (-0.01%) ⬇️
cassandra-4.x-v1-manual 16.58% <ø> (+<0.01%) ⬆️
cassandra-4.x-v2-auto 2.71% <ø> (-0.01%) ⬇️
cassandra-4.x-v2-manual 2.71% <ø> (-0.01%) ⬇️
cassandra-5.x-v1-manual 16.58% <ø> (+<0.01%) ⬆️
cassandra-5.x-v2-auto 2.71% <ø> (-0.01%) ⬇️
cassandra-5.x-v2-manual 2.71% <ø> (-0.01%) ⬇️
elasticsearch-6.x-v1 20.37% <ø> (+0.11%) ⬆️
elasticsearch-7.x-v1 20.43% <ø> (+0.10%) ⬆️
elasticsearch-8.x-v1 20.59% <ø> (+0.10%) ⬆️
elasticsearch-8.x-v2 2.76% <ø> (-0.01%) ⬇️
grpc_v1 12.16% <ø> (-0.05%) ⬇️
grpc_v2 9.02% <ø> (-0.03%) ⬇️
kafka-3.x-v1 10.32% <ø> (-0.04%) ⬇️
kafka-3.x-v2 2.77% <ø> (-0.01%) ⬇️
memory_v2 2.76% <ø> (-0.01%) ⬇️
opensearch-1.x-v1 20.48% <ø> (+0.10%) ⬆️
opensearch-2.x-v1 20.49% <ø> (+0.11%) ⬆️
opensearch-2.x-v2 2.77% <ø> (-0.01%) ⬇️
tailsampling-processor 0.51% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: cs-308-2023 <[email protected]>
Signed-off-by: cs-308-2023 <[email protected]>
Makefile Outdated Show resolved Hide resolved
cmd/jaeger/features/main.go Outdated Show resolved Hide resolved
Signed-off-by: cs-308-2023 <[email protected]>
Makefile Outdated Show resolved Hide resolved
cmd/jaeger/features/main.go Outdated Show resolved Hide resolved
@@ -26,6 +26,10 @@ var yamlAllInOne embed.FS

const description = "Jaeger backend v2"

func GetDescription() string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed?

Copy link
Contributor Author

@ADI-ROXX ADI-ROXX Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is needed because in the file features/main.go, there is a need to print the current version of the backend. For that, I have used the following
image

The other way around was to change the variable name from description to "Description" to export the variable, but that would require making changes in a lot of places.

cmd/jaeger/main.go Outdated Show resolved Hide resolved

fmt.Println("\n" + internal.GetDescription())
fmt.Println("List of feature gate identifiers. Prefix with '-' to disable the feature. '+' or no prefix will enable the feature.\n ")
otelcol.FeatureCommand(settings)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is going to be a feature subcommand in OTEL why do we need any of this? We can just invoke it and add to our root command.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. So, I will move the fmt.Println("List of feature gate identifiers. Prefix with '-' to disable the feature. '+' or no prefix will enable the feature.\n ") inside the FeatureFlags function but
fmt.Println("\n" + internal.GetDescription()) has to be in this file only because it will display that it is a Jaeger Backend v2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output of the (sub)-command is completed determined by the command itself, it does not need to borrow description from anywhere else. For example, version subcommand only outputs a JSON:

$ go run ./cmd/jaeger version
2025/01/20 11:11:45 application version: git-commit=, git-version=, build-date=
{"gitCommit":"","gitVersion":"","buildDate":""}%

(we need to clean up the first log line to not be printed)

Signed-off-by: cs-308-2023 <[email protected]>
Signed-off-by: cs-308-2023 <[email protected]>

fmt.Println("\n" + internal.GetDescription())
fmt.Println("List of feature gate identifiers. Prefix with '-' to disable the feature. '+' or no prefix will enable the feature.\n ")
otelcol.FeatureCommand(settings)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does otelcol.FeatureCommand need any of the above? It seems completely irrelevant.

Suggestion: copy the core logic of FeatureCommand into Jaeger directly for now, so that we don't have to wait for OTEL Collector reease.

Signed-off-by: cs-308-2023 <[email protected]>
// Copyright (c) 2023 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0

package features
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmd/jaeger/internal/features/display.go

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reminder

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a unit test

return
}
f.reg.VisitAll(func(g *featuregate.Gate) {
str := "Feature:\t"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use exact number of spaces, not \t

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

\t is giving me beautified output

@ADI-ROXX
Copy link
Contributor Author

For the unit test, I am thinking the following:

  1. In the DisplayFeatures() function, return a string.
  2. Set a desired string. Check if the string output from DisplayFeatures is same as the desired output

Signed-off-by: cs-308-2023 <[email protected]>
str := "Feature:\t"
id := g.ID()
desc := g.Description()
str += id + "\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you concatenating strings instead of just printing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, I had to write fmt.Println() lot of time and it would be too big of a code, so I thought it would be better to concatenate and then print in the end

Signed-off-by: cs-308-2023 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "features" command to print documentation about all features
2 participants