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()) {
final item = _peek();
item.scope.propagationContext = PropagationContext();
} else {
final item = _peek();
// if transactionContext has no sampled decision, run the traces sampler
var samplingDecision = transactionContext.samplingDecision;
if (samplingDecision == null) {
final samplingContext = SentrySamplingContext(
transactionContext, customSamplingContext ?? {});
samplingDecision = _tracesSampler.sample(samplingContext);
transactionContext =
transactionContext.copyWith(samplingDecision: samplingDecision);
}
if (transactionContext.origin == null) {
transactionContext = transactionContext.copyWith(
origin: SentryTraceOrigins.manual,
);
}
SentryProfiler? profiler;
if (_profilerFactory != null &&
_tracesSampler.sampleProfiling(samplingDecision)) {
profiler = _profilerFactory?.startProfiler(transactionContext);
}
final tracer = SentryTracer(
transactionContext,
this,
startTimestamp: startTimestamp,
waitForChildren: waitForChildren ?? false,
autoFinishAfter: autoFinishAfter,
trimEnd: trimEnd ?? false,
onFinish: onFinish,
profiler: profiler,
);
if (bindToScope ?? false) {
item.scope.span = tracer;
}
return tracer;
}
return NoOpSentrySpan();
}