traceStart function
Implementation
TraceContext? traceStart(
String kind, String method,
({String traceId, String spanId, bool sampled})? parent) {
final tracer = _tracer;
if (tracer == null || !_traceAllowed(method)) return null;
final ctx = TraceContext(
parent?.traceId ?? _randomHex(16),
_randomHex(8),
parent?.spanId ?? '',
parent?.sampled ?? true,
);
if (!ctx.sampled) return ctx;
try {
tracer.onStart(kind, method, ctx.traceId, ctx.spanId, ctx.parentSpanId);
} catch (_) {
// observers must never break the call
}
return ctx;
}