Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Span.php

function Span::recordException

@inheritDoc

File

vendor/open-telemetry/sdk/Trace/Span.php, line 190

Class

Span

Namespace

OpenTelemetry\SDK\Trace

Code

public function recordException(Throwable $exception, iterable $attributes = [], ?int $timestamp = null) : self {
    if ($this->hasEnded) {
        return $this;
    }
    if (++$this->totalRecordedEvents > $this->spanLimits
        ->getEventCountLimit()) {
        return $this;
    }
    $timestamp ??= Clock::getDefault()->now();
    $eventAttributesBuilder = $this->spanLimits
        ->getEventAttributesFactory()
        ->builder([
        'exception.type' => $exception::class,
        'exception.message' => $exception->getMessage(),
        'exception.stacktrace' => StackTraceFormatter::format($exception),
    ]);
    foreach ($attributes as $key => $value) {
        $eventAttributesBuilder[$key] = $value;
    }
    $this->events[] = new Event('exception', $timestamp, $eventAttributesBuilder->build());
    return $this;
}
RSS feed
Powered by Drupal