Skip to content

Commit

Permalink
fixes nested tags search error
Browse files Browse the repository at this point in the history
Signed-off-by: bugslayer-332 <[email protected]>
  • Loading branch information
severussnape321 committed Aug 12, 2023
1 parent 5b9e7e1 commit db2245e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions plugin/storage/es/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ func createSpanReader(
SpanIndexRolloverFrequency: cfg.GetIndexRolloverFrequencySpansDuration(),
ServiceIndexRolloverFrequency: cfg.GetIndexRolloverFrequencyServicesDuration(),
TagDotReplacement: cfg.Tags.DotReplacement,
AllTagsAsFields: cfg.Tags.AllAsFields,
UseReadWriteAliases: cfg.UseReadWriteAliases,
Archive: archive,
RemoteReadClusters: cfg.RemoteReadClusters,
Expand Down
15 changes: 11 additions & 4 deletions plugin/storage/es/spanstore/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ var (

objectTagFieldList = []string{objectTagsField, objectProcessTagsField}

nestedTagFieldList = []string{nestedTagsField, nestedProcessTagsField, nestedLogFieldsField}
nestedTagFieldList = []string{nestedTagsField, nestedProcessTagsField}
)

// SpanReader can query for and load traces from ElasticSearch
Expand All @@ -104,6 +104,7 @@ type SpanReader struct {
spanIndexRolloverFrequency time.Duration
serviceIndexRolloverFrequency time.Duration
spanConverter dbmodel.ToDomain
allTagsAsFields bool
timeRangeIndices timeRangeIndexFn
sourceFn sourceFn
maxDocCount int
Expand All @@ -123,6 +124,7 @@ type SpanReaderParams struct {
SpanIndexRolloverFrequency time.Duration
ServiceIndexRolloverFrequency time.Duration
TagDotReplacement string
AllTagsAsFields bool
Archive bool
UseReadWriteAliases bool
RemoteReadClusters []string
Expand Down Expand Up @@ -150,6 +152,7 @@ func NewSpanReader(p SpanReaderParams) *SpanReader {
spanIndexRolloverFrequency: p.SpanIndexRolloverFrequency,
serviceIndexRolloverFrequency: p.SpanIndexRolloverFrequency,
spanConverter: dbmodel.NewToDomain(p.TagDotReplacement),
allTagsAsFields: p.AllTagsAsFields,
timeRangeIndices: getTimeRangeIndexFn(p.Archive, p.UseReadWriteAliases, p.RemoteReadClusters),
sourceFn: getSourceFn(p.Archive, p.MaxDocCount),
maxDocCount: p.MaxDocCount,
Expand Down Expand Up @@ -668,14 +671,18 @@ func (s *SpanReader) buildOperationNameQuery(operationName string) elastic.Query

func (s *SpanReader) buildTagQuery(k string, v string) elastic.Query {
objectTagListLen := len(objectTagFieldList)
queries := make([]elastic.Query, len(nestedTagFieldList)+objectTagListLen)
queries := make([]elastic.Query, objectTagListLen)
kd := s.spanConverter.ReplaceDot(k)
for i := range objectTagFieldList {
queries[i] = s.buildObjectQuery(objectTagFieldList[i], kd, v)
}
for i := range nestedTagFieldList {
queries[i+objectTagListLen] = s.buildNestedQuery(nestedTagFieldList[i], k, v)
if !s.allTagsAsFields {
for i := range nestedTagFieldList {
queries = append(queries, s.buildNestedQuery(nestedTagFieldList[i], k, v))
}
}
// Nested Logs Query
queries = append(queries, s.buildNestedQuery(nestedLogFieldsField, k, v))

// but configuration can change over time
return elastic.NewBoolQuery().Should(queries...)
Expand Down
1 change: 1 addition & 0 deletions plugin/storage/integration/elasticsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ func (s *ESStorageIntegration) initSpanstore(allTagsAsFields, archive bool) erro
IndexPrefix: indexPrefix,
MaxSpanAge: maxSpanAge,
TagDotReplacement: tagKeyDeDotChar,
AllTagsAsFields: allTagsAsFields,
Archive: archive,
MaxDocCount: defaultMaxDocCount,
Tracer: tracer.Tracer("test"),
Expand Down

0 comments on commit db2245e

Please sign in to comment.