end method

void end({
  1. SpanStatus status = SpanStatus.ok,
  2. Object? error,
  3. StackTrace? stackTrace,
})

End the span. Emits LogSpan to the pipeline.

Implementation

void end({
  SpanStatus status = SpanStatus.ok,
  Object? error,
  StackTrace? stackTrace,
}) {
  if (_ended) return;
  _ended = true;

  final span = LogSpan(
    spanId: spanId,
    parentSpanId: parentSpanId,
    traceId: traceId,
    scope: scope,
    name: name,
    startTime: _startTime,
    endTime: _clock(),
    status: status,
    error: error,
    stackTrace: stackTrace,
    data: _data,
    events: List.unmodifiable(_events),
  );

  _onComplete(span);
}