mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-17 09:05:54 +08:00
fix: smartTraceAlgo for new schema (#6602)
This commit is contained in:
parent
81775c7d55
commit
f9d4cf19e9
@ -1203,7 +1203,9 @@ func (r *ClickHouseReader) GetUsage(ctx context.Context, queryParams *model.GetU
|
|||||||
return &usageItems, nil
|
return &usageItems, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ClickHouseReader) SearchTracesV2(ctx context.Context, params *model.SearchTracesParams) (*[]model.SearchSpansResult, error) {
|
func (r *ClickHouseReader) SearchTracesV2(ctx context.Context, params *model.SearchTracesParams,
|
||||||
|
smartTraceAlgorithm func(payload []model.SearchSpanResponseItem, targetSpanId string,
|
||||||
|
levelUp int, levelDown int, spanLimit int) ([]model.SearchSpansResult, error)) (*[]model.SearchSpansResult, error) {
|
||||||
searchSpansResult := []model.SearchSpansResult{
|
searchSpansResult := []model.SearchSpansResult{
|
||||||
{
|
{
|
||||||
Columns: []string{"__time", "SpanId", "TraceId", "ServiceName", "Name", "Kind", "DurationNano", "TagsKeys", "TagsValues", "References", "Events", "HasError", "StatusMessage", "StatusCodeString", "SpanKind"},
|
Columns: []string{"__time", "SpanId", "TraceId", "ServiceName", "Name", "Kind", "DurationNano", "TagsKeys", "TagsValues", "References", "Events", "HasError", "StatusMessage", "StatusCodeString", "SpanKind"},
|
||||||
@ -1318,9 +1320,29 @@ func (r *ClickHouseReader) SearchTracesV2(ctx context.Context, params *model.Sea
|
|||||||
end = time.Now()
|
end = time.Now()
|
||||||
zap.L().Debug("getTraceSQLQuery unmarshal took: ", zap.Duration("duration", end.Sub(start)))
|
zap.L().Debug("getTraceSQLQuery unmarshal took: ", zap.Duration("duration", end.Sub(start)))
|
||||||
|
|
||||||
for i, item := range searchSpanResponses {
|
err = r.featureFlags.CheckFeature(model.SmartTraceDetail)
|
||||||
spanEvents := item.GetValues()
|
smartAlgoEnabled := err == nil
|
||||||
searchSpansResult[0].Events[i] = spanEvents
|
if len(searchScanResponses) > params.SpansRenderLimit && smartAlgoEnabled {
|
||||||
|
start = time.Now()
|
||||||
|
searchSpansResult, err = smartTraceAlgorithm(searchSpanResponses, params.SpanID, params.LevelUp, params.LevelDown, params.SpansRenderLimit)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
end = time.Now()
|
||||||
|
zap.L().Debug("smartTraceAlgo took: ", zap.Duration("duration", end.Sub(start)))
|
||||||
|
userEmail, err := auth.GetEmailFromJwt(ctx)
|
||||||
|
if err == nil {
|
||||||
|
data := map[string]interface{}{
|
||||||
|
"traceSize": len(searchScanResponses),
|
||||||
|
"spansRenderLimit": params.SpansRenderLimit,
|
||||||
|
}
|
||||||
|
telemetry.GetInstance().SendEvent(telemetry.TELEMETRY_EVENT_LARGE_TRACE_OPENED, data, userEmail, true, false)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for i, item := range searchSpanResponses {
|
||||||
|
spanEvents := item.GetValues()
|
||||||
|
searchSpansResult[0].Events[i] = spanEvents
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
searchSpansResult[0].StartTimestampMillis = startTime - (durationNano / 1000000)
|
searchSpansResult[0].StartTimestampMillis = startTime - (durationNano / 1000000)
|
||||||
@ -1334,7 +1356,7 @@ func (r *ClickHouseReader) SearchTraces(ctx context.Context, params *model.Searc
|
|||||||
levelUp int, levelDown int, spanLimit int) ([]model.SearchSpansResult, error)) (*[]model.SearchSpansResult, error) {
|
levelUp int, levelDown int, spanLimit int) ([]model.SearchSpansResult, error)) (*[]model.SearchSpansResult, error) {
|
||||||
|
|
||||||
if r.useTraceNewSchema {
|
if r.useTraceNewSchema {
|
||||||
return r.SearchTracesV2(ctx, params)
|
return r.SearchTracesV2(ctx, params, smartTraceAlgorithm)
|
||||||
}
|
}
|
||||||
|
|
||||||
var countSpans uint64
|
var countSpans uint64
|
||||||
|
Loading…
x
Reference in New Issue
Block a user