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

feat: Add esmapping-generator into jaeger binary #6327

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Rohanraj123
Copy link
Contributor

@Rohanraj123 Rohanraj123 commented Dec 8, 2024

Which problem is this PR solving?

Description of the changes

  • Decoupled the Esmapping generation logic from cmd/esmappnig-generator/main.go and kept it into reusable renderer package and then reimplemented the subcommand in the plugin/storage/es/esmapping-generator.go file and then registered in jaeger/main.go.

How was this change tested?

  • go test ./... -count=1

Checklist

@Rohanraj123 Rohanraj123 marked this pull request as ready for review December 8, 2024 18:36
@Rohanraj123 Rohanraj123 requested a review from a team as a code owner December 8, 2024 18:36
@dosubot dosubot bot added the area/storage label Dec 8, 2024
@Rohanraj123
Copy link
Contributor Author

@yurishkuro I think now this is perfectly decoupling the logic for generation in tool and then calling it from jaeger binary. Looking forward to your suggestions!

Copy link

codecov bot commented Dec 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 50.21%. Comparing base (980dc31) to head (01ad9bc).
Report is 1 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (980dc31) and HEAD (01ad9bc). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (980dc31) HEAD (01ad9bc)
unittests 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #6327       +/-   ##
===========================================
- Coverage   96.27%   50.21%   -46.07%     
===========================================
  Files         372      188      -184     
  Lines       21283    11405     -9878     
===========================================
- Hits        20491     5727    -14764     
- Misses        605     5220     +4615     
- Partials      187      458      +271     
Flag Coverage Δ
badger_v1 10.68% <ø> (+<0.01%) ⬆️
badger_v2 2.78% <ø> (+<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.25% <ø> (+<0.01%) ⬆️
elasticsearch-7.x-v1 20.32% <ø> (+<0.01%) ⬆️
elasticsearch-8.x-v1 20.49% <ø> (+0.02%) ⬆️
elasticsearch-8.x-v2 2.77% <ø> (+<0.01%) ⬆️
grpc_v1 12.20% <ø> (-0.12%) ⬇️
grpc_v2 9.04% <ø> (-0.06%) ⬇️
kafka-3.x-v1 10.36% <ø> (+<0.01%) ⬆️
kafka-3.x-v2 2.78% <ø> (+<0.01%) ⬆️
memory_v2 2.78% <ø> (+<0.01%) ⬆️
opensearch-1.x-v1 20.37% <ø> (+0.01%) ⬆️
opensearch-2.x-v1 20.38% <ø> (+0.01%) ⬆️
opensearch-2.x-v2 2.78% <ø> (+<0.01%) ⬆️
tailsampling-processor 0.51% <ø> (+<0.01%) ⬆️
unittests ?

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.

"go.uber.org/zap"
)

func GenerateESMappings(logger *zap.Logger, options app.Options) error {
Copy link
Member

Choose a reason for hiding this comment

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

  • this can be in the app/ package
  • can be called GenerateMappings ("ES" is implied)
  • as a library function it needs to return the results, not print them. The caller can decide what to do with the string.


fmt.Println(parsedMapping)
return nil
}
Copy link
Member

Choose a reason for hiding this comment

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

needs tests

@@ -0,0 +1,26 @@
package es
Copy link
Member

Choose a reason for hiding this comment

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

this package is not a place for commands. Can move it to cmd/esmapping-generator/app/command.go

Short: "Generate Elasticsearch mappings",
Long: "Generate Elasticsearch mappings using jaeger-esmapping-generator functionality",
Run: func(_ *cobra.Command, _ []string) {
if err := renderer.GenerateESMappings(logger, options); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

where are options populated?

@@ -25,19 +23,13 @@ func main() {
Short: "Jaeger esmapping-generator prints rendered mappings as string",
Long: `Jaeger esmapping-generator renders passed templates with provided values and prints rendered output to stdout`,
Run: func(_ *cobra.Command, _ /* args */ []string) {
if _, err := mappings.MappingTypeFromString(options.Mapping); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

how is this command different from the new one you defined? Merge into one?

Signed-off-by: Rohanraj123 <rajrohan88293@gmail.com>
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.

how is a user expected to run this?

@@ -199,6 +200,7 @@ by default uses only in-memory database.`,
command.AddCommand(docs.Command(v))
command.AddCommand(status.Command(v, ports.CollectorAdminHTTP))
command.AddCommand(printconfig.Command(v))
command.AddCommand(esmapping.Command(svc.Logger))
Copy link
Member

Choose a reason for hiding this comment

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

no need to add this to v1 binaries, only cmd/jaeger

"github.com/jaegertracing/jaeger/cmd/esmapping-generator/app"
"github.com/jaegertracing/jaeger/cmd/esmapping-generator/app/renderer"
"github.com/jaegertracing/jaeger/pkg/es"
"github.com/jaegertracing/jaeger/pkg/version"
"github.com/jaegertracing/jaeger/plugin/storage/es/mappings"
"github.com/spf13/cobra"
"go.uber.org/zap"
Copy link
Member

Choose a reason for hiding this comment

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

run make fmt

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.

2 participants