(
options: {
sentryTrace: Parameters<typeof propagationContextFromHeaders>[0];
baggage: Parameters<typeof propagationContextFromHeaders>[1];
},
callback: () => V,
)
| 221 | * be attached to the incoming trace. |
| 222 | */ |
| 223 | export const continueTrace = <V>( |
| 224 | options: { |
| 225 | sentryTrace: Parameters<typeof propagationContextFromHeaders>[0]; |
| 226 | baggage: Parameters<typeof propagationContextFromHeaders>[1]; |
| 227 | }, |
| 228 | callback: () => V, |
| 229 | ): V => { |
| 230 | const carrier = getMainCarrier(); |
| 231 | const acs = getAsyncContextStrategy(carrier); |
| 232 | if (acs.continueTrace) { |
| 233 | return acs.continueTrace(options, callback); |
| 234 | } |
| 235 | |
| 236 | const { sentryTrace, baggage } = options; |
| 237 | |
| 238 | const client = getClient(); |
| 239 | const incomingDsc = baggageHeaderToDynamicSamplingContext(baggage); |
| 240 | if (client && !shouldContinueTrace(client, incomingDsc?.org_id)) { |
| 241 | return startNewTrace(callback); |
| 242 | } |
| 243 | |
| 244 | return withScope(scope => { |
| 245 | const propagationContext = propagationContextFromHeaders(sentryTrace, baggage); |
| 246 | scope.setPropagationContext(propagationContext); |
| 247 | _setSpanForScope(scope, undefined); |
| 248 | return callback(); |
| 249 | }); |
| 250 | }; |
| 251 | |
| 252 | /** |
| 253 | * 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