ttrss/vendor/open-telemetry/sdk/Trace/Behavior/UsesSpanConverterTrait.php

42 lines
1000 B
PHP
Raw Normal View History

2023-10-20 14:12:29 +00:00
<?php
declare(strict_types=1);
namespace OpenTelemetry\SDK\Trace\Behavior;
use OpenTelemetry\SDK\Trace\SpanConverterInterface;
use OpenTelemetry\SDK\Trace\SpanDataInterface;
use OpenTelemetry\SDK\Trace\SpanExporter\NullSpanConverter;
trait UsesSpanConverterTrait
{
private ?SpanConverterInterface $converter = null;
/**
* @param SpanConverterInterface $converter
*/
protected function setSpanConverter(SpanConverterInterface $converter): void
{
$this->converter = $converter;
}
public function getSpanConverter(): SpanConverterInterface
{
if (null === $this->converter) {
$this->converter = new NullSpanConverter();
}
return $this->converter;
}
/**
* @param SpanDataInterface $span
* @return array
* @psalm-suppress PossiblyNullReference
*/
protected function convertSpan(SpanDataInterface $span): array
{
return $this->getSpanConverter()->convert([$span]);
}
}