function Span::recordException
@inheritDoc
File
-
vendor/
open-telemetry/ sdk/ Trace/ Span.php, line 190
Class
Namespace
OpenTelemetry\SDK\TraceCode
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;
}