function StreamFactory::createSynchronousWriter
Overrides MetricFactoryInterface::createSynchronousWriter
File
-
vendor/
open-telemetry/ sdk/ Metrics/ MetricFactory/ StreamFactory.php, line 81
Class
- StreamFactory
- @internal
Namespace
OpenTelemetry\SDK\Metrics\MetricFactoryCode
public function createSynchronousWriter(MetricRegistryInterface $registry, ResourceInfo $resource, InstrumentationScopeInterface $instrumentationScope, Instrument $instrument, int $timestamp, iterable $views, ?ExemplarFilterInterface $exemplarFilter = null) : array {
$streams = [];
$dedup = [];
foreach ($views as [
$view,
$registration,
]) {
if ($view->aggregation === null) {
continue;
}
$dedupId = $this->streamId($view->aggregation, $view->attributeKeys);
if (($streamId = $dedup[$dedupId] ?? null) === null) {
$stream = new SynchronousMetricStream($view->aggregation, $timestamp);
$streamId = $registry->registerSynchronousStream($instrument, $stream, new MetricAggregator($this->attributeProcessor($view->attributeKeys), $view->aggregation, $this->createExemplarReservoir($view->aggregation, $exemplarFilter)));
$streams[$streamId] = $stream;
$dedup[$dedupId] = $streamId;
}
$this->registerSource($view, $instrument, $instrumentationScope, $resource, $streams[$streamId], $registry, $registration, $streamId);
}
return array_keys($streams);
}