Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. MetricAggregator.php

class MetricAggregator

@internal

Hierarchy

  • class \OpenTelemetry\SDK\Metrics\Stream\MetricAggregator implements \OpenTelemetry\SDK\Metrics\Stream\MetricAggregatorInterface

Expanded class hierarchy of MetricAggregator

1 file declares its use of MetricAggregator
StreamFactory.php in vendor/open-telemetry/sdk/Metrics/MetricFactory/StreamFactory.php

File

vendor/open-telemetry/sdk/Metrics/Stream/MetricAggregator.php, line 17

Namespace

OpenTelemetry\SDK\Metrics\Stream
View source
final class MetricAggregator implements MetricAggregatorInterface {
    
    /** @var array<AttributesInterface> */
    private array $attributes = [];
    private array $summaries = [];
    public function __construct(?AttributeProcessorInterface $attributeProcessor, AggregationInterface $aggregation, ?ExemplarReservoirInterface $exemplarReservoir = null) {
    }
    public function record(float|int $value, AttributesInterface $attributes, ContextInterface $context, int $timestamp) : void {
        $filteredAttributes = $this->attributeProcessor !== null ? $this->attributeProcessor
            ->process($attributes, $context) : $attributes;
        $raw = $filteredAttributes->toArray();
        $index = $raw !== [] ? serialize($raw) : 0;
        $this->attributes[$index] ??= $filteredAttributes;
        $this->aggregation
            ->record($this->summaries[$index] ??= $this->aggregation
            ->initialize(), $value, $attributes, $context, $timestamp);
        if ($this->exemplarReservoir !== null) {
            $this->exemplarReservoir
                ->offer($index, $value, $attributes, $context, $timestamp);
        }
    }
    public function collect(int $timestamp) : Metric {
        $exemplars = $this->exemplarReservoir ? $this->exemplarReservoir
            ->collect($this->attributes) : [];
        $metric = new Metric($this->attributes, $this->summaries, $timestamp, $exemplars);
        $this->attributes = [];
        $this->summaries = [];
        return $metric;
    }

}

Members

Title Sort descending Modifiers Object type Summary
MetricAggregator::$attributes private property @var array&lt;AttributesInterface&gt;
MetricAggregator::$summaries private property
MetricAggregator::collect public function
MetricAggregator::record public function
MetricAggregator::__construct public function

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal