diff --git a/cmd/jaeger-v2/internal/all-in-one.yaml b/cmd/jaeger-v2/internal/all-in-one.yaml new file mode 100644 index 00000000000..d17c52fc850 --- /dev/null +++ b/cmd/jaeger-v2/internal/all-in-one.yaml @@ -0,0 +1,38 @@ +service: + extensions: [jaeger_storage, jaeger_query] + pipelines: + traces: + receivers: [otlp, jaeger, zipkin] + processors: [batch] + exporters: [jaeger_storage_exporter] + +extensions: + jaeger_query: + trace_storage: memstore + + jaeger_storage: + memory: + memstore: + max_traces: 100000 + +receivers: + otlp: + protocols: + grpc: + http: + + jaeger: + protocols: + grpc: + thrift_binary: + thrift_compact: + thrift_http: + + zipkin: + +processors: + batch: + +exporters: + jaeger_storage_exporter: + trace_storage: memstore diff --git a/cmd/jaeger-v2/internal/command.go b/cmd/jaeger-v2/internal/command.go index b8302b55535..9cea221bcc8 100644 --- a/cmd/jaeger-v2/internal/command.go +++ b/cmd/jaeger-v2/internal/command.go @@ -4,16 +4,20 @@ package internal import ( + "embed" + "fmt" "log" "github.com/spf13/cobra" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/otelcol" - allinone "github.com/jaegertracing/jaeger/cmd/jaeger-v2/internal/all-in-one" "github.com/jaegertracing/jaeger/pkg/version" ) +//go:embed all-in-one.yaml +var yamlAllInOne embed.FS + const description = "Jaeger backend v2" func Command() *cobra.Command { @@ -38,25 +42,20 @@ func Command() *cobra.Command { // We want to support running the binary in all-in-one mode without a config file. // Since there are no explicit hooks in OTel Collector for that today (as of v0.87), // we intercept the official RunE implementation and check if any `--config` flags - // are present in the args. If not, we pass a custom ConfigProvider, and create the - // collector manually. Unfortunately, `set`(tings) is passed to NewCommand above - // by value, otherwise we could've overwritten it in the interceptor and then delegated - // back to the official RunE. + // are present in the args. If not, we create one with all-in-one configuration. otelRunE := cmd.RunE cmd.RunE = func(cmd *cobra.Command, args []string) error { - // a bit of a hack to check if '--config' flag was present - configFlag := cmd.Flag("config").Value.String() - if configFlag != "" && configFlag != "[]" { - return otelRunE(cmd, args) - } - log.Print("No '--config' flags detected, using default All-in-One configuration with memory storage.") - log.Print("To customize All-in-One behavior, pass a proper configuration.") - settings.ConfigProvider = allinone.NewConfigProvider() - col, err := otelcol.NewCollector(settings) - if err != nil { - return err + configFlag := cmd.Flag("config") + if !configFlag.Changed { + log.Print("No '--config' flags detected, using default All-in-One configuration with memory storage.") + log.Print("To customize All-in-One behavior, pass a proper configuration.") + data, err := yamlAllInOne.ReadFile("all-in-one.yaml") + if err != nil { + return fmt.Errorf("cannot read embedded all-in-one configuration: %w", err) + } + configFlag.Value.Set("yaml:" + string(data)) } - return col.Run(cmd.Context()) + return otelRunE(cmd, args) } cmd.Short = description diff --git a/cmd/jaeger-v2/internal/exporters/storageexporter/factory.go b/cmd/jaeger-v2/internal/exporters/storageexporter/factory.go index b555a80bbec..5721c45c4e4 100644 --- a/cmd/jaeger-v2/internal/exporters/storageexporter/factory.go +++ b/cmd/jaeger-v2/internal/exporters/storageexporter/factory.go @@ -10,8 +10,6 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/exporter/exporterhelper" - - "github.com/jaegertracing/jaeger/cmd/jaeger-v2/internal/extension/jaegerstorage" ) // componentType is the name of this extension in configuration. @@ -30,9 +28,7 @@ func NewFactory() exporter.Factory { } func createDefaultConfig() component.Config { - return &Config{ - TraceStorage: jaegerstorage.DefaultMemoryStore, - } + return &Config{} } func createTracesExporter(ctx context.Context, set exporter.CreateSettings, config component.Config) (exporter.Traces, error) { diff --git a/cmd/jaeger-v2/internal/extension/jaegerquery/factory.go b/cmd/jaeger-v2/internal/extension/jaegerquery/factory.go index 9efd3d02a79..bef4b296f05 100644 --- a/cmd/jaeger-v2/internal/extension/jaegerquery/factory.go +++ b/cmd/jaeger-v2/internal/extension/jaegerquery/factory.go @@ -10,7 +10,6 @@ import ( "go.opentelemetry.io/collector/config/confighttp" "go.opentelemetry.io/collector/extension" - "github.com/jaegertracing/jaeger/cmd/jaeger-v2/internal/extension/jaegerstorage" "github.com/jaegertracing/jaeger/ports" ) @@ -26,7 +25,6 @@ func NewFactory() extension.Factory { func createDefaultConfig() component.Config { return &Config{ - TraceStoragePrimary: jaegerstorage.DefaultMemoryStore, HTTPServerSettings: confighttp.HTTPServerSettings{ Endpoint: ports.PortToHostPort(ports.QueryHTTP), }, diff --git a/cmd/jaeger-v2/internal/extension/jaegerstorage/factory.go b/cmd/jaeger-v2/internal/extension/jaegerstorage/factory.go index 2cf2797bec3..627372915b9 100644 --- a/cmd/jaeger-v2/internal/extension/jaegerstorage/factory.go +++ b/cmd/jaeger-v2/internal/extension/jaegerstorage/factory.go @@ -8,17 +8,10 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/extension" - - memoryCfg "github.com/jaegertracing/jaeger/pkg/memory/config" ) -const ( - // componentType is the name of this extension in configuration. - componentType = component.Type("jaeger_storage") - - // DefaultMemoryStore is the name of the memory storage included in the default configuration. - DefaultMemoryStore = "memstore" -) +// componentType is the name of this extension in configuration. +const componentType = component.Type("jaeger_storage") // ID is the identifier of this extension. var ID = component.NewID(componentType) @@ -33,13 +26,7 @@ func NewFactory() extension.Factory { } func createDefaultConfig() component.Config { - return &Config{ - Memory: map[string]memoryCfg.Configuration{ - DefaultMemoryStore: { - MaxTraces: 100_000, - }, - }, - } + return &Config{} } // createExtension creates the extension based on this config.