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
Remove unused field from waterfall response (part 1 of memory opt) (#11337)
Nikhil Sonif47f1ad92bb3
diff --git a/docs/api/openapi.yml b/docs/api/openapi.ymlindex ba7ec267a1..252931a664 100644--- a/docs/api/openapi.yml+++ b/docs/api/openapi.yml@@ -5686,12 +5686,6 @@ components:type: stringrootServiceName:type: string- serviceNameToTotalDurationMap:- additionalProperties:- minimum: 0- type: integer- nullable: true- type: objectspans:items:$ref: '#/components/schemas/SpantypesWaterfallSpan'diff --git a/frontend/src/api/generated/services/sigNoz.schemas.ts b/frontend/src/api/generated/services/sigNoz.schemas.tsindex 6b1d9a45be..1452b59223 100644--- a/frontend/src/api/generated/services/sigNoz.schemas.ts+++ b/frontend/src/api/generated/services/sigNoz.schemas.ts@@ -6743,15 +6743,6 @@ export interface SpantypesGettableSpanMapperGroupsDTO {items: SpantypesSpanMapperGroupDTO[];}-export type SpantypesGettableWaterfallTraceDTOServiceNameToTotalDurationMapAnyOf =- { [key: string]: number };--/**- * @nullable- */-export type SpantypesGettableWaterfallTraceDTOServiceNameToTotalDurationMap =- SpantypesGettableWaterfallTraceDTOServiceNameToTotalDurationMapAnyOf | null;-export enum SpantypesSpanAggregationTypeDTO {span_count = 'span_count',execution_time_percentage = 'execution_time_percentage',@@ -6940,10 +6931,6 @@ export interface SpantypesGettableWaterfallTraceDTO {* @type string*/rootServiceName?: string;- /**- * @type object,null- */- serviceNameToTotalDurationMap?: SpantypesGettableWaterfallTraceDTOServiceNameToTotalDurationMap;/*** @type array,null*/diff --git a/pkg/modules/tracedetail/impltracedetail/waterfall_test.go b/pkg/modules/tracedetail/impltracedetail/waterfall_test.goindex 8f1fa5de7a..a85b586460 100644--- a/pkg/modules/tracedetail/impltracedetail/waterfall_test.go+++ b/pkg/modules/tracedetail/impltracedetail/waterfall_test.go@@ -97,7 +97,7 @@ func makeChain(n int) (*spantypes.WaterfallSpan, map[string]*spantypes.Waterfall}func getWaterfallTrace(roots []*spantypes.WaterfallSpan, spanMap map[string]*spantypes.WaterfallSpan) *spantypes.WaterfallTrace {- return spantypes.NewWaterfallTrace(0, 0, uint64(len(spanMap)), 0, spanMap, nil, roots, false)+ return spantypes.NewWaterfallTrace(0, 0, uint64(len(spanMap)), 0, spanMap, roots, false)}// ─────────────────────────────────────────────────────────────────────────────diff --git a/pkg/types/spantypes/aggregation_test.go b/pkg/types/spantypes/aggregation_test.goindex 5f356192cb..fc6fda96bf 100644--- a/pkg/types/spantypes/aggregation_test.go+++ b/pkg/types/spantypes/aggregation_test.go@@ -33,7 +33,7 @@ func buildTraceFromSpans(spans ...*WaterfallSpan) *WaterfallTrace {endTime = end}}- return NewWaterfallTrace(startTime, endTime, uint64(len(spanMap)), 0, spanMap, nil, nil, false)+ return NewWaterfallTrace(startTime, endTime, uint64(len(spanMap)), 0, spanMap, nil, false)}var (diff --git a/pkg/types/spantypes/waterfall_trace.go b/pkg/types/spantypes/waterfall_trace.goindex 088792c4e5..e3832d7b59 100644--- a/pkg/types/spantypes/waterfall_trace.go+++ b/pkg/types/spantypes/waterfall_trace.go@@ -20,50 +20,45 @@ type TraceSummary struct {// WaterfallTrace holds processed trace data with childern populated in spans.type WaterfallTrace struct {- StartTime uint64 `json:"startTime"`- EndTime uint64 `json:"endTime"`- TotalSpans uint64 `json:"totalSpans"`- TotalErrorSpans uint64 `json:"totalErrorSpans"`- ServiceNameToTotalDurationMap map[string]uint64 `json:"serviceNameToTotalDurationMap"`- SpanIDToSpanNodeMap map[string]*WaterfallSpan `json:"spanIdToSpanNodeMap"`- TraceRoots []*WaterfallSpan `json:"traceRoots"`- HasMissingSpans bool `json:"hasMissingSpans"`+ StartTime uint64 `json:"startTime"`+ EndTime uint64 `json:"endTime"`+ TotalSpans uint64 `json:"totalSpans"`+ TotalErrorSpans uint64 `json:"totalErrorSpans"`+ SpanIDToSpanNodeMap map[string]*WaterfallSpan `json:"spanIdToSpanNodeMap"`+ TraceRoots []*WaterfallSpan `json:"traceRoots"`+ HasMissingSpans bool `json:"hasMissingSpans"`}// GettableWaterfallTrace is the response for the v3 waterfall API.type GettableWaterfallTrace struct {- StartTimestampMillis uint64 `json:"startTimestampMillis"`- EndTimestampMillis uint64 `json:"endTimestampMillis"`- RootServiceName string `json:"rootServiceName"`- RootServiceEntryPoint string `json:"rootServiceEntryPoint"`- TotalSpansCount uint64 `json:"totalSpansCount"`- TotalErrorSpansCount uint64 `json:"totalErrorSpansCount"`- // Deprecated: use Aggregations with SpanAggregationExecutionTimePercentage on the service.name field instead.- ServiceNameToTotalDurationMap map[string]uint64 `json:"serviceNameToTotalDurationMap"`- Spans []*WaterfallSpan `json:"spans"`- HasMissingSpans bool `json:"hasMissingSpans"`- UncollapsedSpans []string `json:"uncollapsedSpans"`- HasMore bool `json:"hasMore"`- Aggregations []SpanAggregationResult `json:"aggregations"`+ StartTimestampMillis uint64 `json:"startTimestampMillis"`+ EndTimestampMillis uint64 `json:"endTimestampMillis"`+ RootServiceName string `json:"rootServiceName"`+ RootServiceEntryPoint string `json:"rootServiceEntryPoint"`+ TotalSpansCount uint64 `json:"totalSpansCount"`+ TotalErrorSpansCount uint64 `json:"totalErrorSpansCount"`+ Spans []*WaterfallSpan `json:"spans"`+ HasMissingSpans bool `json:"hasMissingSpans"`+ UncollapsedSpans []string `json:"uncollapsedSpans"`+ HasMore bool `json:"hasMore"`+ Aggregations []SpanAggregationResult `json:"aggregations"`}// NewWaterfallTrace constructs a WaterfallTrace from processed span data.func NewWaterfallTrace(startTime, endTime, totalSpans, totalErrorSpans uint64,spanIDToSpanNodeMap map[string]*WaterfallSpan,- serviceNameToTotalDurationMap map[string]uint64,traceRoots []*WaterfallSpan,hasMissingSpans bool,) *WaterfallTrace {return &WaterfallTrace{- StartTime: startTime,- EndTime: endTime,- TotalSpans: totalSpans,- TotalErrorSpans: totalErrorSpans,- SpanIDToSpanNodeMap: spanIDToSpanNodeMap,- ServiceNameToTotalDurationMap: serviceNameToTotalDurationMap,- TraceRoots: traceRoots,- HasMissingSpans: hasMissingSpans,+ StartTime: startTime,+ EndTime: endTime,+ TotalSpans: totalSpans,+ TotalErrorSpans: totalErrorSpans,+ SpanIDToSpanNodeMap: spanIDToSpanNodeMap,+ TraceRoots: traceRoots,+ HasMissingSpans: hasMissingSpans,}}@@ -124,7 +119,6 @@ func NewWaterfallTraceFromSpans(spans []StorableSpan) *WaterfallTrace {uint64(len(spans)),totalErrorSpans,spanIDToSpanNodeMap,- calculateServiceTime(spanIDToSpanNodeMap),traceRoots,hasMissingSpans,)@@ -206,23 +200,19 @@ func (wt *WaterfallTrace) CalculateUncollapsedSpanIDs(uncollapsedSpanIDs []strin}func (wt *WaterfallTrace) Clone() cachetypes.Cacheable {- copyOfServiceNameToTotalDurationMap := make(map[string]uint64)- maps.Copy(copyOfServiceNameToTotalDurationMap, wt.ServiceNameToTotalDurationMap)-copyOfSpanIDToSpanNodeMap := make(map[string]*WaterfallSpan)maps.Copy(copyOfSpanIDToSpanNodeMap, wt.SpanIDToSpanNodeMap)copyOfTraceRoots := make([]*WaterfallSpan, len(wt.TraceRoots))copy(copyOfTraceRoots, wt.TraceRoots)return &WaterfallTrace{- StartTime: wt.StartTime,- EndTime: wt.EndTime,- TotalSpans: wt.TotalSpans,- TotalErrorSpans: wt.TotalErrorSpans,- ServiceNameToTotalDurationMap: copyOfServiceNameToTotalDurationMap,- SpanIDToSpanNodeMap: copyOfSpanIDToSpanNodeMap,- TraceRoots: copyOfTraceRoots,- HasMissingSpans: wt.HasMissingSpans,+ StartTime: wt.StartTime,+ EndTime: wt.EndTime,+ TotalSpans: wt.TotalSpans,+ TotalErrorSpans: wt.TotalErrorSpans,+ SpanIDToSpanNodeMap: copyOfSpanIDToSpanNodeMap,+ TraceRoots: copyOfTraceRoots,+ HasMissingSpans: wt.HasMissingSpans,}}@@ -257,11 +247,6 @@ func NewGettableWaterfallTrace(rootServiceEntryPoint = traceData.TraceRoots[0].Name}- serviceDurationsMillis := make(map[string]uint64, len(traceData.ServiceNameToTotalDurationMap))- for svc, dur := range traceData.ServiceNameToTotalDurationMap {- serviceDurationsMillis[svc] = dur / 1_000_000- }-// convert start timestamp to millis because client is expecting it in millisfor _, span := range selectedSpans {span.TimeUnix = span.TimeUnix / 1_000_000@@ -277,18 +262,17 @@ func NewGettableWaterfallTrace(}return &GettableWaterfallTrace{- Spans: selectedSpans,- UncollapsedSpans: uncollapsedSpans,- StartTimestampMillis: traceData.StartTime / 1_000_000,- EndTimestampMillis: traceData.EndTime / 1_000_000,- TotalSpansCount: traceData.TotalSpans,- TotalErrorSpansCount: traceData.TotalErrorSpans,- RootServiceName: rootServiceName,- RootServiceEntryPoint: rootServiceEntryPoint,- ServiceNameToTotalDurationMap: serviceDurationsMillis,- HasMissingSpans: traceData.HasMissingSpans,- HasMore: !selectAllSpans,- Aggregations: aggregations,+ Spans: selectedSpans,+ UncollapsedSpans: uncollapsedSpans,+ StartTimestampMillis: traceData.StartTime / 1_000_000,+ EndTimestampMillis: traceData.EndTime / 1_000_000,+ TotalSpansCount: traceData.TotalSpans,+ TotalErrorSpansCount: traceData.TotalErrorSpans,+ RootServiceName: rootServiceName,+ RootServiceEntryPoint: rootServiceEntryPoint,+ HasMissingSpans: traceData.HasMissingSpans,+ HasMore: !selectAllSpans,+ Aggregations: aggregations,}}@@ -311,21 +295,6 @@ func windowAroundIndex(selectedIndex, total int, spanLimitPerRequest float64) (sreturn}-func calculateServiceTime(spanIDToSpanNodeMap map[string]*WaterfallSpan) map[string]uint64 {- serviceSpans := make(map[string][]*WaterfallSpan)- for _, span := range spanIDToSpanNodeMap {- if span.ServiceName != "" {- serviceSpans[span.ServiceName] = append(serviceSpans[span.ServiceName], span)- }- }-- totalTimes := make(map[string]uint64)- for service, spans := range serviceSpans {- totalTimes[service] = mergeSpanIntervals(spans)- }- return totalTimes-}-// mergeSpanIntervals computes non-overlapping execution time for a set of spans.func mergeSpanIntervals(spans []*WaterfallSpan) uint64 {if len(spans) == 0 {