-
Notifications
You must be signed in to change notification settings - Fork 2
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
Read trace ID from ES without leading zeros #1
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -337,7 +337,17 @@ func (s *SpanReader) multiRead(ctx context.Context, traceIDs []model.TraceID, st | |
} | ||
searchRequests := make([]*elastic.SearchRequest, len(traceIDs)) | ||
for i, traceID := range traceIDs { | ||
query := elastic.NewTermQuery("traceID", traceID.String()) | ||
// TODO remove in newer versions, added in Jaeger 1.16 | ||
// read ID without leading zeros | ||
// https://github.com/jaegertracing/jaeger/pull/1956 added leading zeros to IDs | ||
var legacyTraceID string | ||
if traceID.High == 0 { | ||
legacyTraceID = fmt.Sprintf("%x", traceID.Low) | ||
} else { | ||
legacyTraceID = fmt.Sprintf("%x%016x", traceID.High, traceID.Low) | ||
} | ||
query := elastic.NewBoolQuery(). | ||
Should( elastic.NewTermQuery(traceIDField, traceID.String()).Boost(2), elastic.NewTermQuery(traceIDField, legacyTraceID)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not really sure what goes on in this query, but is there any reason to not simply add the legacy ID to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's basically or statement and the new ID has a higher priority https://www.elastic.co/guide/en/elasticsearch/reference/6.6//query-dsl-term-query.html There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rather do this than running a separate query. It might be more effective. |
||
if val, ok := searchAfterTime[traceID]; ok { | ||
nextTime = val | ||
} | ||
|
@@ -394,16 +404,23 @@ func (s *SpanReader) multiRead(ctx context.Context, traceIDs []model.TraceID, st | |
} | ||
|
||
func convertTraceIDsStringsToModels(traceIDs []string) ([]model.TraceID, error) { | ||
traceIDsModels := make([]model.TraceID, len(traceIDs)) | ||
for i, ID := range traceIDs { | ||
traceIDsMap := map[model.TraceID]bool{} | ||
for _, ID := range traceIDs { | ||
traceID, err := model.TraceIDFromString(ID) | ||
if err != nil { | ||
return nil, errors.Wrap(err, fmt.Sprintf("Making traceID from string '%s' failed", ID)) | ||
} | ||
|
||
traceIDsModels[i] = traceID | ||
if _, ok := traceIDsMap[traceID]; !ok { | ||
traceIDsMap[traceID] = true | ||
} | ||
} | ||
|
||
traceIDsModels := make([]model.TraceID, len(traceIDsMap)) | ||
i := 0 | ||
for id, _ := range traceIDsMap { | ||
traceIDsModels[i] = id | ||
i++ | ||
} | ||
return traceIDsModels, nil | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we only want to do that if the normal ID string starts with a 0, otherwise issue a single query.