function AsynchronousMetricStream::collect
Overrides MetricStreamInterface::collect
File
-
vendor/
open-telemetry/ sdk/ Metrics/ Stream/ AsynchronousMetricStream.php, line 70
Class
- AsynchronousMetricStream
- @internal
Namespace
OpenTelemetry\SDK\Metrics\StreamCode
public function collect(int $reader) : DataInterface {
$metric = $this->metric;
if (($lastRead = $this->lastReads[$reader] ?? null) === null) {
$temporality = Temporality::CUMULATIVE;
$startTimestamp = $this->startTimestamp;
}
else {
$temporality = Temporality::DELTA;
$startTimestamp = $lastRead->timestamp;
$this->lastReads[$reader] = $metric;
$metric = $this->diff($lastRead, $metric);
}
return $this->aggregation
->toData($metric->attributes, $metric->summaries, Exemplar::groupByIndex($metric->exemplars), $startTimestamp, $metric->timestamp, $temporality);
}