fix: include orphan traces (#4)
This commit is contained in:
parent
e6cb20bc83
commit
32c7cb85df
1 changed files with 19 additions and 11 deletions
12
main.go
12
main.go
|
@ -39,7 +39,7 @@ type Trace struct {
|
|||
|
||||
type TraceData struct {
|
||||
Trace Trace `json:"trace"`
|
||||
Orphaned []Span `json:"orphaned"`
|
||||
Orphaned []Trace `json:"orphaned"`
|
||||
IsTruncated bool `json:"is_truncated"`
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,14 @@ func buildSpanIndexes(fullTrace TraceData) (map[string]Span, map[string][]string
|
|||
spansById := map[string]Span{}
|
||||
spanIdsByResourceName := map[string][]string{}
|
||||
|
||||
for key, value := range fullTrace.Trace.Spans {
|
||||
tracesToProcess := []Trace{fullTrace.Trace}
|
||||
|
||||
if fullTrace.Orphaned != nil {
|
||||
tracesToProcess = append(tracesToProcess, fullTrace.Orphaned...)
|
||||
}
|
||||
|
||||
for _, trace := range tracesToProcess {
|
||||
for key, value := range trace.Spans {
|
||||
resourceName := value.Resource
|
||||
spansById[key] = value
|
||||
|
||||
|
@ -106,6 +113,7 @@ func buildSpanIndexes(fullTrace TraceData) (map[string]Span, map[string][]string
|
|||
spanIdsByResourceName[resourceName] = append(spanList, key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return spansById, spanIdsByResourceName
|
||||
}
|
||||
|
|
Reference in a new issue