startSpan method

  1. @override
Future<EmbraceSpan?> startSpan(
  1. String name, {
  2. EmbraceSpan? parent,
  3. int? startTimeMs,
})
override

Create and start a new span. Returns a reference to the new span on success and null on failure.

Implementation

@override
Future<EmbraceSpan?> startSpan(
  String name, {
  EmbraceSpan? parent,
  int? startTimeMs,
}) async {
  return _runCatchingAndReturn<EmbraceSpan?>(
    'startSpan',
    () async {
      final id = await _platform.startSpan(
        name,
        parentSpanId: parent?.id,
        startTimeMs: startTimeMs,
      );
      if (id != null) {
        return Future.value(EmbraceSpanImpl(id, _platform));
      } else {
        return Future.value();
      }
    },
    defaultValue: null,
  );
}