startTransactionWithContext method
ISentrySpan
startTransactionWithContext(
- SentryTransactionContext transactionContext, {
- Map<
String, dynamic> ? customSamplingContext, - DateTime? startTimestamp,
- bool? bindToScope,
- bool? waitForChildren,
- Duration? autoFinishAfter,
- bool? trimEnd,
- OnTransactionFinish? onFinish,
Creates a Transaction and returns the instance.
Implementation
ISentrySpan startTransactionWithContext(
SentryTransactionContext transactionContext, {
Map<String, dynamic>? customSamplingContext,
DateTime? startTimestamp,
bool? bindToScope,
bool? waitForChildren,
Duration? autoFinishAfter,
bool? trimEnd,
OnTransactionFinish? onFinish,
}) {
if (!_isEnabled) {
_options.logger(
SentryLevel.warning,
"Instance is disabled and this 'startTransaction' call is a no-op.",
);
} else if (!_options.isTracingEnabled()) {
_options.logger(
SentryLevel.info,
"Tracing is disabled and this 'startTransaction' returns a no-op.",
);
} else {
final item = _peek();
final samplingContext = SentrySamplingContext(
transactionContext, customSamplingContext ?? {});
// if transactionContext has no sampled decision, run the traces sampler
if (transactionContext.samplingDecision == null) {
final samplingDecision = _tracesSampler.sample(samplingContext);
transactionContext =
transactionContext.copyWith(samplingDecision: samplingDecision);
}
final tracer = SentryTracer(
transactionContext,
this,
startTimestamp: startTimestamp,
waitForChildren: waitForChildren ?? false,
autoFinishAfter: autoFinishAfter,
trimEnd: trimEnd ?? false,
onFinish: onFinish,
);
if (bindToScope ?? false) {
item.scope.span = tracer;
}
return tracer;
}
return NoOpSentrySpan();
}