(callback: () => T)
| 319 | * or page will automatically create a new trace. |
| 320 | */ |
| 321 | export function startNewTrace<T>(callback: () => T): T { |
| 322 | const acs = getAcs(); |
| 323 | if (acs.startNewTrace) { |
| 324 | return acs.startNewTrace(callback); |
| 325 | } |
| 326 | |
| 327 | return withScope(scope => { |
| 328 | scope.setPropagationContext({ |
| 329 | traceId: generateTraceId(), |
| 330 | sampleRand: safeMathRandom(), |
| 331 | }); |
| 332 | DEBUG_BUILD && debug.log(`Starting a new trace with id ${scope.getPropagationContext().traceId}`); |
| 333 | return withActiveSpan(null, callback); |
| 334 | }); |
| 335 | } |
| 336 | |
| 337 | /** |
| 338 | * The placeholder returned from `startSpan*` when `onlyIfParent` is set but there is no parent span. |
no test coverage detected