(scope: Scope)
| 150 | * Get a trace context for the given scope. |
| 151 | */ |
| 152 | export function getTraceContextFromScope(scope: Scope): TraceContext { |
| 153 | const externalContext = getExternalPropagationContext(); |
| 154 | if (externalContext) { |
| 155 | return { trace_id: externalContext.traceId, span_id: externalContext.spanId }; |
| 156 | } |
| 157 | |
| 158 | const propagationContext = scope.getPropagationContext(); |
| 159 | |
| 160 | const { traceId, parentSpanId, propagationSpanId } = propagationContext; |
| 161 | |
| 162 | const traceContext: TraceContext = { |
| 163 | trace_id: traceId, |
| 164 | span_id: propagationSpanId || generateSpanId(), |
| 165 | }; |
| 166 | |
| 167 | if (parentSpanId) { |
| 168 | traceContext.parent_span_id = parentSpanId; |
| 169 | } |
| 170 | |
| 171 | return traceContext; |
| 172 | } |
no test coverage detected