traceSyncOperation<T> method

  1. @override
T traceSyncOperation<T>(
  1. TracedOperation operation,
  2. T execute()
)
override

Called when a synchronous operation trace point is reached.

T is the type of the result of the operation.

The method must call execute exactly once. execute might throw an exception. This method must return the same value as execute or throw the same exception as execute.

Implementation

@override
T traceSyncOperation<T>(
  TracedOperation operation,
  T Function() execute,
) {
  if (!_operationFilter(operation)) {
    return execute();
  }

  final name = _operationNameResolver(operation);
  final details = _operationDetailsResolver(operation);
  final task = _provideTimelineTask();
  try {
    task?.start(name, arguments: details);
    return _withCblTimelineTask(
      task,
      () => Timeline.timeSync(name, execute, arguments: details),
    );
  } finally {
    task?.finish();
  }
}