-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add esmapping-generator tool to jaeger binary
Signed-off-by: Rohanraj123 <[email protected]>
- Loading branch information
1 parent
980dc31
commit 01ad9bc
Showing
5 changed files
with
62 additions
and
4 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
24 changes: 24 additions & 0 deletions
24
cmd/esmapping-generator/app/generator/esmapping_generator.go
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,24 @@ | ||
package generator | ||
|
||
import ( | ||
"fmt" | ||
|
||
"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/plugin/storage/es/mappings" | ||
) | ||
|
||
func GenerateMappings() string { | ||
options := app.Options{} | ||
if _, err := mappings.MappingTypeFromString(options.Mapping); err != nil { | ||
return fmt.Sprintf("please pass either 'jaeger-service' or 'jaeger-span' as argument: %v", err) | ||
} | ||
|
||
parsedMapping, err := renderer.GetMappingAsString(es.TextTemplateBuilder{}, &options) | ||
if err != nil { | ||
return fmt.Sprintf("failed to get mapping as string: %v", err) | ||
} | ||
|
||
return parsedMapping | ||
} |
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
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,28 @@ | ||
package esmapping | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/jaegertracing/jaeger/cmd/esmapping-generator/app" | ||
"github.com/jaegertracing/jaeger/cmd/esmapping-generator/app/generator" | ||
"go.uber.org/zap" | ||
) | ||
|
||
func Command(logger *zap.Logger) *cobra.Command { | ||
options := app.Options{} | ||
|
||
command := &cobra.Command{ | ||
Use: "es-mappings", | ||
Short: "Generate Elasticsearch mappings", | ||
Long: "Generate Elasticsearch mappings using jaeger-esmapping-generator functionality", | ||
Run: func(_ *cobra.Command, _ []string) { | ||
result := generator.GenerateMappings() | ||
fmt.Println(result) | ||
}, | ||
} | ||
|
||
command.Flags().StringVar(&options.Mapping, "mapping", "jaeger-span", "Mapping type to use, e.g. 'jaeger-service' or 'jaeger-span'") | ||
return command | ||
} |
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