From 74f2b36e95010511b2cd46e28bcdc4ecf6609c28 Mon Sep 17 00:00:00 2001 From: Matheus Nogueira Date: Wed, 6 Sep 2023 15:07:46 -0300 Subject: [PATCH] fix: make sure trace.Spans() consider tree object when flat is nil --- server/traces/trace_entities.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/traces/trace_entities.go b/server/traces/trace_entities.go index 983fb65b71..7de54e9766 100644 --- a/server/traces/trace_entities.go +++ b/server/traces/trace_entities.go @@ -194,6 +194,11 @@ func (t *Trace) Spans() []Span { return []Span{} } + if len(t.Flat) == 0 { + t.Flat = make(map[trace.SpanID]*Span) + flattenSpans(t.Flat, t.RootSpan) + } + spans := make([]Span, 0, len(t.Flat)) for _, span := range t.Flat { spans = append(spans, *span)