Skip to content

Commit

Permalink
starting a brand new configuration scheme to structure
Browse files Browse the repository at this point in the history
  • Loading branch information
JaredTan95 committed Aug 1, 2024
1 parent 75296d9 commit e211d34
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 46 deletions.
20 changes: 13 additions & 7 deletions cmd/jaeger/config-elasticsearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ extensions:
some_storage:
elasticsearch:
index_prefix: "jaeger-main"
index_date_layout_spans: "2006-01-02"
index_date_layout_services: "2006-01-02"
index_date_layout_sampling: "2006-01-02"
index_date_layout_dependencies: "2006-01-02"
index_rollover_frequency_spans: "hour"
index_rollover_frequency_services: "hour"
index_rollover_frequency_sampling: "hour"
# indices:
# spans:
# date_layout: "2006-01-02"
# rollover_frequency: "hour"
# services:
# date_layout: "2006-01-02"
# rollover_frequency: "hour"
# dependencies:
# date_layout: "2006-01-02"
# rollover_frequency: "hour"
# sampling:
# date_layout: "2006-01-02"
# rollover_frequency: "hour"
another_storage:
elasticsearch:
index_prefix: "jaeger-archive"
Expand Down
80 changes: 51 additions & 29 deletions pkg/es/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,37 +44,59 @@ import (
storageMetrics "github.com/jaegertracing/jaeger/storage/spanstore/metrics"
)

// IndexOptions describes the index format and rollover frequency
type IndexOptions struct {
DateLayout string `mapstructure:"date_layout"`
RolloverFrequency string `mapstructure:"rollover_frequency"`
}

// Indices describes different configuration options for each index type
type Indices struct {
Spans IndexOptions `mapstructure:"spans"`
Services IndexOptions `mapstructure:"services"`
Dependencies IndexOptions `mapstructure:"dependencies"`
Sampling IndexOptions `mapstructure:"sampling"`
}

// Configuration describes the configuration properties needed to connect to an ElasticSearch cluster
type Configuration struct {
Servers []string `mapstructure:"server_urls" valid:"required,url"`
RemoteReadClusters []string `mapstructure:"remote_read_clusters"`
Username string `mapstructure:"username"`
Password string `mapstructure:"password" json:"-"`
TokenFilePath string `mapstructure:"token_file"`
PasswordFilePath string `mapstructure:"password_file"`
AllowTokenFromContext bool `mapstructure:"-"`
Sniffer bool `mapstructure:"sniffer"` // https://github.com/olivere/elastic/wiki/Sniffing
SnifferTLSEnabled bool `mapstructure:"sniffer_tls_enabled"`
MaxDocCount int `mapstructure:"-"` // Defines maximum number of results to fetch from storage per query
MaxSpanAge time.Duration `mapstructure:"-"` // configures the maximum lookback on span reads
NumShards int64 `mapstructure:"num_shards"`
NumReplicas int64 `mapstructure:"num_replicas"`
PrioritySpanTemplate int64 `mapstructure:"priority_span_template"`
PriorityServiceTemplate int64 `mapstructure:"priority_service_template"`
PriorityDependenciesTemplate int64 `mapstructure:"priority_dependencies_template"`
Timeout time.Duration `mapstructure:"-"`
BulkSize int `mapstructure:"-"`
BulkWorkers int `mapstructure:"-"`
BulkActions int `mapstructure:"-"`
BulkFlushInterval time.Duration `mapstructure:"-"`
IndexPrefix string `mapstructure:"index_prefix"`
IndexDateLayoutSpans string `mapstructure:"index_date_layout_spans"`
IndexDateLayoutServices string `mapstructure:"index_date_layout_services"`
IndexDateLayoutSampling string `mapstructure:"index_date_layout_sampling"`
IndexDateLayoutDependencies string `mapstructure:"index_date_layout_dependencies"`
IndexRolloverFrequencySpans string `mapstructure:"index_rollover_frequency_spans"`
IndexRolloverFrequencyServices string `mapstructure:"index_rollover_frequency_services"`
IndexRolloverFrequencySampling string `mapstructure:"index_rollover_frequency_sampling"`
Servers []string `mapstructure:"server_urls" valid:"required,url"`
RemoteReadClusters []string `mapstructure:"remote_read_clusters"`
Username string `mapstructure:"username"`
Password string `mapstructure:"password" json:"-"`
TokenFilePath string `mapstructure:"token_file"`
PasswordFilePath string `mapstructure:"password_file"`
AllowTokenFromContext bool `mapstructure:"-"`
Sniffer bool `mapstructure:"sniffer"` // https://github.com/olivere/elastic/wiki/Sniffing
SnifferTLSEnabled bool `mapstructure:"sniffer_tls_enabled"`
MaxDocCount int `mapstructure:"-"` // Defines maximum number of results to fetch from storage per query
MaxSpanAge time.Duration `mapstructure:"-"` // configures the maximum lookback on span reads
NumShards int64 `mapstructure:"num_shards"`
NumReplicas int64 `mapstructure:"num_replicas"`
PrioritySpanTemplate int64 `mapstructure:"priority_span_template"`
PriorityServiceTemplate int64 `mapstructure:"priority_service_template"`
PriorityDependenciesTemplate int64 `mapstructure:"priority_dependencies_template"`
Timeout time.Duration `mapstructure:"-"`
BulkSize int `mapstructure:"-"`
BulkWorkers int `mapstructure:"-"`
BulkActions int `mapstructure:"-"`
BulkFlushInterval time.Duration `mapstructure:"-"`
IndexPrefix string `mapstructure:"index_prefix"`
// Deprecated: use Indices and IndexOptions instead.
IndexDateLayoutSpans string `mapstructure:"-"`
// Deprecated: use Indices and IndexOptions instead.
IndexDateLayoutServices string `mapstructure:"-"`
// Deprecated: use Indices and IndexOptions instead.
IndexDateLayoutSampling string `mapstructure:"-"`
// Deprecated: use Indices and IndexOptions instead.
IndexDateLayoutDependencies string `mapstructure:"-"`
// Deprecated: use Indices and IndexOptions instead.
IndexRolloverFrequencySpans string `mapstructure:"-"`
// Deprecated: use Indices and IndexOptions instead.
IndexRolloverFrequencyServices string `mapstructure:"-"`
// Deprecated: use Indices and IndexOptions instead.
IndexRolloverFrequencySampling string `mapstructure:"-"`
Indices Indices `mapstructure:"indices"`
ServiceCacheTTL time.Duration `mapstructure:"service_cache_ttl"`
AdaptiveSamplingLookback time.Duration `mapstructure:"-"`
Tags TagsAsFields `mapstructure:"tags_as_fields"`
Expand Down
39 changes: 29 additions & 10 deletions plugin/storage/es/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ const (
defaultSendGetBodyAs = ""
)

var (
defaultIndexOptions = config.IndexOptions{
DateLayout: initDateLayout(defaultIndexRolloverFrequency, defaultIndexDateSeparator),
RolloverFrequency: defaultIndexRolloverFrequency,
}
)

// TODO this should be moved next to config.Configuration struct (maybe ./flags package)

// Options contains various type of Elasticsearch configs and provides the ability
Expand Down Expand Up @@ -427,15 +434,27 @@ func DefaultConfig() config.Configuration {
Tags: config.TagsAsFields{
DotReplacement: "@",
},
Enabled: true,
CreateIndexTemplates: true,
Version: 0,
UseReadWriteAliases: false,
UseILM: false,
Servers: []string{defaultServerURL},
RemoteReadClusters: []string{},
MaxDocCount: defaultMaxDocCount,
LogLevel: "error",
SendGetBodyAs: defaultSendGetBodyAs,
Enabled: true,
CreateIndexTemplates: true,
Version: 0,
UseReadWriteAliases: false,
UseILM: false,
Servers: []string{defaultServerURL},
RemoteReadClusters: []string{},
MaxDocCount: defaultMaxDocCount,
LogLevel: "error",
SendGetBodyAs: defaultSendGetBodyAs,
IndexDateLayoutSpans: defaultIndexOptions.DateLayout,
IndexDateLayoutServices: defaultIndexOptions.DateLayout,
IndexDateLayoutSampling: defaultIndexOptions.DateLayout,
IndexRolloverFrequencySpans: defaultIndexOptions.RolloverFrequency,
IndexRolloverFrequencyServices: defaultIndexOptions.RolloverFrequency,
IndexRolloverFrequencySampling: defaultIndexOptions.RolloverFrequency,
Indices: config.Indices{
Spans: defaultIndexOptions,
Services: defaultIndexOptions,
Dependencies: defaultIndexOptions,
Sampling: defaultIndexOptions,
},
}
}

0 comments on commit e211d34

Please sign in to comment.