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

Breadcrumb

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

class MeterProvider

Hierarchy

  • class \OpenTelemetry\SDK\Metrics\MeterProvider implements \OpenTelemetry\SDK\Metrics\MeterProviderInterface

Expanded class hierarchy of MeterProvider

File

vendor/open-telemetry/sdk/Metrics/MeterProvider.php, line 24

Namespace

OpenTelemetry\SDK\Metrics
View source
final class MeterProvider implements MeterProviderInterface {
    private readonly MeterInstruments $instruments;
    private readonly MetricRegistryInterface $registry;
    private readonly MetricWriterInterface $writer;
    private readonly ArrayAccess $destructors;
    private bool $closed = false;
    private readonly WeakMap $meters;
    
    /**
     * @param iterable<MetricReaderInterface&MetricSourceRegistryInterface&DefaultAggregationProviderInterface> $metricReaders
     */
    public function __construct(?ContextStorageInterface $contextStorage, ResourceInfo $resource, ClockInterface $clock, AttributesFactoryInterface $attributesFactory, InstrumentationScopeFactoryInterface $instrumentationScopeFactory, iterable $metricReaders, ViewRegistryInterface $viewRegistry, ?ExemplarFilterInterface $exemplarFilter, StalenessHandlerFactoryInterface $stalenessHandlerFactory, MetricFactoryInterface $metricFactory = new StreamFactory(), ?Configurator $configurator = null) {
        $this->instruments = new MeterInstruments();
        $registry = new MetricRegistry($contextStorage, $attributesFactory, $clock);
        $this->registry = $registry;
        $this->writer = $registry;
        $this->destructors = new WeakMap();
        $this->meters = new WeakMap();
    }
    public function getMeter(string $name, ?string $version = null, ?string $schemaUrl = null, iterable $attributes = []) : MeterInterface {
        if ($this->closed || Sdk::isDisabled()) {
            
            //@todo create meter provider from factory, and move Sdk::isDisabled() there
            return new NoopMeter();
        }
        $meter = new Meter($this->metricFactory, $this->resource, $this->clock, $this->stalenessHandlerFactory, $this->metricReaders, $this->viewRegistry, $this->exemplarFilter, $this->instruments, $this->instrumentationScopeFactory
            ->create($name, $version, $schemaUrl, $attributes), $this->registry, $this->writer, $this->destructors, $this->configurator);
        $this->meters
            ->offsetSet($meter, null);
        return $meter;
    }
    public function shutdown() : bool {
        if ($this->closed) {
            return false;
        }
        $this->closed = true;
        $success = true;
        foreach ($this->metricReaders as $metricReader) {
            if (!$metricReader->shutdown()) {
                $success = false;
            }
        }
        return $success;
    }
    public function forceFlush() : bool {
        if ($this->closed) {
            return false;
        }
        $success = true;
        foreach ($this->metricReaders as $metricReader) {
            if (!$metricReader->forceFlush()) {
                $success = false;
            }
        }
        return $success;
    }
    public static function builder() : MeterProviderBuilder {
        return new MeterProviderBuilder();
    }
    
    /**
     * Update the {@link Configurator} for a {@link MeterProvider}, which will reconfigure
     *  all meters created from the provider.
     *
     * @experimental
     */
    public function updateConfigurator(Configurator $configurator) : void {
        $this->configurator = $configurator;
        foreach ($this->meters as $meter => $unused) {
            $meter->updateConfigurator($configurator);
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
MeterProvider::$closed private property
MeterProvider::$destructors private property
MeterProvider::$instruments private property
MeterProvider::$meters private property
MeterProvider::$registry private property
MeterProvider::$writer private property
MeterProvider::builder public static function
MeterProvider::forceFlush public function Overrides MeterProviderInterface::forceFlush
MeterProvider::getMeter public function Returns a `Meter` for the given instrumentation scope. Overrides MeterProviderInterface::getMeter
MeterProvider::shutdown public function Overrides MeterProviderInterface::shutdown
MeterProvider::updateConfigurator public function Update the {@link Configurator} for a {@link MeterProvider}, which will reconfigure
all meters created from the provider.
Overrides Configurable::updateConfigurator
MeterProvider::__construct public function
RSS feed
Powered by Drupal