SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix: sibling spans order respects the span start timestamp (#9842)
Muhammed Ajmal M815c60485d7d
diff --git a/pkg/query-service/app/clickhouseReader/reader.go b/pkg/query-service/app/clickhouseReader/reader.goindex 0e64566df6..a6ba763813 100644--- a/pkg/query-service/app/clickhouseReader/reader.go+++ b/pkg/query-service/app/clickhouseReader/reader.go@@ -934,6 +934,8 @@ func (r *ClickHouseReader) GetWaterfallSpansForTraceWithMetadata(ctx context.Conevents = append(events, eventMap)}+ startTimeUnixNano := uint64(item.TimeUnixNano.UnixNano())+jsonItem := model.Span{SpanID: item.SpanID,TraceID: item.TraceID,@@ -949,10 +951,10 @@ func (r *ClickHouseReader) GetWaterfallSpansForTraceWithMetadata(ctx context.ConEvents: events,TagMap: item.Attributes_string,Children: make([]*model.Span, 0),+ TimeUnixNano: startTimeUnixNano, // Store nanoseconds temporarily}// metadata calculation- startTimeUnixNano := uint64(item.TimeUnixNano.UnixNano())if startTime == 0 || startTimeUnixNano < startTime {startTime = startTimeUnixNano}@@ -967,12 +969,9 @@ func (r *ClickHouseReader) GetWaterfallSpansForTraceWithMetadata(ctx context.ContotalErrorSpans = totalErrorSpans + 1}- // convert start timestamp to millis because right now frontend is expecting it in millis- jsonItem.TimeUnixNano = uint64(item.TimeUnixNano.UnixNano() / 1000000)-// collect the intervals for service for execution time calculationserviceNameIntervalMap[jsonItem.ServiceName] =- append(serviceNameIntervalMap[jsonItem.ServiceName], tracedetail.Interval{StartTime: jsonItem.TimeUnixNano, Duration: jsonItem.DurationNano / 1000000, Service: jsonItem.ServiceName})+ append(serviceNameIntervalMap[jsonItem.ServiceName], tracedetail.Interval{StartTime: jsonItem.TimeUnixNano, Duration: jsonItem.DurationNano, Service: jsonItem.ServiceName})// append to the span node mapspanIdToSpanNodeMap[jsonItem.SpanID] = &jsonItem@@ -1050,6 +1049,15 @@ func (r *ClickHouseReader) GetWaterfallSpansForTraceWithMetadata(ctx context.ConselectedSpans, uncollapsedSpans, rootServiceName, rootServiceEntryPoint := tracedetail.GetSelectedSpans(req.UncollapsedSpans, req.SelectedSpanID, traceRoots, spanIdToSpanNodeMap, req.IsSelectedSpanIDUnCollapsed)zap.L().Info("getWaterfallSpansForTraceWithMetadata: processing post cache", zap.Duration("duration", time.Since(processingPostCache)), zap.String("traceID", traceID))+ // convert start timestamp to millis because right now frontend is expecting it in millis+ for _, span := range selectedSpans {+ span.TimeUnixNano = span.TimeUnixNano / 1000000+ }++ for serviceName, totalDuration := range serviceNameToTotalDurationMap {+ serviceNameToTotalDurationMap[serviceName] = totalDuration / 1000000+ }+response.Spans = selectedSpansresponse.UncollapsedSpans = uncollapsedSpansresponse.StartTimestampMillis = startTime / 1000000