blob: ebb0225952d3ba43df05e585eab948b6f703837c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
<?php
declare(strict_types=1);
namespace OpenTelemetry\SDK\Trace\SpanExporter;
use ArrayObject;
use OpenTelemetry\SDK\Trace\Behavior\SpanExporterTrait;
use OpenTelemetry\SDK\Trace\SpanExporterInterface;
class InMemoryExporter implements SpanExporterInterface
{
use SpanExporterTrait;
private ArrayObject $storage;
public function __construct(?ArrayObject $storage = null)
{
$this->storage = $storage ?? new ArrayObject();
}
protected function doExport(iterable $spans): bool
{
foreach ($spans as $span) {
$this->storage[] = $span;
}
return true;
}
public function getSpans(): array
{
return (array) $this->storage;
}
public function getStorage(): ArrayObject
{
return $this->storage;
}
}
|