(options: OpenTelemetrySpanContext)
| 146 | * it may just be a non-recording span if the span is not sampled or if tracing is disabled. |
| 147 | */ |
| 148 | export function startInactiveSpan(options: OpenTelemetrySpanContext): Span { |
| 149 | const tracer = getTracer(); |
| 150 | |
| 151 | const { name, parentSpan: customParentSpan } = options; |
| 152 | |
| 153 | // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan` |
| 154 | const wrapper = getActiveSpanWrapper<Span>(customParentSpan); |
| 155 | |
| 156 | return wrapper(() => { |
| 157 | const activeCtx = getContext(options.scope, options.forceTransaction); |
| 158 | const missingRequiredParent = options.onlyIfParent && !trace.getSpan(activeCtx); |
| 159 | let ctx = missingRequiredParent ? suppressTracing(activeCtx) : activeCtx; |
| 160 | |
| 161 | if (missingRequiredParent) { |
| 162 | getClient()?.recordDroppedEvent('no_parent_span', 'span'); |
| 163 | } |
| 164 | |
| 165 | const spanOptions = getSpanOptions(options); |
| 166 | |
| 167 | if (!hasSpansEnabled()) { |
| 168 | ctx = isTracingSuppressed(ctx) ? ctx : suppressTracing(ctx); |
| 169 | } |
| 170 | |
| 171 | const span = tracer.startSpan(name, spanOptions, ctx); |
| 172 | patchSpanEnd(span); |
| 173 | return span; |
| 174 | }); |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be |
no test coverage detected