(span: Span)
| 212 | * Convert a span to the intermediate {@link StreamedSpanJSON} representation. |
| 213 | */ |
| 214 | export function spanToStreamedSpanJSON(span: Span): StreamedSpanJSON { |
| 215 | if (spanIsSentrySpan(span)) { |
| 216 | return span.getStreamedSpanJSON(); |
| 217 | } |
| 218 | |
| 219 | const { spanId: span_id, traceId: trace_id } = span.spanContext(); |
| 220 | |
| 221 | // Handle a span from @opentelemetry/sdk-base-trace's `Span` class |
| 222 | if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) { |
| 223 | const { attributes, startTime, name, endTime, status, links } = span; |
| 224 | |
| 225 | return { |
| 226 | name, |
| 227 | span_id, |
| 228 | trace_id, |
| 229 | parent_span_id: getOtelParentSpanId(span), |
| 230 | start_timestamp: spanTimeInputToSeconds(startTime), |
| 231 | end_timestamp: spanTimeInputToSeconds(endTime), |
| 232 | is_segment: span === INTERNAL_getSegmentSpan(span), |
| 233 | status: getSimpleStatus(status), |
| 234 | attributes: addStatusMessageAttribute(attributes, status), |
| 235 | links: getStreamedSpanLinks(links), |
| 236 | }; |
| 237 | } |
| 238 | |
| 239 | // Finally, as a fallback, at least we have `spanContext()`.... |
| 240 | // This should not actually happen in reality, but we need to handle it for type safety. |
| 241 | return { |
| 242 | span_id, |
| 243 | trace_id, |
| 244 | start_timestamp: 0, |
| 245 | name: '', |
| 246 | end_timestamp: 0, |
| 247 | status: 'ok', |
| 248 | is_segment: span === INTERNAL_getSegmentSpan(span), |
| 249 | }; |
| 250 | } |
| 251 | |
| 252 | /** |
| 253 | * In preparation for the next major of OpenTelemetry, we want to support |
no test coverage detected