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

[jaeger-v2] Refactor Configuration For Query Service #5998

Merged
merged 21 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/all-in-one/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ by default uses only in-memory database.`,
if err != nil {
logger.Fatal("Failed to initialize collector", zap.Error(err))
}
qOpts, err := new(queryApp.QueryOptions).InitFromViper(v, logger)
qOpts, err := new(queryApp.Options).InitFromViper(v, logger)
if err != nil {
logger.Fatal("Failed to configure query service", zap.Error(err))
}
Expand Down Expand Up @@ -263,7 +263,7 @@ func startAgent(

func startQuery(
svc *flags.Service,
qOpts *queryApp.QueryOptions,
qOpts *queryApp.Options,
queryOpts *querysvc.QueryServiceOptions,
spanReader spanstore.Reader,
depReader dependencystore.Reader,
Expand Down
8 changes: 5 additions & 3 deletions cmd/jaeger/config-badger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ extensions:
http:

jaeger_query:
trace_storage: some_store
trace_storage_archive: another_store
ui_config: ./cmd/jaeger/config-ui.json
storage:
trace: some_store
trace_archive: another_store
ui:
config_file: ./cmd/jaeger/config-ui.json

jaeger_storage:
backends:
Expand Down
8 changes: 5 additions & 3 deletions cmd/jaeger/config-cassandra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ extensions:
http:

jaeger_query:
trace_storage: some_storage
trace_storage_archive: another_storage
ui_config: ./cmd/jaeger/config-ui.json
storage:
trace: some_storage
trace_archive: another_storage
ui:
config_file: ./cmd/jaeger/config-ui.json

jaeger_storage:
backends:
Expand Down
8 changes: 5 additions & 3 deletions cmd/jaeger/config-elasticsearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ extensions:
http:

jaeger_query:
trace_storage: some_storage
trace_storage_archive: another_storage
ui_config: ./cmd/jaeger/config-ui.json
storage:
trace: some_storage
trace_archive: another_storage
ui:
config_file: ./cmd/jaeger/config-ui.json

jaeger_storage:
backends:
Expand Down
3 changes: 2 additions & 1 deletion cmd/jaeger/config-kafka-ingester.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ extensions:
endpoint: 0.0.0.0:14133

jaeger_query:
trace_storage: some_storage
storage:
trace: some_storage

jaeger_storage:
backends:
Expand Down
8 changes: 5 additions & 3 deletions cmd/jaeger/config-opensearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ extensions:
http:

jaeger_query:
trace_storage: some_storage
trace_storage_archive: another_storage
ui_config: ./cmd/jaeger/config-ui.json
storage:
trace: some_storage
trace_archive: another_storage
ui:
config_file: ./cmd/jaeger/config-ui.json

jaeger_storage:
backends:
Expand Down
6 changes: 4 additions & 2 deletions cmd/jaeger/config-remote-storage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ extensions:
http:

jaeger_query:
trace_storage: some-storage
ui_config: ./cmd/jaeger/config-ui.json
storage:
trace: some-storage
ui:
config_file: ./cmd/jaeger/config-ui.json

jaeger_storage:
backends:
Expand Down
3 changes: 2 additions & 1 deletion cmd/jaeger/config-tail-sampling-always-sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ extensions:
use_v2: true
http:
jaeger_query:
trace_storage: some_storage
storage:
trace: some_storage
jaeger_storage:
backends:
some_storage:
Expand Down
3 changes: 2 additions & 1 deletion cmd/jaeger/config-tail-sampling-service-name-policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ extensions:
use_v2: true
http:
jaeger_query:
trace_storage: some_storage
storage:
trace: some_storage
jaeger_storage:
backends:
some_storage:
Expand Down
8 changes: 5 additions & 3 deletions cmd/jaeger/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ extensions:
# endpoint: 0.0.0.0:55679

jaeger_query:
trace_storage: some_store
trace_storage_archive: another_store
ui_config: ./cmd/jaeger/config-ui.json
storage:
trace: some_store
trace_archive: another_store
ui:
config_file: ./cmd/jaeger/config-ui.json

jaeger_storage:
backends:
Expand Down
3 changes: 2 additions & 1 deletion cmd/jaeger/internal/all-in-one.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ service:

extensions:
jaeger_query:
trace_storage: some_storage
storage:
trace: some_storage

jaeger_storage:
backends:
Expand Down
28 changes: 21 additions & 7 deletions cmd/jaeger/internal/extension/jaegerquery/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,27 @@ var _ component.ConfigValidator = (*Config)(nil)

// Config represents the configuration for jaeger-query,
type Config struct {
queryApp.QueryOptionsBase `mapstructure:",squash"`
TraceStoragePrimary string `valid:"required" mapstructure:"trace_storage"`
TraceStorageArchive string `valid:"optional" mapstructure:"trace_storage_archive"`
MetricStorage string `valid:"optional" mapstructure:"metric_storage"`
HTTP confighttp.ServerConfig `mapstructure:",squash"`
GRPC configgrpc.ServerConfig `mapstructure:",squash"`
Tenancy tenancy.Options `mapstructure:"multi_tenancy"`
queryApp.OptionsBase `mapstructure:",squash"`
Connection Connection `mapstructure:"connection"`
Storage Storage `mapstructure:"storage"`
}

type Connection struct {
mahadzaryab1 marked this conversation as resolved.
Show resolved Hide resolved
// Tenancy holds the multi-tenancy configuration.
Tenancy tenancy.Options `mapstructure:"multi_tenancy"`
// HTTP holds the HTTP configuration that the query service uses to serve requests.
HTTP confighttp.ServerConfig `mapstructure:"http"`
// GRPC holds the GRPC configuration that the query service uses to serve requests.
GRPC configgrpc.ServerConfig `mapstructure:"grpc"`
}

type Storage struct {
// TracePrimary contains the name of the primary trace storage that is being queried.
TracePrimary string `mapstructure:"trace" valid:"required"`
mahadzaryab1 marked this conversation as resolved.
Show resolved Hide resolved
// TraceArchive contains the name of the archive trace storage that is being queried.
TraceArchive string `mapstructure:"trace_archive" valid:"optional"`
// Metric contains the name of the metric storage that is being queried.
Metric string `mapstructure:"metric" valid:"optional"`
mahadzaryab1 marked this conversation as resolved.
Show resolved Hide resolved
}

func (cfg *Config) Validate() error {
Expand Down
6 changes: 4 additions & 2 deletions cmd/jaeger/internal/extension/jaegerquery/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ func Test_Validate(t *testing.T) {
{
name: "Empty config",
config: &Config{},
expectedErr: "TraceStoragePrimary: non zero value required",
expectedErr: "Storage.TracePrimary: non zero value required",
},
{
name: "Non empty-config",
config: &Config{
TraceStoragePrimary: "some-storage",
Storage: Storage{
TracePrimary: "some-storage",
},
},
expectedErr: "",
},
Expand Down
18 changes: 12 additions & 6 deletions cmd/jaeger/internal/extension/jaegerquery/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"go.opentelemetry.io/collector/config/confignet"
"go.opentelemetry.io/collector/extension"

"github.com/jaegertracing/jaeger/cmd/query/app"
"github.com/jaegertracing/jaeger/ports"
)

Expand All @@ -27,13 +28,18 @@ func NewFactory() extension.Factory {

func createDefaultConfig() component.Config {
return &Config{
HTTP: confighttp.ServerConfig{
Endpoint: ports.PortToHostPort(ports.QueryHTTP),
OptionsBase: app.OptionsBase{
BasePath: "/",
mahadzaryab1 marked this conversation as resolved.
Show resolved Hide resolved
mahadzaryab1 marked this conversation as resolved.
Show resolved Hide resolved
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: ports.PortToHostPort(ports.QueryGRPC),
Transport: confignet.TransportTypeTCP,
Connection: Connection{
HTTP: confighttp.ServerConfig{
Endpoint: ports.PortToHostPort(ports.QueryHTTP),
},
GRPC: configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: ports.PortToHostPort(ports.QueryGRPC),
Transport: confignet.TransportTypeTCP,
},
},
},
}
Expand Down
24 changes: 12 additions & 12 deletions cmd/jaeger/internal/extension/jaegerquery/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ func (s *server) Start(_ context.Context, host component.Host) error {
mf := otelmetrics.NewFactory(s.telset.MeterProvider)
baseFactory := mf.Namespace(metrics.NSOptions{Name: "jaeger"})
queryMetricsFactory := baseFactory.Namespace(metrics.NSOptions{Name: "query"})
f, err := jaegerstorage.GetStorageFactory(s.config.TraceStoragePrimary, host)
f, err := jaegerstorage.GetStorageFactory(s.config.Storage.TracePrimary, host)
if err != nil {
return fmt.Errorf("cannot find primary storage %s: %w", s.config.TraceStoragePrimary, err)
return fmt.Errorf("cannot find primary storage %s: %w", s.config.Storage.TracePrimary, err)
}

spanReader, err := f.CreateSpanReader()
Expand All @@ -81,7 +81,7 @@ func (s *server) Start(_ context.Context, host component.Host) error {
return err
}

tm := tenancy.NewManager(&s.config.Tenancy)
tm := tenancy.NewManager(&s.config.Connection.Tenancy)

// TODO OTel-collector does not initialize the tracer currently
// https://github.com/open-telemetry/opentelemetry-collector/issues/7532
Expand Down Expand Up @@ -122,12 +122,12 @@ func (s *server) Start(_ context.Context, host component.Host) error {
}

func (s *server) addArchiveStorage(opts *querysvc.QueryServiceOptions, host component.Host) error {
if s.config.TraceStorageArchive == "" {
if s.config.Storage.TraceArchive == "" {
s.telset.Logger.Info("Archive storage not configured")
return nil
}

f, err := jaegerstorage.GetStorageFactory(s.config.TraceStorageArchive, host)
f, err := jaegerstorage.GetStorageFactory(s.config.Storage.TraceArchive, host)
if err != nil {
return fmt.Errorf("cannot find archive storage factory: %w", err)
}
Expand All @@ -139,12 +139,12 @@ func (s *server) addArchiveStorage(opts *querysvc.QueryServiceOptions, host comp
}

func (s *server) createMetricReader(host component.Host) (metricsstore.Reader, error) {
if s.config.MetricStorage == "" {
if s.config.Storage.Metric == "" {
s.telset.Logger.Info("Metric storage not configured")
return disabled.NewMetricsReader()
}

mf, err := jaegerstorage.GetMetricsFactory(s.config.MetricStorage, host)
mf, err := jaegerstorage.GetMetricsFactory(s.config.Storage.Metric, host)
if err != nil {
return nil, fmt.Errorf("cannot find metrics storage factory: %w", err)
}
Expand All @@ -156,13 +156,13 @@ func (s *server) createMetricReader(host component.Host) (metricsstore.Reader, e
return metricsReader, err
}

func (s *server) makeQueryOptions() *queryApp.QueryOptions {
return &queryApp.QueryOptions{
QueryOptionsBase: s.config.QueryOptionsBase,
func (s *server) makeQueryOptions() *queryApp.Options {
return &queryApp.Options{
OptionsBase: s.config.OptionsBase,

// TODO utilize OTEL helpers for creating HTTP/GRPC servers
HTTPHostPort: s.config.HTTP.Endpoint,
GRPCHostPort: s.config.GRPC.NetAddr.Endpoint,
HTTPHostPort: s.config.Connection.HTTP.Endpoint,
GRPCHostPort: s.config.Connection.GRPC.NetAddr.Endpoint,
// TODO handle TLS
}
}
Expand Down
Loading
Loading