(span: Span)
| 64 | * Convert a span to a trace context, which can be sent as the `trace` context in a non-transaction event. |
| 65 | */ |
| 66 | export function spanToTraceContext(span: Span): TraceContext { |
| 67 | const { spanId, traceId: trace_id, isRemote } = span.spanContext(); |
| 68 | |
| 69 | // If the span is remote, we use a random/virtual span as span_id to the trace context, |
| 70 | // and the remote span as parent_span_id |
| 71 | const parent_span_id = isRemote ? spanId : spanToJSON(span).parent_span_id; |
| 72 | const scope = getCapturedScopesOnSpan(span).scope; |
| 73 | |
| 74 | const span_id = isRemote ? scope?.getPropagationContext().propagationSpanId || generateSpanId() : spanId; |
| 75 | |
| 76 | return { |
| 77 | parent_span_id, |
| 78 | span_id, |
| 79 | trace_id, |
| 80 | }; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Convert a Span to a Sentry trace header. |
no test coverage detected