Skip to content

Commit

Permalink
added support for esv8
Browse files Browse the repository at this point in the history
Signed-off-by: bugslayer-332 <[email protected]>
  • Loading branch information
severussnape321 committed Oct 10, 2023
1 parent 14a6bc0 commit 552d512
Show file tree
Hide file tree
Showing 13 changed files with 575 additions and 13 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ require (
github.com/eapache/go-resiliency v1.4.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/elastic/elastic-transport-go/v8 v8.0.0-20230329154755-1a3c63de0db6 // indirect
github.com/elastic/go-elasticsearch/v8 v8.10.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/go-kit/log v0.2.1 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 h1:Oy0F4A
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3/go.mod h1:YvSRo5mw33fLEx1+DlK6L2VV43tJt5Eyel9n9XBcR+0=
github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
github.com/elastic/elastic-transport-go/v8 v8.0.0-20230329154755-1a3c63de0db6 h1:1+44gxLdKRnR/Bx/iAtr+XqNcE4e0oODa63+FABNANI=
github.com/elastic/elastic-transport-go/v8 v8.0.0-20230329154755-1a3c63de0db6/go.mod h1:87Tcz8IVNe6rVSLdBux1o/PEItLtyabHU3naC7IoqKI=
github.com/elastic/go-elasticsearch/v8 v8.10.0 h1:ALg3DMxSrx07YmeMNcfPf7cFh1Ep2+Qa19EOXTbwr2k=
github.com/elastic/go-elasticsearch/v8 v8.10.0/go.mod h1:NGmpvohKiRHXI0Sw4fuUGn6hYOmAXlyCphKpzVBiqDE=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
Expand Down
21 changes: 21 additions & 0 deletions pkg/es/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"go.uber.org/zap/zapcore"
"go.uber.org/zap/zapgrpc"

elasticsearch8 "github.com/elastic/go-elasticsearch/v8"
"github.com/jaegertracing/jaeger/pkg/bearertoken"
"github.com/jaegertracing/jaeger/pkg/config/tlscfg"
"github.com/jaegertracing/jaeger/pkg/es"
Expand Down Expand Up @@ -187,6 +188,26 @@ func NewClient(c *Configuration, logger *zap.Logger, metricsFactory metrics.Fact
return eswrapper.WrapESClient(rawClient, service, c.Version), nil
}

func NewElasticSearch8Client(c *Configuration, logger *zap.Logger) (*elasticsearch8.Client, error) {
var options elasticsearch8.Config
options.Addresses = c.Servers
options.Username = c.Username
options.Password = c.Password
options.DiscoverNodesOnStart = c.Sniffer
transport, err := GetHTTPRoundTripper(c, logger)
if err != nil {
return nil, err
}
options.Transport = transport

client, err := elasticsearch8.NewClient(options)
if err != nil {
return nil, err
}
return client, nil

}

// ApplyDefaults copies settings from source unless its own value is non-zero.
func (c *Configuration) ApplyDefaults(source *Configuration) {
if len(c.RemoteReadClusters) == 0 {
Expand Down
7 changes: 7 additions & 0 deletions plugin/storage/es/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,15 @@ func createSpanWriter(
if err != nil {
return nil, err
}

elasticsearch8Client, err := config.NewElasticSearch8Client(cfg, logger)
if err != nil {
return nil, err
}

writer := esSpanStore.NewSpanWriter(esSpanStore.SpanWriterParams{
Client: clientFn,
V8Client: elasticsearch8Client,
IndexPrefix: cfg.IndexPrefix,
SpanIndexDateLayout: cfg.IndexDateLayoutSpans,
ServiceIndexDateLayout: cfg.IndexDateLayoutServices,
Expand Down
20 changes: 20 additions & 0 deletions plugin/storage/es/mappings/fixtures/jaeger-dependencies-8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"priority": 101,
"index_patterns": "*jaeger-dependencies-*",
"template": {
"aliases": {
"test-jaeger-dependencies-read": {}
},
"settings": {
"index.number_of_shards": 3,
"index.number_of_replicas": 3,
"index.mapping.nested_fields.limit": 50,
"index.requests.cache.enable": true,
"lifecycle": {
"name": "jaeger-test-policy",
"rollover_alias": "test-jaeger-dependencies-write"
}
},
"mappings": {}
}
}
51 changes: 51 additions & 0 deletions plugin/storage/es/mappings/fixtures/jaeger-service-8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"priority": 101,
"index_patterns": "*test-jaeger-service-*",
"template": {
"aliases": {
"test-jaeger-service-read": {}
},
"settings": {
"index.number_of_shards": 3,
"index.number_of_replicas": 3,
"index.mapping.nested_fields.limit": 50,
"index.requests.cache.enable": true,
"lifecycle": {
"name": "jaeger-test-policy",
"rollover_alias": "test-jaeger-service-write"
}
},
"mappings": {
"dynamic_templates": [
{
"span_tags_map": {
"mapping": {
"type": "keyword",
"ignore_above": 256
},
"path_match": "tag.*"
}
},
{
"process_tags_map": {
"mapping": {
"type": "keyword",
"ignore_above": 256
},
"path_match": "process.tag.*"
}
}
],
"properties": {
"serviceName": {
"type": "keyword",
"ignore_above": 256
},
"operationName": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
167 changes: 167 additions & 0 deletions plugin/storage/es/mappings/fixtures/jaeger-span-8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
{
"priority": 101,
"index_patterns": "*test-jaeger-span-*",
"template": {
"aliases": {
"test-jaeger-span-read": {}
},
"settings": {
"index.number_of_shards": 3,
"index.number_of_replicas": 3,
"index.mapping.nested_fields.limit": 50,
"index.requests.cache.enable": true,
"lifecycle": {
"name": "jaeger-test-policy",
"rollover_alias": "test-jaeger-span-write"
}
},
"mappings": {
"dynamic_templates": [
{
"span_tags_map": {
"mapping": {
"type": "keyword",
"ignore_above": 256
},
"path_match": "tag.*"
}
},
{
"process_tags_map": {
"mapping": {
"type": "keyword",
"ignore_above": 256
},
"path_match": "process.tag.*"
}
}
],
"properties": {
"traceID": {
"type": "keyword",
"ignore_above": 256
},
"parentSpanID": {
"type": "keyword",
"ignore_above": 256
},
"spanID": {
"type": "keyword",
"ignore_above": 256
},
"operationName": {
"type": "keyword",
"ignore_above": 256
},
"startTime": {
"type": "long"
},
"startTimeMillis": {
"type": "date",
"format": "epoch_millis"
},
"duration": {
"type": "long"
},
"flags": {
"type": "integer"
},
"logs": {
"type": "nested",
"dynamic": false,
"properties": {
"timestamp": {
"type": "long"
},
"fields": {
"type": "nested",
"dynamic": false,
"properties": {
"key": {
"type": "keyword",
"ignore_above": 256
},
"value": {
"type": "keyword",
"ignore_above": 256
},
"tagType": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"process": {
"properties": {
"serviceName": {
"type": "keyword",
"ignore_above": 256
},
"tag": {
"type": "object"
},
"tags": {
"type": "nested",
"dynamic": false,
"properties": {
"key": {
"type": "keyword",
"ignore_above": 256
},
"value": {
"type": "keyword",
"ignore_above": 256
},
"tagType": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"references": {
"type": "nested",
"dynamic": false,
"properties": {
"refType": {
"type": "keyword",
"ignore_above": 256
},
"traceID": {
"type": "keyword",
"ignore_above": 256
},
"spanID": {
"type": "keyword",
"ignore_above": 256
}
}
},
"tag": {
"type": "object"
},
"tags": {
"type": "nested",
"dynamic": false,
"properties": {
"key": {
"type": "keyword",
"ignore_above": 256
},
"value": {
"type": "keyword",
"ignore_above": 256
},
"tagType": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
24 changes: 24 additions & 0 deletions plugin/storage/es/mappings/jaeger-dependencies-8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"priority": 502,
"index_patterns": "*jaeger-dependencies-*",
"template": {
{{- if .UseILM }}
"aliases": {
"{{ .IndexPrefix }}jaeger-dependencies-read": {}
},
{{- end }}
"settings": {
"index.number_of_shards": {{ .Shards }},
"index.number_of_replicas": {{ .Replicas }},
"index.mapping.nested_fields.limit": 50,
"index.requests.cache.enable": true,
{{- if .UseILM }}
"lifecycle": {
"name": "{{ .ILMPolicyName }}",
"rollover_alias": "{{ .IndexPrefix }}jaeger-dependencies-write"
}
{{- end }}
},
"mappings": {}
}
}
55 changes: 55 additions & 0 deletions plugin/storage/es/mappings/jaeger-service-8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"priority": 501,
"index_patterns": "*{{ .IndexPrefix }}jaeger-service-*",
"template": {
{{- if .UseILM }}
"aliases": {
"{{ .IndexPrefix }}jaeger-service-read": {}
},
{{- end }}
"settings": {
"index.number_of_shards": {{ .Shards }},
"index.number_of_replicas": {{ .Replicas }},
"index.mapping.nested_fields.limit": 50,
"index.requests.cache.enable": true
{{- if .UseILM }},
"lifecycle": {
"name": "{{ .ILMPolicyName }}",
"rollover_alias": "{{ .IndexPrefix }}jaeger-service-write"
}
{{- end }}
},
"mappings": {
"dynamic_templates": [
{
"span_tags_map": {
"mapping": {
"type": "keyword",
"ignore_above": 256
},
"path_match": "tag.*"
}
},
{
"process_tags_map": {
"mapping": {
"type": "keyword",
"ignore_above": 256
},
"path_match": "process.tag.*"
}
}
],
"properties": {
"serviceName": {
"type": "keyword",
"ignore_above": 256
},
"operationName": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
Loading

0 comments on commit 552d512

Please sign in to comment.