Skip to content

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.

fix: return span start time similar to waterfall v2 (#11183)

Nikhil Soniac46cd8e8089
diff --git a/docs/api/openapi.yml b/docs/api/openapi.yml
index b7265b1727..60c034e6cb 100644
--- a/docs/api/openapi.yml
+++ b/docs/api/openapi.yml
@@ -5321,6 +5321,9 @@ components:
sub_tree_node_count:
minimum: 0
type: integer
+ time_unix:
+ minimum: 0
+ type: integer
trace_id:
type: string
trace_state:
diff --git a/frontend/src/api/generated/services/sigNoz.schemas.ts b/frontend/src/api/generated/services/sigNoz.schemas.ts
index c1bc29f04e..a59497ad0d 100644
--- a/frontend/src/api/generated/services/sigNoz.schemas.ts
+++ b/frontend/src/api/generated/services/sigNoz.schemas.ts
@@ -7714,6 +7714,11 @@ export interface TracedetailtypesWaterfallSpanDTO {
* @minimum 0
*/
sub_tree_node_count?: number;
+ /**
+ * @type integer
+ * @minimum 0
+ */
+ time_unix?: number;
/**
* @type string
*/
diff --git a/pkg/types/tracedetailtypes/aggregation_test.go b/pkg/types/tracedetailtypes/aggregation_test.go
index f1000aa72f..4863cb328d 100644
--- a/pkg/types/tracedetailtypes/aggregation_test.go
+++ b/pkg/types/tracedetailtypes/aggregation_test.go
@@ -13,7 +13,7 @@ func mkASpan(id string, resource map[string]string, attributes map[string]any, s
SpanID: id,
Resource: resource,
Attributes: attributes,
- TimeUnixNano: startNs,
+ TimeUnix: startNs,
DurationNano: durationNs,
Children: make([]*WaterfallSpan, 0),
}
@@ -25,11 +25,11 @@ func buildTraceFromSpans(spans ...*WaterfallSpan) *WaterfallTrace {
initialized := false
for _, s := range spans {
spanMap[s.SpanID] = s
- if !initialized || s.TimeUnixNano < startTime {
- startTime = s.TimeUnixNano
+ if !initialized || s.TimeUnix < startTime {
+ startTime = s.TimeUnix
initialized = true
}
- if end := s.TimeUnixNano + s.DurationNano; end > endTime {
+ if end := s.TimeUnix + s.DurationNano; end > endTime {
endTime = end
}
}
diff --git a/pkg/types/tracedetailtypes/waterfall_span.go b/pkg/types/tracedetailtypes/waterfall_span.go
index 90397e720b..31c495d77f 100644
--- a/pkg/types/tracedetailtypes/waterfall_span.go
+++ b/pkg/types/tracedetailtypes/waterfall_span.go
@@ -71,7 +71,7 @@ type WaterfallSpan struct {
ParentSpanID string `json:"parent_span_id"`
Resource map[string]string `json:"resource"`
SpanID string `json:"span_id"`
- TimeUnixNano uint64 `json:"-"`
+ TimeUnix uint64 `json:"time_unix"`
TraceID string `json:"trace_id"`
TraceState string `json:"trace_state"`
@@ -138,7 +138,7 @@ func NewMissingWaterfallSpan(spanID, traceID string, timeUnixNano, durationNano
SpanID: spanID,
TraceID: traceID,
Name: "Missing Span",
- TimeUnixNano: timeUnixNano,
+ TimeUnix: timeUnixNano,
DurationNano: durationNano,
Events: make([]Event, 0),
Children: make([]*WaterfallSpan, 0),
@@ -150,10 +150,10 @@ func NewMissingWaterfallSpan(spanID, traceID string, timeUnixNano, durationNano
// SortChildren recursively sorts children of each span by TimeUnixNano then Name.
func (ws *WaterfallSpan) SortChildren() {
sort.Slice(ws.Children, func(i, j int) bool {
- if ws.Children[i].TimeUnixNano == ws.Children[j].TimeUnixNano {
+ if ws.Children[i].TimeUnix == ws.Children[j].TimeUnix {
return ws.Children[i].Name < ws.Children[j].Name
}
- return ws.Children[i].TimeUnixNano < ws.Children[j].TimeUnixNano
+ return ws.Children[i].TimeUnix < ws.Children[j].TimeUnix
})
for _, child := range ws.Children {
child.SortChildren()
@@ -292,7 +292,7 @@ func (item *StorableSpan) ToWaterfallSpan() *WaterfallSpan {
TraceID: item.TraceID,
TraceState: item.TraceState,
Children: make([]*WaterfallSpan, 0),
- TimeUnixNano: uint64(item.StartTime.UnixNano()),
+ TimeUnix: uint64(item.StartTime.UnixNano()),
ServiceName: item.ServiceName,
}
}
diff --git a/pkg/types/tracedetailtypes/waterfall_trace.go b/pkg/types/tracedetailtypes/waterfall_trace.go
index 4eb28ff613..b5ca39b3c2 100644
--- a/pkg/types/tracedetailtypes/waterfall_trace.go
+++ b/pkg/types/tracedetailtypes/waterfall_trace.go
@@ -95,7 +95,7 @@ func NewWaterfallTraceFromSpans(spans []StorableSpan) *WaterfallTrace {
if parentNode, exists := spanIDToSpanNodeMap[spanNode.ParentSpanID]; exists {
parentNode.Children = append(parentNode.Children, spanNode)
} else {
- missingSpan := NewMissingWaterfallSpan(spanNode.ParentSpanID, spanNode.TraceID, spanNode.TimeUnixNano, spanNode.DurationNano)
+ missingSpan := NewMissingWaterfallSpan(spanNode.ParentSpanID, spanNode.TraceID, spanNode.TimeUnix, spanNode.DurationNano)
missingSpan.Children = append(missingSpan.Children, spanNode)
spanIDToSpanNodeMap[missingSpan.SpanID] = missingSpan
traceRoots = append(traceRoots, missingSpan)
@@ -112,10 +112,10 @@ func NewWaterfallTraceFromSpans(spans []StorableSpan) *WaterfallTrace {
}
sort.Slice(traceRoots, func(i, j int) bool {
- if traceRoots[i].TimeUnixNano == traceRoots[j].TimeUnixNano {
+ if traceRoots[i].TimeUnix == traceRoots[j].TimeUnix {
return traceRoots[i].Name < traceRoots[j].Name
}
- return traceRoots[i].TimeUnixNano < traceRoots[j].TimeUnixNano
+ return traceRoots[i].TimeUnix < traceRoots[j].TimeUnix
})
return NewWaterfallTrace(
@@ -264,7 +264,7 @@ func NewGettableWaterfallTrace(
// convert start timestamp to millis because client is expecting it in millis
for _, span := range selectedSpans {
- span.TimeUnixNano = span.TimeUnixNano / 1_000_000
+ span.TimeUnix = span.TimeUnix / 1_000_000
}
// duration values are in nanoseconds; convert in-place to milliseconds.
@@ -332,15 +332,15 @@ func mergeSpanIntervals(spans []*WaterfallSpan) uint64 {
return 0
}
sort.Slice(spans, func(i, j int) bool {
- return spans[i].TimeUnixNano < spans[j].TimeUnixNano
+ return spans[i].TimeUnix < spans[j].TimeUnix
})
- currentStart := spans[0].TimeUnixNano
+ currentStart := spans[0].TimeUnix
currentEnd := currentStart + spans[0].DurationNano
total := uint64(0)
for _, span := range spans[1:] {
- startNano := span.TimeUnixNano
+ startNano := span.TimeUnix
endNano := startNano + span.DurationNano
if currentEnd >= startNano {
if endNano > currentEnd {