Skip to content

Commit 0fc705b

Browse files
committed
polish
Signed-off-by: Jared Tan <[email protected]>
1 parent e5158ab commit 0fc705b

18 files changed

+356
-216
lines changed

cmd/jaeger/config-elasticsearch.yaml

+13-13
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ extensions:
1717
some_storage:
1818
elasticsearch:
1919
index_prefix: "jaeger-main"
20-
# indices:
21-
# spans:
22-
# date_layout: "2006-01-02"
23-
# rollover_frequency: "hour"
24-
# services:
25-
# date_layout: "2006-01-02"
26-
# rollover_frequency: "hour"
27-
# dependencies:
28-
# date_layout: "2006-01-02"
29-
# rollover_frequency: "hour"
30-
# sampling:
31-
# date_layout: "2006-01-02"
32-
# rollover_frequency: "hour"
20+
indices:
21+
spans:
22+
date_layout: "2006-01-02"
23+
rollover_frequency: "day"
24+
services:
25+
date_layout: "2006-01-02"
26+
rollover_frequency: "day"
27+
dependencies:
28+
date_layout: "2006-01-02"
29+
rollover_frequency: "day"
30+
sampling:
31+
date_layout: "2006-01-02"
32+
rollover_frequency: "day"
3333
another_storage:
3434
elasticsearch:
3535
index_prefix: "jaeger-archive"

pkg/es/config/config.go

+48-46
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,17 @@ import (
4444
storageMetrics "github.com/jaegertracing/jaeger/storage/spanstore/metrics"
4545
)
4646

47+
type TemplateOptions struct {
48+
Priority int64 `mapstructure:"priority"`
49+
NumShards int64 `mapstructure:"num_shards"`
50+
NumReplicas int64 `mapstructure:"num_replicas"`
51+
}
52+
4753
// IndexOptions describes the index format and rollover frequency
4854
type IndexOptions struct {
49-
DateLayout string `mapstructure:"date_layout"`
50-
RolloverFrequency string `mapstructure:"rollover_frequency"`
55+
DateLayout string `mapstructure:"date_layout"`
56+
RolloverFrequency string `mapstructure:"rollover_frequency"`
57+
TemplateOptions TemplateOptions `mapstructure:"template"`
5158
}
5259

5360
// Indices describes different configuration options for each index type
@@ -60,40 +67,35 @@ type Indices struct {
6067

6168
// Configuration describes the configuration properties needed to connect to an ElasticSearch cluster
6269
type Configuration struct {
63-
Servers []string `mapstructure:"server_urls" valid:"required,url"`
64-
RemoteReadClusters []string `mapstructure:"remote_read_clusters"`
65-
Username string `mapstructure:"username"`
66-
Password string `mapstructure:"password" json:"-"`
67-
TokenFilePath string `mapstructure:"token_file"`
68-
PasswordFilePath string `mapstructure:"password_file"`
69-
AllowTokenFromContext bool `mapstructure:"-"`
70-
Sniffer bool `mapstructure:"sniffer"` // https://github.com/olivere/elastic/wiki/Sniffing
71-
SnifferTLSEnabled bool `mapstructure:"sniffer_tls_enabled"`
72-
MaxDocCount int `mapstructure:"-"` // Defines maximum number of results to fetch from storage per query
73-
MaxSpanAge time.Duration `mapstructure:"-"` // configures the maximum lookback on span reads
74-
NumShards int64 `mapstructure:"num_shards"`
75-
NumReplicas int64 `mapstructure:"num_replicas"`
76-
PrioritySpanTemplate int64 `mapstructure:"priority_span_template"`
77-
PriorityServiceTemplate int64 `mapstructure:"priority_service_template"`
78-
PriorityDependenciesTemplate int64 `mapstructure:"priority_dependencies_template"`
79-
Timeout time.Duration `mapstructure:"-"`
80-
BulkSize int `mapstructure:"-"`
81-
BulkWorkers int `mapstructure:"-"`
82-
BulkActions int `mapstructure:"-"`
83-
BulkFlushInterval time.Duration `mapstructure:"-"`
84-
IndexPrefix string `mapstructure:"index_prefix"`
85-
Indices Indices `mapstructure:"indices"`
86-
ServiceCacheTTL time.Duration `mapstructure:"service_cache_ttl"`
87-
AdaptiveSamplingLookback time.Duration `mapstructure:"-"`
88-
Tags TagsAsFields `mapstructure:"tags_as_fields"`
89-
Enabled bool `mapstructure:"-"`
90-
TLS tlscfg.Options `mapstructure:"tls"`
91-
UseReadWriteAliases bool `mapstructure:"use_aliases"`
92-
CreateIndexTemplates bool `mapstructure:"create_mappings"`
93-
UseILM bool `mapstructure:"use_ilm"`
94-
Version uint `mapstructure:"version"`
95-
LogLevel string `mapstructure:"log_level"`
96-
SendGetBodyAs string `mapstructure:"send_get_body_as"`
70+
Servers []string `mapstructure:"server_urls" valid:"required,url"`
71+
RemoteReadClusters []string `mapstructure:"remote_read_clusters"`
72+
Username string `mapstructure:"username"`
73+
Password string `mapstructure:"password" json:"-"`
74+
TokenFilePath string `mapstructure:"token_file"`
75+
PasswordFilePath string `mapstructure:"password_file"`
76+
AllowTokenFromContext bool `mapstructure:"-"`
77+
Sniffer bool `mapstructure:"sniffer"` // https://github.com/olivere/elastic/wiki/Sniffing
78+
SnifferTLSEnabled bool `mapstructure:"sniffer_tls_enabled"`
79+
MaxDocCount int `mapstructure:"-"` // Defines maximum number of results to fetch from storage per query
80+
MaxSpanAge time.Duration `mapstructure:"-"` // configures the maximum lookback on span reads
81+
Timeout time.Duration `mapstructure:"-"`
82+
BulkSize int `mapstructure:"-"`
83+
BulkWorkers int `mapstructure:"-"`
84+
BulkActions int `mapstructure:"-"`
85+
BulkFlushInterval time.Duration `mapstructure:"-"`
86+
IndexPrefix string `mapstructure:"index_prefix"`
87+
Indices Indices `mapstructure:"indices"`
88+
ServiceCacheTTL time.Duration `mapstructure:"service_cache_ttl"`
89+
AdaptiveSamplingLookback time.Duration `mapstructure:"-"`
90+
Tags TagsAsFields `mapstructure:"tags_as_fields"`
91+
Enabled bool `mapstructure:"-"`
92+
TLS tlscfg.Options `mapstructure:"tls"`
93+
UseReadWriteAliases bool `mapstructure:"use_aliases"`
94+
CreateIndexTemplates bool `mapstructure:"create_mappings"`
95+
UseILM bool `mapstructure:"use_ilm"`
96+
Version uint `mapstructure:"version"`
97+
LogLevel string `mapstructure:"log_level"`
98+
SendGetBodyAs string `mapstructure:"send_get_body_as"`
9799
}
98100

99101
// TagsAsFields holds configuration for tag schema.
@@ -246,20 +248,20 @@ func (c *Configuration) ApplyDefaults(source *Configuration) {
246248
if c.AdaptiveSamplingLookback == 0 {
247249
c.AdaptiveSamplingLookback = source.AdaptiveSamplingLookback
248250
}
249-
if c.NumShards == 0 {
250-
c.NumShards = source.NumShards
251+
if c.Indices.Dependencies.TemplateOptions.NumShards == 0 {
252+
c.Indices.Dependencies.TemplateOptions.NumShards = source.Indices.Dependencies.TemplateOptions.NumShards
251253
}
252-
if c.NumReplicas == 0 {
253-
c.NumReplicas = source.NumReplicas
254+
if c.Indices.Dependencies.TemplateOptions.NumReplicas == 0 {
255+
c.Indices.Dependencies.TemplateOptions.NumReplicas = source.Indices.Dependencies.TemplateOptions.NumReplicas
254256
}
255-
if c.PrioritySpanTemplate == 0 {
256-
c.PrioritySpanTemplate = source.PrioritySpanTemplate
257+
if c.Indices.Spans.TemplateOptions.Priority == 0 {
258+
c.Indices.Spans.TemplateOptions.Priority = source.Indices.Spans.TemplateOptions.Priority
257259
}
258-
if c.PriorityServiceTemplate == 0 {
259-
c.PriorityServiceTemplate = source.PriorityServiceTemplate
260+
if c.Indices.Services.TemplateOptions.Priority == 0 {
261+
c.Indices.Services.TemplateOptions.Priority = source.Indices.Services.TemplateOptions.Priority
260262
}
261-
if c.PrioritySpanTemplate == 0 {
262-
c.PriorityDependenciesTemplate = source.PriorityDependenciesTemplate
263+
if c.Indices.Dependencies.TemplateOptions.Priority == 0 {
264+
c.Indices.Dependencies.TemplateOptions.Priority = source.Indices.Dependencies.TemplateOptions.Priority
263265
}
264266
if c.BulkSize == 0 {
265267
c.BulkSize = source.BulkSize

plugin/storage/es/factory.go

+11-5
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,20 @@ func (f *Factory) CreateSamplingStore(int /* maxBuckets */) (samplingstore.Store
325325
func mappingBuilderFromConfig(cfg *config.Configuration) mappings.MappingBuilder {
326326
return mappings.MappingBuilder{
327327
TemplateBuilder: es.TextTemplateBuilder{},
328-
Shards: cfg.NumShards,
329-
Replicas: cfg.NumReplicas,
328+
ShardsSpan: cfg.Indices.Spans.TemplateOptions.NumShards,
329+
ReplicasSpan: cfg.Indices.Spans.TemplateOptions.NumReplicas,
330+
ShardsService: cfg.Indices.Services.TemplateOptions.NumShards,
331+
ReplicasService: cfg.Indices.Services.TemplateOptions.NumShards,
332+
ShardsSampling: cfg.Indices.Sampling.TemplateOptions.NumShards,
333+
ReplicasSampling: cfg.Indices.Sampling.TemplateOptions.NumShards,
334+
ShardsDependencies: cfg.Indices.Dependencies.TemplateOptions.NumShards,
335+
ReplicasDependencies: cfg.Indices.Dependencies.TemplateOptions.NumShards,
330336
EsVersion: cfg.Version,
331337
IndexPrefix: cfg.IndexPrefix,
332338
UseILM: cfg.UseILM,
333-
PrioritySpanTemplate: cfg.PrioritySpanTemplate,
334-
PriorityServiceTemplate: cfg.PriorityServiceTemplate,
335-
PriorityDependenciesTemplate: cfg.PriorityDependenciesTemplate,
339+
PrioritySpanTemplate: cfg.Indices.Spans.TemplateOptions.Priority,
340+
PriorityServiceTemplate: cfg.Indices.Services.TemplateOptions.Priority,
341+
PriorityDependenciesTemplate: cfg.Indices.Dependencies.TemplateOptions.Priority,
336342
}
337343
}
338344

plugin/storage/es/mappings/jaeger-dependencies-6.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"template": "*jaeger-dependencies-*",
33
"settings":{
4-
"index.number_of_shards": {{ .Shards }},
5-
"index.number_of_replicas": {{ .Replicas }},
4+
"index.number_of_shards": {{ .ShardsDependencies }},
5+
"index.number_of_replicas": {{ .ReplicasDependencies }},
66
"index.mapping.nested_fields.limit":50,
77
"index.requests.cache.enable":true
88
},

plugin/storage/es/mappings/jaeger-dependencies-7.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
},
77
{{- end }}
88
"settings":{
9-
"index.number_of_shards": {{ .Shards }},
10-
"index.number_of_replicas": {{ .Replicas }},
9+
"index.number_of_shards": {{ .ShardsDependencies }},
10+
"index.number_of_replicas": {{ .ReplicasDependencies }},
1111
"index.mapping.nested_fields.limit":50,
1212
"index.requests.cache.enable":true
1313
{{- if .UseILM }}

plugin/storage/es/mappings/jaeger-dependencies-8.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
},
99
{{- end }}
1010
"settings": {
11-
"index.number_of_shards": {{ .Shards }},
12-
"index.number_of_replicas": {{ .Replicas }},
11+
"index.number_of_shards": {{ .ShardsDependencies }},
12+
"index.number_of_replicas": {{ .ReplicasDependencies }},
1313
"index.mapping.nested_fields.limit": 50,
1414
"index.requests.cache.enable": true
1515
{{- if .UseILM }},

plugin/storage/es/mappings/jaeger-sampling-6.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"template": "*jaeger-sampling-*",
33
"settings":{
4-
"index.number_of_shards": {{ .Shards }},
5-
"index.number_of_replicas": {{ .Replicas }},
4+
"index.number_of_shards": {{ .ShardsSampling }},
5+
"index.number_of_replicas": {{ .ReplicasSampling }},
66
"index.mapping.nested_fields.limit":50,
77
"index.requests.cache.enable":false
88
},

plugin/storage/es/mappings/jaeger-sampling-7.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
},
77
{{- end }}
88
"settings":{
9-
"index.number_of_shards": {{ .Shards }},
10-
"index.number_of_replicas": {{ .Replicas }},
9+
"index.number_of_shards": {{ .ShardsSampling }},
10+
"index.number_of_replicas": {{ .ReplicasSampling }},
1111
"index.mapping.nested_fields.limit":50,
1212
"index.requests.cache.enable":false
1313
{{- if .UseILM }}

plugin/storage/es/mappings/jaeger-sampling-8.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
},
99
{{- end }}
1010
"settings": {
11-
"index.number_of_shards": {{ .Shards }},
12-
"index.number_of_replicas": {{ .Replicas }},
11+
"index.number_of_shards": {{ .ShardsSampling }},
12+
"index.number_of_replicas": {{ .ReplicasSampling }},
1313
"index.mapping.nested_fields.limit": 50,
1414
"index.requests.cache.enable": false
1515
{{- if .UseILM }},

plugin/storage/es/mappings/jaeger-service-6.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"template": "*jaeger-service-*",
33
"settings":{
4-
"index.number_of_shards": {{ .Shards }},
5-
"index.number_of_replicas": {{ .Replicas }},
4+
"index.number_of_shards": {{ .ShardsService }},
5+
"index.number_of_replicas": {{ .ReplicasService }},
66
"index.mapping.nested_fields.limit":50,
77
"index.requests.cache.enable":true,
88
"index.mapper.dynamic":false

plugin/storage/es/mappings/jaeger-service-7.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
},
77
{{- end }}
88
"settings":{
9-
"index.number_of_shards": {{ .Shards }},
10-
"index.number_of_replicas": {{ .Replicas }},
9+
"index.number_of_shards": {{ .ShardsService }},
10+
"index.number_of_replicas": {{ .ReplicasService }},
1111
"index.mapping.nested_fields.limit":50,
1212
"index.requests.cache.enable":true
1313
{{- if .UseILM }}

plugin/storage/es/mappings/jaeger-service-8.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
},
99
{{- end }}
1010
"settings": {
11-
"index.number_of_shards": {{ .Shards }},
12-
"index.number_of_replicas": {{ .Replicas }},
11+
"index.number_of_shards": {{ .ShardsService }},
12+
"index.number_of_replicas": {{ .ReplicasService }},
1313
"index.mapping.nested_fields.limit": 50,
1414
"index.requests.cache.enable": true
1515
{{- if .UseILM }},

plugin/storage/es/mappings/jaeger-span-6.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"template": "*jaeger-span-*",
33
"settings":{
4-
"index.number_of_shards": {{ .Shards }},
5-
"index.number_of_replicas": {{ .Replicas }},
4+
"index.number_of_shards": {{ .ShardsSpan }},
5+
"index.number_of_replicas": {{ .ReplicasSpan }},
66
"index.mapping.nested_fields.limit":50,
77
"index.requests.cache.enable":true,
88
"index.mapper.dynamic":false

plugin/storage/es/mappings/jaeger-span-7.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
},
77
{{- end }}
88
"settings":{
9-
"index.number_of_shards": {{ .Shards }},
10-
"index.number_of_replicas": {{ .Replicas }},
9+
"index.number_of_shards": {{ .ShardsSpan }},
10+
"index.number_of_replicas": {{ .ReplicasSpan }},
1111
"index.mapping.nested_fields.limit":50,
1212
"index.requests.cache.enable":true
1313
{{- if .UseILM }}

plugin/storage/es/mappings/jaeger-span-8.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
},
1010
{{- end}}
1111
"settings": {
12-
"index.number_of_shards": {{ .Shards }},
13-
"index.number_of_replicas": {{ .Replicas }},
12+
"index.number_of_shards": {{ .ShardsSpan }},
13+
"index.number_of_replicas": {{ .ReplicasSpan }},
1414
"index.mapping.nested_fields.limit": 50,
1515
"index.requests.cache.enable": true
1616
{{- if .UseILM }},

plugin/storage/es/mappings/mapping.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ var MAPPINGS embed.FS
3030
// MappingBuilder holds parameters required to render an elasticsearch index template
3131
type MappingBuilder struct {
3232
TemplateBuilder es.TemplateBuilder
33-
Shards int64
34-
Replicas int64
33+
ShardsSpan int64
34+
ReplicasSpan int64
35+
ShardsService int64
36+
ReplicasService int64
37+
ShardsDependencies int64
38+
ReplicasDependencies int64
39+
ShardsSampling int64
40+
ReplicasSampling int64
3541
PrioritySpanTemplate int64
3642
PriorityServiceTemplate int64
3743
PriorityDependenciesTemplate int64

0 commit comments

Comments
 (0)