From d0a600fb6803ec93cb4f9ff6af37cc1d81a779fe Mon Sep 17 00:00:00 2001 From: Tobias Bachert Date: Wed, 10 Aug 2022 14:11:47 +0200 Subject: [PATCH] Add support for concurrent exports (#790) * Add support for concurrent exports * Remove cancellation support from `::await()` --- src/SDK/Common/Future/CompletedFuture.php | 28 +++++++++++++++++++ src/SDK/Common/Future/FutureInterface.php | 16 +++++++++++ .../Behavior/SpanExporterDecoratorTrait.php | 8 +++--- src/SDK/Trace/Behavior/SpanExporterTrait.php | 15 +++++----- src/SDK/Trace/SpanExporterInterface.php | 5 ++-- .../SpanProcessor/BatchSpanProcessor.php | 2 +- .../SpanProcessor/SimpleSpanProcessor.php | 2 +- .../Unit/Contrib/AbstractHttpExporterTest.php | 4 +-- tests/Unit/Contrib/AgentExporterTest.php | 12 ++++---- .../JaegerHttpCollectorExporterTest.php | 14 +++++----- tests/Unit/Contrib/OTLPGrpcExporterTest.php | 8 +++--- tests/Unit/Contrib/OTLPHttpExporterTest.php | 10 +++---- .../SpanExporter/AbstractExporterTest.php | 2 +- .../SpanExporter/ConsoleSpanExporterTest.php | 8 +++--- .../SpanExporter/LoggerDecoratorTest.php | 18 +++++++----- .../Trace/SpanExporter/LoggerExporterTest.php | 5 +++- .../SpanProcessor/BatchSpanProcessorTest.php | 10 +++++-- .../SpanProcessor/SimpleSpanProcessorTest.php | 5 ++-- 18 files changed, 114 insertions(+), 58 deletions(-) create mode 100644 src/SDK/Common/Future/CompletedFuture.php create mode 100644 src/SDK/Common/Future/FutureInterface.php diff --git a/src/SDK/Common/Future/CompletedFuture.php b/src/SDK/Common/Future/CompletedFuture.php new file mode 100644 index 000000000..461ed0088 --- /dev/null +++ b/src/SDK/Common/Future/CompletedFuture.php @@ -0,0 +1,28 @@ + + */ +final class CompletedFuture implements FutureInterface +{ + /** @var T */ + private $value; + + /** + * @param T $value + */ + public function __construct($value) + { + $this->value = $value; + } + + public function await() + { + return $this->value; + } +} diff --git a/src/SDK/Common/Future/FutureInterface.php b/src/SDK/Common/Future/FutureInterface.php new file mode 100644 index 000000000..077e8f4c5 --- /dev/null +++ b/src/SDK/Common/Future/FutureInterface.php @@ -0,0 +1,16 @@ + $spans - * @return int - * @psalm-return SpanExporterInterface::STATUS_* + * @return FutureInterface */ - public function export(iterable $spans, ?CancellationInterface $cancellation = null): int + public function export(iterable $spans, ?CancellationInterface $cancellation = null): FutureInterface { $response = $this->decorated->export( $this->beforeExport($spans), $cancellation, ); - $this->afterExport($spans, $response); + $this->afterExport($spans, $response->await()); return $response; } diff --git a/src/SDK/Trace/Behavior/SpanExporterTrait.php b/src/SDK/Trace/Behavior/SpanExporterTrait.php index 4fa556def..af8ddb223 100644 --- a/src/SDK/Trace/Behavior/SpanExporterTrait.php +++ b/src/SDK/Trace/Behavior/SpanExporterTrait.php @@ -5,6 +5,8 @@ namespace OpenTelemetry\SDK\Trace\Behavior; use OpenTelemetry\SDK\Common\Future\CancellationInterface; +use OpenTelemetry\SDK\Common\Future\CompletedFuture; +use OpenTelemetry\SDK\Common\Future\FutureInterface; use OpenTelemetry\SDK\Trace\SpanDataInterface; use OpenTelemetry\SDK\Trace\SpanExporterInterface; @@ -29,19 +31,16 @@ public function forceFlush(?CancellationInterface $cancellation = null): bool abstract public static function fromConnectionString(string $endpointUrl, string $name, string $args); /** - * @param iterable $spans Batch of spans to export - * - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/specification/trace/sdk.md#exportbatch - * - * @psalm-return SpanExporterInterface::STATUS_* + * @param iterable $spans + * @return FutureInterface */ - public function export(iterable $spans, ?CancellationInterface $cancellation = null): int + public function export(iterable $spans, ?CancellationInterface $cancellation = null): FutureInterface { if (!$this->running) { - return SpanExporterInterface::STATUS_FAILED_NOT_RETRYABLE; + return new CompletedFuture(SpanExporterInterface::STATUS_FAILED_NOT_RETRYABLE); } - return $this->doExport($spans); /** @phpstan-ignore-line */ + return new CompletedFuture($this->doExport($spans)); /** @phpstan-ignore-line */ } /** diff --git a/src/SDK/Trace/SpanExporterInterface.php b/src/SDK/Trace/SpanExporterInterface.php index 83cd0d835..05d15a23d 100644 --- a/src/SDK/Trace/SpanExporterInterface.php +++ b/src/SDK/Trace/SpanExporterInterface.php @@ -5,6 +5,7 @@ namespace OpenTelemetry\SDK\Trace; use OpenTelemetry\SDK\Common\Future\CancellationInterface; +use OpenTelemetry\SDK\Common\Future\FutureInterface; /** * @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/specification/trace/sdk.md#span-exporter @@ -25,9 +26,9 @@ public static function fromConnectionString(string $endpointUrl, string $name, s * * @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/specification/trace/sdk.md#exportbatch * - * @psalm-return SpanExporterInterface::STATUS_* + * @psalm-return FutureInterface */ - public function export(iterable $spans, ?CancellationInterface $cancellation = null): int; + public function export(iterable $spans, ?CancellationInterface $cancellation = null): FutureInterface; /** @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/specification/trace/sdk.md#shutdown-2 */ public function shutdown(?CancellationInterface $cancellation = null): bool; diff --git a/src/SDK/Trace/SpanProcessor/BatchSpanProcessor.php b/src/SDK/Trace/SpanProcessor/BatchSpanProcessor.php index 544cfc0d5..9d794032a 100644 --- a/src/SDK/Trace/SpanProcessor/BatchSpanProcessor.php +++ b/src/SDK/Trace/SpanProcessor/BatchSpanProcessor.php @@ -105,7 +105,7 @@ public function forceFlush(?CancellationInterface $cancellation = null): bool return true; } - $this->exporter->export($this->queue); + $this->exporter->export($this->queue)->await(); $this->queue = []; $this->stopwatch->reset(); $this->exporter->forceFlush(); diff --git a/src/SDK/Trace/SpanProcessor/SimpleSpanProcessor.php b/src/SDK/Trace/SpanProcessor/SimpleSpanProcessor.php index 88293d967..c8d7cc610 100644 --- a/src/SDK/Trace/SpanProcessor/SimpleSpanProcessor.php +++ b/src/SDK/Trace/SpanProcessor/SimpleSpanProcessor.php @@ -37,7 +37,7 @@ public function onEnd(ReadableSpanInterface $span): void } if (null !== $this->exporter) { - $this->exporter->export([$span->toSpanData()]); + $this->exporter->export([$span->toSpanData()])->await(); } } diff --git a/tests/Unit/Contrib/AbstractHttpExporterTest.php b/tests/Unit/Contrib/AbstractHttpExporterTest.php index b7199bbf8..d06e80e1a 100644 --- a/tests/Unit/Contrib/AbstractHttpExporterTest.php +++ b/tests/Unit/Contrib/AbstractHttpExporterTest.php @@ -53,7 +53,7 @@ public function test_exporter_response_status($responseStatus, $expected): void $expected, $this->createExporter()->export([ $this->createMock(SpanData::class), - ]) + ])->await(), ); } @@ -107,7 +107,7 @@ public function test_client_exception_decides_return_code($exception, $expected) $expected, $this->createExporter()->export([ $this->createMock(SpanData::class), - ]) + ])->await(), ); } diff --git a/tests/Unit/Contrib/AgentExporterTest.php b/tests/Unit/Contrib/AgentExporterTest.php index fa884c5ad..801237016 100644 --- a/tests/Unit/Contrib/AgentExporterTest.php +++ b/tests/Unit/Contrib/AgentExporterTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace OpenTelemetry\Tests\Contrib\Unit; +namespace OpenTelemetry\Tests\Unit\Contrib; use OpenTelemetry\Contrib\Jaeger\AgentExporter; use OpenTelemetry\SDK\Trace\SpanExporterInterface; @@ -10,10 +10,10 @@ use PHPUnit\Framework\TestCase; /** - * @covers OpenTelemetry\Contrib\Jaeger\AgentExporter - * @covers OpenTelemetry\Contrib\Jaeger\JaegerTransport - * @covers OpenTelemetry\Contrib\Jaeger\ThriftUdpTransport - * @covers OpenTelemetry\Contrib\Jaeger\ParsedEndpointUrl + * @covers \OpenTelemetry\Contrib\Jaeger\AgentExporter + * @covers \OpenTelemetry\Contrib\Jaeger\JaegerTransport + * @covers \OpenTelemetry\Contrib\Jaeger\ThriftUdpTransport + * @covers \OpenTelemetry\Contrib\Jaeger\ParsedEndpointUrl */ class AgentExporterTest extends TestCase { @@ -24,7 +24,7 @@ public function test_happy_path() 'someServiceName', ); - $status = $exporter->export([new SpanData()]); + $status = $exporter->export([new SpanData()])->await(); $this->assertSame(SpanExporterInterface::STATUS_SUCCESS, $status); diff --git a/tests/Unit/Contrib/JaegerHttpCollectorExporterTest.php b/tests/Unit/Contrib/JaegerHttpCollectorExporterTest.php index b70e735d5..7f6530c73 100644 --- a/tests/Unit/Contrib/JaegerHttpCollectorExporterTest.php +++ b/tests/Unit/Contrib/JaegerHttpCollectorExporterTest.php @@ -10,12 +10,12 @@ use PHPUnit\Framework\TestCase; /** - * @covers OpenTelemetry\Contrib\Jaeger\HttpCollectorExporter - * @covers OpenTelemetry\Contrib\Jaeger\HttpSender - * @covers OpenTelemetry\Contrib\Jaeger\ThriftHttpTransport - * @covers OpenTelemetry\Contrib\Jaeger\ParsedEndpointUrl - * @covers OpenTelemetry\Contrib\Jaeger\BatchAdapter\BatchAdapter - * @covers OpenTelemetry\Contrib\Jaeger\BatchAdapter\BatchAdapterFactory + * @covers \OpenTelemetry\Contrib\Jaeger\HttpCollectorExporter + * @covers \OpenTelemetry\Contrib\Jaeger\HttpSender + * @covers \OpenTelemetry\Contrib\Jaeger\ThriftHttpTransport + * @covers \OpenTelemetry\Contrib\Jaeger\ParsedEndpointUrl + * @covers \OpenTelemetry\Contrib\Jaeger\BatchAdapter\BatchAdapter + * @covers \OpenTelemetry\Contrib\Jaeger\BatchAdapter\BatchAdapterFactory * */ class JaegerHttpCollectorExporterTest extends TestCase @@ -35,7 +35,7 @@ public function test_happy_path() $this->getStreamFactoryInterfaceMock() ); - $status = $exporter->export([new SpanData()]); + $status = $exporter->export([new SpanData()])->await(); $this->assertSame(SpanExporterInterface::STATUS_SUCCESS, $status); } diff --git a/tests/Unit/Contrib/OTLPGrpcExporterTest.php b/tests/Unit/Contrib/OTLPGrpcExporterTest.php index 2e0d68919..2ef488ab9 100644 --- a/tests/Unit/Contrib/OTLPGrpcExporterTest.php +++ b/tests/Unit/Contrib/OTLPGrpcExporterTest.php @@ -16,7 +16,7 @@ use org\bovigo\vfs\vfsStream; /** - * @covers OpenTelemetry\Contrib\OtlpGrpc\Exporter + * @covers \OpenTelemetry\Contrib\OtlpGrpc\Exporter */ class OTLPGrpcExporterTest extends AbstractExporterTest { @@ -55,7 +55,7 @@ public function test_exporter_happy_path(): void ]) ); - $exporterStatusCode = $exporter->export([new SpanData()]); + $exporterStatusCode = $exporter->export([new SpanData()])->await(); $this->assertSame(SpanExporterInterface::STATUS_SUCCESS, $exporterStatusCode); } @@ -80,14 +80,14 @@ public function test_exporter_unexpected_grpc_response_status(): void ]) ); - $exporterStatusCode = $exporter->export([new SpanData()]); + $exporterStatusCode = $exporter->export([new SpanData()])->await(); $this->assertSame(SpanExporterInterface::STATUS_FAILED_NOT_RETRYABLE, $exporterStatusCode); } public function test_exporter_grpc_responds_as_unavailable(): void { - $this->assertEquals(SpanExporterInterface::STATUS_FAILED_RETRYABLE, (new Exporter())->export([new SpanData()])); + $this->assertEquals(SpanExporterInterface::STATUS_FAILED_RETRYABLE, (new Exporter())->export([new SpanData()])->await()); } public function test_set_headers_with_environment_variables(): void diff --git a/tests/Unit/Contrib/OTLPHttpExporterTest.php b/tests/Unit/Contrib/OTLPHttpExporterTest.php index 5a8765f5b..eba580ac5 100644 --- a/tests/Unit/Contrib/OTLPHttpExporterTest.php +++ b/tests/Unit/Contrib/OTLPHttpExporterTest.php @@ -21,7 +21,7 @@ use Psr\Http\Client\NetworkExceptionInterface; /** - * @covers OpenTelemetry\Contrib\OtlpHttp\Exporter + * @covers \OpenTelemetry\Contrib\OtlpHttp\Exporter */ class OTLPHttpExporterTest extends AbstractExporterTest { @@ -59,7 +59,7 @@ public function test_exporter_response_status($responseStatus, $expected): void $this->assertEquals( $expected, - $exporter->export([new SpanData()]) + $exporter->export([new SpanData()])->await(), ); } @@ -90,7 +90,7 @@ public function test_client_exceptions_should_decide_return_code($exception, $ex $this->assertEquals( $expected, - $exporter->export([new SpanData()]) + $exporter->export([new SpanData()])->await(), ); } @@ -129,7 +129,7 @@ public function test_exporter_with_config_via_env_vars(?string $endpoint, string $client = new Client(['handler' => $stack]); $exporter = new Exporter($client, new HttpFactory(), new HttpFactory()); - $exporter->export([new SpanData()]); + $exporter->export([new SpanData()])->await(); $request = $container[0]['request']; @@ -164,7 +164,7 @@ public function test_should_be_ok_to_exporter_empty_spans_collection(): void $this->getClientInterfaceMock(), $this->getRequestFactoryInterfaceMock(), $this->getStreamFactoryInterfaceMock() - ))->export([]) + ))->export([])->await(), ); } diff --git a/tests/Unit/SDK/Trace/SpanExporter/AbstractExporterTest.php b/tests/Unit/SDK/Trace/SpanExporter/AbstractExporterTest.php index 21701cb3f..6f43f6b0a 100644 --- a/tests/Unit/SDK/Trace/SpanExporter/AbstractExporterTest.php +++ b/tests/Unit/SDK/Trace/SpanExporter/AbstractExporterTest.php @@ -38,6 +38,6 @@ public function test_fails_if_not_test_running(): void $span = $this->createMock(SpanData::class); $exporter->shutdown(); - $this->assertSame(SpanExporterInterface::STATUS_FAILED_NOT_RETRYABLE, $exporter->export([$span])); + $this->assertSame(SpanExporterInterface::STATUS_FAILED_NOT_RETRYABLE, $exporter->export([$span])->await()); } } diff --git a/tests/Unit/SDK/Trace/SpanExporter/ConsoleSpanExporterTest.php b/tests/Unit/SDK/Trace/SpanExporter/ConsoleSpanExporterTest.php index 0f1fe5dd0..960c4f40f 100644 --- a/tests/Unit/SDK/Trace/SpanExporter/ConsoleSpanExporterTest.php +++ b/tests/Unit/SDK/Trace/SpanExporter/ConsoleSpanExporterTest.php @@ -10,7 +10,7 @@ use OpenTelemetry\SDK\Trace\SpanExporterInterface; /** - * @covers OpenTelemetry\SDK\Trace\SpanExporter\ConsoleSpanExporter + * @covers \OpenTelemetry\SDK\Trace\SpanExporter\ConsoleSpanExporter */ class ConsoleSpanExporterTest extends AbstractExporterTest { @@ -64,7 +64,7 @@ public function test_export_success(): void SpanExporterInterface::STATUS_SUCCESS, (new ConsoleSpanExporter($converter))->export([ $this->createMock(SpanDataInterface::class), - ]) + ])->await(), ); ob_end_clean(); @@ -84,7 +84,7 @@ public function test_export_failed(): void SpanExporterInterface::STATUS_FAILED_NOT_RETRYABLE, (new ConsoleSpanExporter($converter))->export([ $this->createMock(SpanDataInterface::class), - ]) + ])->await(), ); ob_end_clean(); @@ -108,7 +108,7 @@ public function test_export_output(): void (new ConsoleSpanExporter($converter))->export([ $this->createMock(SpanDataInterface::class), - ]); + ])->await(); } public function test_from_connection_string(): void diff --git a/tests/Unit/SDK/Trace/SpanExporter/LoggerDecoratorTest.php b/tests/Unit/SDK/Trace/SpanExporter/LoggerDecoratorTest.php index 54a6d153b..e5c2499b6 100644 --- a/tests/Unit/SDK/Trace/SpanExporter/LoggerDecoratorTest.php +++ b/tests/Unit/SDK/Trace/SpanExporter/LoggerDecoratorTest.php @@ -4,6 +4,7 @@ namespace OpenTelemetry\Tests\Unit\SDK\Trace\SpanExporter; +use OpenTelemetry\SDK\Common\Future\CompletedFuture; use OpenTelemetry\SDK\Trace\SpanExporter\LoggerDecorator; use OpenTelemetry\SDK\Trace\SpanExporterInterface; use PHPUnit\Framework\MockObject\MockObject; @@ -11,7 +12,7 @@ use RuntimeException; /** - * @covers OpenTelemetry\SDK\Trace\SpanExporter\LoggerDecorator + * @covers \OpenTelemetry\SDK\Trace\SpanExporter\LoggerDecorator */ class LoggerDecoratorTest extends AbstractLoggerAwareTest { @@ -66,7 +67,7 @@ public function test_export_success(): void $this->getSpanExporterInterfaceMock() ->expects($this->once()) ->method('export') - ->willReturn(SpanExporterInterface::STATUS_SUCCESS); + ->willReturn(new CompletedFuture(SpanExporterInterface::STATUS_SUCCESS)); $this->getLoggerInterfaceMock() ->expects($this->once()) @@ -76,7 +77,8 @@ public function test_export_success(): void $this->createLoggerDecorator() ->export( $this->createSpanMocks() - ); + ) + ->await(); } /** @@ -88,7 +90,7 @@ public function test_export_failed_retryable(): void $this->getSpanExporterInterfaceMock() ->expects($this->once()) ->method('export') - ->willReturn(SpanExporterInterface::STATUS_FAILED_RETRYABLE); + ->willReturn(new CompletedFuture(SpanExporterInterface::STATUS_FAILED_RETRYABLE)); $this->getLoggerInterfaceMock() ->expects($this->once()) @@ -98,7 +100,8 @@ public function test_export_failed_retryable(): void $this->createLoggerDecorator() ->export( $this->createSpanMocks() - ); + ) + ->await(); } /** @@ -110,7 +113,7 @@ public function test_export_failed_not_retryable(): void $this->getSpanExporterInterfaceMock() ->expects($this->once()) ->method('export') - ->willReturn(SpanExporterInterface::STATUS_FAILED_NOT_RETRYABLE); + ->willReturn(new CompletedFuture(SpanExporterInterface::STATUS_FAILED_NOT_RETRYABLE)); $this->getLoggerInterfaceMock() ->expects($this->once()) @@ -120,7 +123,8 @@ public function test_export_failed_not_retryable(): void $this->createLoggerDecorator() ->export( $this->createSpanMocks() - ); + ) + ->await(); } /** diff --git a/tests/Unit/SDK/Trace/SpanExporter/LoggerExporterTest.php b/tests/Unit/SDK/Trace/SpanExporter/LoggerExporterTest.php index 6121b19df..6630c6909 100644 --- a/tests/Unit/SDK/Trace/SpanExporter/LoggerExporterTest.php +++ b/tests/Unit/SDK/Trace/SpanExporter/LoggerExporterTest.php @@ -9,7 +9,7 @@ use OpenTelemetry\SDK\Trace\SpanExporterInterface; /** - * @covers OpenTelemetry\SDK\Trace\SpanExporter\LoggerExporter + * @covers \OpenTelemetry\SDK\Trace\SpanExporter\LoggerExporter */ class LoggerExporterTest extends AbstractExporterTest { @@ -53,6 +53,7 @@ public function test_export_granularity_aggregate(): void ->export( $this->createSpanMocks() ) + ->await(), ); } @@ -72,6 +73,7 @@ public function test_export_granularity_span(): void SpanExporterInterface::STATUS_SUCCESS, $this->createLoggerExporter(LoggerExporter::GRANULARITY_SPAN) ->export($spans) + ->await(), ); } @@ -91,6 +93,7 @@ public function test_logger_throws_exception(): void ->export( $this->createSpanMocks() ) + ->await(), ); } diff --git a/tests/Unit/SDK/Trace/SpanProcessor/BatchSpanProcessorTest.php b/tests/Unit/SDK/Trace/SpanProcessor/BatchSpanProcessorTest.php index 42a8d6826..13544b472 100644 --- a/tests/Unit/SDK/Trace/SpanProcessor/BatchSpanProcessorTest.php +++ b/tests/Unit/SDK/Trace/SpanProcessor/BatchSpanProcessorTest.php @@ -10,6 +10,7 @@ use Mockery\Adapter\Phpunit\MockeryTestCase; use OpenTelemetry\API\Trace as API; use OpenTelemetry\Context\Context; +use OpenTelemetry\SDK\Common\Future\CompletedFuture; use OpenTelemetry\SDK\Common\Time\ClockFactory; use OpenTelemetry\SDK\Common\Time\ClockInterface; use OpenTelemetry\SDK\Trace\ReadWriteSpanInterface; @@ -173,7 +174,8 @@ function (array $spans) { return true; } ) - ); + ) + ->andReturn(new CompletedFuture(0)); /** @var SpanExporterInterface $exporter */ $processor = new BatchSpanProcessor( @@ -275,7 +277,8 @@ function (array $spans) use ($sampledSpan) { return true; } ) - ); + ) + ->andReturn(new CompletedFuture(0)); $batchProcessor = new BatchSpanProcessor($exporter, $this->testClock); foreach ([$sampledSpan, $nonSampledSpan] as $span) { @@ -305,7 +308,8 @@ function (array $spans) { return true; } ) - ); + ) + ->andReturn(new CompletedFuture(0)); $processor = new BatchSpanProcessor( $exporter, diff --git a/tests/Unit/SDK/Trace/SpanProcessor/SimpleSpanProcessorTest.php b/tests/Unit/SDK/Trace/SpanProcessor/SimpleSpanProcessorTest.php index ccbfe02d8..518c8bdcf 100644 --- a/tests/Unit/SDK/Trace/SpanProcessor/SimpleSpanProcessorTest.php +++ b/tests/Unit/SDK/Trace/SpanProcessor/SimpleSpanProcessorTest.php @@ -10,6 +10,7 @@ use OpenTelemetry\API\Trace\SpanContext; use OpenTelemetry\API\Trace\SpanContextInterface; use OpenTelemetry\Context\Context; +use OpenTelemetry\SDK\Common\Future\CompletedFuture; use OpenTelemetry\SDK\Trace\ReadableSpanInterface; use OpenTelemetry\SDK\Trace\ReadWriteSpanInterface; use OpenTelemetry\SDK\Trace\SpanExporterInterface; @@ -17,7 +18,7 @@ use OpenTelemetry\Tests\Unit\SDK\Util\SpanData; /** - * @covers OpenTelemetry\SDK\Trace\SpanProcessor\SimpleSpanProcessor + * @covers \OpenTelemetry\SDK\Trace\SpanProcessor\SimpleSpanProcessor */ class SimpleSpanProcessorTest extends MockeryTestCase { @@ -63,7 +64,7 @@ public function test_on_end_sampled_span(): void $spanData = new SpanData(); $this->readableSpan->expects('getContext')->andReturn($this->sampledSpanContext); $this->readableSpan->expects('toSpanData')->andReturn($spanData); - $this->spanExporter->expects('export')->with([$spanData]); + $this->spanExporter->expects('export')->with([$spanData])->andReturn(new CompletedFuture(0)); $this->simpleSpanProcessor->onEnd($this->readableSpan); }