setStatus method

  1. @override
void setStatus(
  1. StatusCode status, {
  2. String description = '',
})
override

Sets the status to the Span.

If used, this will override the default Span status. Default status code is api.StatusCode.unset.

Only the value of the last call will be recorded, and implementations are free to ignore previous calls.

Implementation

@override
void setStatus(api.StatusCode status, {String description = ''}) {
  // A status cannot be Unset after being set, and cannot be set to any other
  // status after being marked "Ok".
  if (status == api.StatusCode.unset || _status.code == api.StatusCode.ok) {
    return;
  }

  _status.code = status;

  // Description is ignored for statuses other than "Error".
  if (status == api.StatusCode.error && description.isNotEmpty) {
    _status.description = description;
  }
}