*/ private array $metrics = []; /** * @var string|Temporality|null */ private $temporality; private bool $closed = false; /** * @param string|Temporality|null $temporality */ public function __construct($temporality = null) { $this->temporality = $temporality; } public function temporality(MetricMetadataInterface $metric) { return $this->temporality ?? $metric->temporality(); } /** * @return list */ public function collect(bool $reset = false): array { $metrics = $this->metrics; if ($reset) { $this->metrics = []; } return $metrics; } public function export(iterable $batch): bool { if ($this->closed) { return false; } /** @psalm-suppress InvalidPropertyAssignmentValue */ array_push($this->metrics, ...$batch); return true; } public function shutdown(): bool { if ($this->closed) { return false; } $this->closed = true; return true; } }