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

Changed Range Query to use startTimeMillis date field instead of startTime field #2980

Merged
merged 8 commits into from May 11, 2021

Conversation

Sreevani871
Copy link
Contributor

@Sreevani871 Sreevani871 commented May 8, 2021

Which problem is this PR solving?

Short description of the changes

If es.use-aliases cofiguration field is set to true, jaeger-span-read alias is used in Elasticsearch which is applying to all indexes. Using time range query Elasticsearch will skip the unnecessary shards while searching. At present in the code, the startTime field is used in range query but it is stored as type: long in Elasticsearch mapping. it's not skipping the unnecessary shards since Elasticsearch timeRange queries works with only type: date field as discussed in the issue: #2923.
Using startTimeMillisField irrespective of es.use-aliases: true will improve the performance of the ES query.

  • Changed TimeRange query to use startTimeMillis field(type:date) instead of startTime(type:long).
  • Added time range term query to the ES query used in the multiRead method to avail the performance benefit.

Closed PR: #2978

Sreevani871 and others added 4 commits August 14, 2020 10:48
@Sreevani871 Sreevani871 requested a review from a team as a code owner May 8, 2021 04:45
Signed-off-by: Sreevani871 <sreevani.karasala@freshworks.com>
Signed-off-by: Sreevani871 <sreevani.karasala@freshworks.com>
@codecov
Copy link

codecov bot commented May 8, 2021

Codecov Report

Merging #2980 (178a3f7) into master (b9e7dfb) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2980   +/-   ##
=======================================
  Coverage   95.95%   95.95%           
=======================================
  Files         223      223           
  Lines        9720     9726    +6     
=======================================
+ Hits         9327     9333    +6     
  Misses        325      325           
  Partials       68       68           
Impacted Files Coverage Δ
plugin/storage/es/spanstore/reader.go 100.00% <100.00%> (ø)
cmd/query/app/server.go 95.62% <0.00%> (-1.46%) ⬇️
plugin/storage/badger/spanstore/reader.go 96.08% <0.00%> (+0.71%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b9e7dfb...178a3f7. Read the comment docs.

Comment on lines 371 to 381
traceQuery := buildTraceByIDQuery(traceID)
var query *elastic.BoolQuery
if s.useReadWriteAliases {
query = elastic.NewBoolQuery().
Must(startTimeRangeQuery).
Must(traceQuery)
} else {
query = elastic.NewBoolQuery().
Must(traceQuery)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can simplify to:

                        query := elastic.NewBoolQuery().
				Must(traceQuery)
			if s.useReadWriteAliases {
				startTimeRangeQuery := s.buildStartTimeQuery(startTime.Add(-time.Hour*24), endTime.Add(time.Hour*24))
				query = query.Must(startTimeRangeQuery)
			}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Changed suggested way.

Signed-off-by: Sreevani871 <sreevani.karasala@freshworks.com>
albertteoh
albertteoh previously approved these changes May 11, 2021
@mergify mergify bot dismissed albertteoh’s stale review May 11, 2021 05:49

Pull request has been modified.

@albertteoh albertteoh merged commit 073a341 into jaegertracing:master May 11, 2021
@albertteoh
Copy link
Contributor

Thanks @Sreevani871 !

@jpkrohling jpkrohling added this to the Release 1.23.0 milestone Jun 4, 2021
@bhiravabhatla
Copy link
Contributor

This actually brought our average search time on Jaeger UI by 1/10. For search all the traces for a particular service/operation in last 2 hours - it used to take 30 secs on average [ We use ES backend and aliases ]. It is down to 3 seconds now. Awesome work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants