@@ -92,7 +92,9 @@ async function extractSpans(
92
92
} else {
93
93
let parentLevel = idToLevelMap . get ( parentSpanId ) ;
94
94
if ( parentLevel === undefined ) {
95
- throw new Error ( `Parent level not found for ${ span . spanID } ` ) ;
95
+ // If traces are linked, there might be a parentId from another trace.
96
+ // In this case, we consider it a root span.
97
+ parentLevel = 0 ;
96
98
}
97
99
idToLevelMap . set ( span . spanID , parentLevel + 1 ) ;
98
100
}
@@ -110,12 +112,7 @@ async function extractSpans(
110
112
childCount = await fetchChildCountViaAPI ( datasourceUid , traceId , span . spanID , startTimeUnixNano , endTimeUnixNano ) ;
111
113
}
112
114
113
- const serviceNamespace =
114
- span . attributes ?. find ( ( a ) => a . key === 'service.namespace' ) ?. value ?. stringValue || undefined ;
115
-
116
- // Using k8s.container.name as the service name since this is specific to our Kubernetes environment.
117
- // Jaeger UI is pulling this info from the process object which is in our case translated to this attribute.
118
- const serviceName = span . attributes ?. find ( ( a ) => a . key === 'k8s.container.name' ) ?. value ?. stringValue || undefined ;
115
+ const serviceName = span . attributes ?. find ( ( a ) => a . key === 'service.name' ) ?. value ?. stringValue || undefined ;
119
116
120
117
spans . push ( {
121
118
spanId : span . spanID ,
@@ -126,8 +123,8 @@ async function extractSpans(
126
123
endTimeUnixNano : endTimeUnixNano ,
127
124
childStatus : childCount !== undefined && childCount > 0 ? ChildStatus . RemoteChildren : ChildStatus . NoChildren ,
128
125
childCount,
129
- name : serviceName || span . name || '' ,
130
- serviceNamespace ,
126
+ name : span . name || '' ,
127
+ serviceName ,
131
128
} ) ;
132
129
}
133
130
return spans ;
@@ -141,9 +138,7 @@ async function loadMoreSpans(
141
138
) : Promise < SpanInfo [ ] > {
142
139
const q = `{ trace:id = "${ traceId } " && span:parentID = "${
143
140
span . spanId
144
- } " } | select (span:parentID, span:name, span.k8s.container.name, resource.service.namespace${
145
- supportsChildCount ? ', childCount' : ''
146
- } )`;
141
+ } " } | select (span:parentID, span:name, resource.service.name${ supportsChildCount ? ', childCount' : '' } )`;
147
142
const start = mkUnixEpochFromNanoSeconds ( span . startTimeUnixNano ) ;
148
143
// As a precaution, we add 1 second to the end time.
149
144
// This is to avoid any rounding errors where the microseconds or nanoseconds are not included in the end time.
@@ -184,7 +179,7 @@ function TraceDetail({
184
179
queryFn : async ( ) => {
185
180
const start = mkUnixEpochFromMiliseconds ( startTimeInMs ) ;
186
181
const end = start + 1 ;
187
- const q = `{ trace:id = "${ traceId } " && nestedSetParent = -1 } | select (span:name, span.k8s.container.name, resource.service.namespace ${
182
+ const q = `{ trace:id = "${ traceId } " && nestedSetParent = -1 } | select (span:name, resource.service.name ${
188
183
supportsChildCount ? ', childCount' : ''
189
184
} )`;
190
185
const data = await search ( datasourceUid , q , start , end ) ;
0 commit comments