Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions app/vtselect/traces/tempo/tempo.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ func summarySearchTracesResult(ctx context.Context, rows []*tracecommon.Row, lim
for _, row := range rows {
var traceID, serviceName, spanName, parentSpanID string
var startTimeUnixNano, endTimeUnixNano int64
var hasStart, hasEnd bool
var err error
for _, field := range row.Fields {
switch field.Name {
Expand All @@ -444,11 +445,13 @@ func summarySearchTracesResult(ctx context.Context, rows []*tracecommon.Row, lim
if err != nil {
return nil, err
}
hasStart = true
case otelpb.EndTimeUnixNanoField:
endTimeUnixNano, err = strconv.ParseInt(field.Value, 10, 64)
if err != nil {
return nil, err
}
hasEnd = true
default:
continue
}
Expand All @@ -469,8 +472,12 @@ func summarySearchTracesResult(ctx context.Context, rows []*tracecommon.Row, lim
}

summary.traceID = traceID
summary.startTimeUnixNano = min(summary.startTimeUnixNano, startTimeUnixNano)
summary.endTimeUnixNano = max(summary.endTimeUnixNano, endTimeUnixNano)
if hasStart {
summary.startTimeUnixNano = min(summary.startTimeUnixNano, startTimeUnixNano)
}
if hasEnd {
summary.endTimeUnixNano = max(summary.endTimeUnixNano, endTimeUnixNano)
}
// if it's the root span
if parentSpanID == "" {
summary.rootServiceName = serviceName
Expand All @@ -482,6 +489,9 @@ func summarySearchTracesResult(ctx context.Context, rows []*tracecommon.Row, lim

resultList := make([]traceSummary, 0, len(traceMap))
for _, summary := range traceMap {
if summary.startTimeUnixNano == math.MaxInt64 {
summary.startTimeUnixNano = 0
}
resultList = append(resultList, summary)
}
return resultList, nil
Expand Down
2 changes: 1 addition & 1 deletion app/vtselect/traces/tempo/tempo.qtpl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"traceID":{%q= summary.traceID %},
"rootServiceName":{%q= summary.rootServiceName %},
"rootTraceName":{%q= summary.rootTraceName %},
"startTimeUnixNano":{%dl= summary.startTimeUnixNano %},
"startTimeUnixNano":"{%dl= summary.startTimeUnixNano %}",
"durationMs":{%dl= (summary.endTimeUnixNano - summary.startTimeUnixNano) / 1e6 %},
"spanSets": []
}
Expand Down
Loading